Ravindra BagaleCourses & study guides मराठी Track your progress

30. Cloud and AWS Security

Cyber Security

30.4 Protecting Data: S3, Encryption and Secrets

S3 exposure is the classic cloud leak. Defences:

  • Turn on S3 Block Public Access at the account level (S3 console, Block Public Access settings for this account). This overrides mistakes on individual buckets.
  • Serve public files through CloudFront with Origin Access Control instead of making the bucket public.
  • Use bucket policies that allow only your app role; enable versioning so deleted or ransomed files can be restored.
aws s3api get-public-access-block --bucket reels-media-pune
aws s3api put-public-access-block --bucket reels-media-pune \
  --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true
aws s3api put-bucket-versioning --bucket reels-media-pune --versioning-configuration Status=Enabled

Encryption. S3 encrypts new objects by default (SSE-S3). For more control use KMS keys (SSE-KMS): you decide who may use the key, and every use is logged in CloudTrail. Tick "Encryption" when creating RDS and EBS volumes – it cannot be switched on later without a snapshot copy.

Secrets. Database passwords and API keys belong in AWS Secrets Manager or SSM Parameter Store (SecureString), not in config.php committed to Git.

aws ssm put-parameter --name /reels/db/password --type SecureString --value 'Str0ng#Pass'
aws ssm get-parameter --name /reels/db/password --with-decryption --query Parameter.Value --output text

The EC2 role then needs only ssm:GetParameter on that one parameter.

Ravindra Bagale's Tip

The reason for making a bucket "public" is always "the images weren't showing". The right fix for that is CloudFront + OAC, not a public bucket. And once you turn on account-level Block Public Access, future mistakes are stopped automatically too.

Lab

Enable account-level Block Public Access. Move the database password of your reels app from config.php into SSM Parameter Store as a SecureString, give the EC2 role permission to read only that parameter, and update the PHP code to fetch it with the AWS SDK.

Real incident: Meta – stolen employee GitHub login used to take code and personal data (Oct 2026)

1. What happened

On 13 October 2026, Meta said an outside group got into some of its GitHub repositories using one employee's stolen credentials. Meta detected the intrusion a few weeks earlier. About 99% of what was taken was business data – software code for some Meta products. The other 1% was personal data that had been put into the repositories by mistake, against company policy. Meta is notifying about 1,500 people, most of them Meta employees in the US, and is offering them credit and dark-web monitoring. Meta cut off the attackers' access, brought in GitHub and law enforcement, rotated the secrets found in the repositories, and is adding scans to catch personal data uploaded to GitHub by mistake. Meta says no Meta product had a vulnerability and its internal systems were not breached. It has not said what types of personal data were involved.

2. How the hack happened (public reporting only – high-level)

  1. An attacker gets hold of one employee's GitHub login (Meta has not said exactly how it was stolen).
  2. The attacker signs in as that employee – to GitHub it looks like a normal user.
  3. The attacker reads and copies repositories that employee could access.
  4. Inside the code are secrets (keys, tokens) and some personal data that someone had committed by mistake – so a code leak also becomes a data leak.
  5. Meta detects the access, cuts it off and rotates every secret in those repositories so stolen keys stop working.

3. How to stop it / defend (this lesson: Protecting Data, S3, Encryption and Secrets)

  • Strong login for code platforms. Turn on MFA for GitHub, and prefer phishing-resistant security keys or passkeys over SMS codes.
  • Short-lived tokens. Use fine-grained tokens with an expiry date, and SSO for the organisation, so a stolen token works only for a short time.
  • Never put secrets in code. Keep passwords and keys in SSM Parameter Store or Secrets Manager (like the Lab above), not in config.php or Git.
  • Turn on secret scanning and push protection. GitHub can block a push that contains a key before it is saved.
  • No real personal data in repositories. Use fake test data. Real customer or employee data belongs in an encrypted, access-controlled store.
  • Watch the audit log. Alert on unusual clones, many downloads, or logins from new places.

4. How to take care so it won't happen again (checklist)

  • [ ] MFA is required for every member of your GitHub organisation.
  • [ ] Personal access tokens are fine-grained and expire within 90 days or less.
  • [ ] Secret scanning and push protection are switched on for all repositories.
  • [ ] Run a scan of your old commits for keys and personal data, and rotate anything found.
  • [ ] Each person can reach only the repositories they need.
  • [ ] When someone leaves, their access and tokens are removed the same day.
  • [ ] India students: personal data in code also falls under the DPDP Act – keep it out of Git, and report major incidents to CERT-In within the required time (see Ch.34).

Source: SecurityWeek, "Meta Says Hackers Took Code, Personal Data of 1,500 in GitHub Breach", 13 October 2026; Cybernews, "Meta GitHub breach exposes data of 1,500 people", October 2026.

Check if you're safe: Password Strength Checker

Real incident: Gheist – stolen GitHub tokens used to print private repository secrets into GitHub Actions logs (Oct 2026)

1. What happened

In this lesson you learned one rule: secrets (passwords, API keys, cloud keys) must live in a safe store, not in code. This real case shows the next step. Even when secrets are stored the right way, anyone who can write to the repository can make a pipeline read them. A GitHub token is like a password that lets a program use your GitHub account. A GitHub Actions workflow is a small file in the repository that tells GitHub to run jobs (build, test, deploy) by itself.

  • On 25 October 2026, the cloud security company Wiz published research on a campaign it calls Gheist. Wiz has tracked it since 15 September 2026.
  • The attackers used stolen GitHub tokens. For every repository a token could reach, their tool added a small workflow that printed the repository's secrets into the job log.
  • Wiz recovered more than 13,500 planted branches from more than 850 compromised accounts, from personal projects to the private repositories of enterprise organizations.
  • Since 28 July 2026, GitHub holds suspicious workflow runs in public repositories until a collaborator approves them. Every public Gheist run Wiz checked was stuck there, so it never ran. But this hold does not cover private repositories or GitHub Enterprise Server. There, the runs completed.
  • In some enterprise organizations, Wiz saw the tool clone private repositories first. Hours later, cloud credentials from the same organization were used to list AWS Secrets Manager secrets. Wiz does not say where those credentials came from.
  • Wiz says the stolen tokens came from sources such as infostealer logs (data stolen by malware from people's computers) and tokens exposed in earlier supply-chain attacks. As of 24 October the campaign was still running, and about two-thirds of the accounts involved were no longer available on GitHub.

2. How the hack happened (public reporting only – high-level)

  1. The attacker got stolen GitHub tokens that could write to repositories.
  2. For each repository, the tool made a new branch with a name like ci-sync- plus six random characters.
  3. On that branch it added one workflow file named sync-check, with the commit message ci: sync config. The commit looked like it came from the token's owner.
  4. A push starts a workflow by itself. So the job ran at once and printed every secret it could read. The values were encoded, so GitHub's automatic hiding of secrets in logs did not recognise them.
  5. One version ran the job once for each deployment environment, so environment secrets (often production keys) were printed too.
  6. The tool downloaded the log through GitHub's own API and deleted the run seconds later. The secrets left through GitHub itself, so there was no attacker server to block.
  7. From about 19 October, one version also tried to search self-hosted runner machines for more keys. Wiz calls that job buggy and reports no successful run.

3. How to stop it / defend (this lesson: protecting secrets)

Why: a secret is only as safe as the list of people and jobs that can read it. On GitHub, anyone with write access to a repository can use every secret in it. So a stolen token with write access is enough.

Controls you can use:

  1. Put production secrets in a protected environment. In the repository go to Settings, then Environments, then create production, then turn on Required reviewers. A job cannot read that environment's secrets until a reviewer approves it.
  2. Use OIDC instead of stored cloud keys. OIDC lets a workflow get a short-lived AWS login, so no long-lived AWS key sits in GitHub. In the AWS role trust policy, allow only your protected branch or environment. Example condition value: repo:YOUR-ORG/YOUR-REPO:environment:production. A random new branch then cannot get the role.
  3. Keep the real secret in AWS Secrets Manager or SSM Parameter Store, like this lesson's lab. Give the pipeline role read access to only the one secret it needs.
  4. Use short-lived, fine-grained tokens or GitHub Apps instead of old personal access tokens. Give each token only the repositories it needs, and set an expiry date.
  5. Run self-hosted runners as short-lived machines, without Docker socket access and without open access to the cloud metadata service.

Example: check your own repository for planted branches. Run these steps one by one.

  1. Open a terminal inside your own cloned repository.
  2. Run git ls-remote --heads origin 'ci-sync-*'
  3. Output when you are safe: nothing. The command prints an empty result and returns to the prompt.
  4. Output when there is a problem: a line like 9f2c… refs/heads/ci-sync-a1b2c3. It means a branch with that name exists on GitHub.
  5. What it means: if you find one, do not run or approve it. Rotate every secret the repository could use, then revoke the token that pushed it. Deleting the branch or the run does not undo the leak.

4. How to take care so it won't happen again (checklist)

  • [ ] Production secrets sit in an environment with Required reviewers.
  • [ ] Pipelines sign in to AWS with OIDC, and the trust policy allows only protected branches or environments.
  • [ ] No long-lived AWS keys are stored as GitHub secrets.
  • [ ] Every GitHub token is fine-grained, has an expiry date, and reaches only the repositories it needs.
  • [ ] Every month, look in the audit log for workflow runs deleted within a minute and for unknown new branches.
  • [ ] If a token leaks: rotate every secret it could reach, revoke the token, and scan the owner's computer for infostealer malware.
  • [ ] Self-hosted runners are short-lived and have no Docker socket.

Source: Wiz Blog, "Gheist: Attempted Scaled Abuse of Stolen GitHub Tokens Stumbles" (Rami McCarthy, Hila Ramati), 25 October 2026; The Hacker News, "Gheist Uses Stolen GitHub Tokens to Steal Private Repository Secrets via Actions Logs", 26 October 2026.

Check if you're safe: Password Strength Checker

Real incident: Chainalysis – offensive agentic AI intrusion exposed customer profile data (Oct–Nov 2026)

1. What happened

In this lesson you learnt that “protecting data” means knowing which fields an attacker can reach even when the crown-jewel investigation content stays locked.

  • On about 30–31 October 2026, crypto-compliance firm Chainalysis disclosed a security incident. It updated the notice around 2 November 2026.
  • An external actor used what Chainalysis called “offensive agentic techniques” to reach internal systems and tools.
  • Accessed data was described as non-sensitive customer account / profile fields: user IDs, full names, email addresses, and organization role labels.
  • Chainalysis said it found no evidence of access to investigation content, transaction or query results, clear-text passwords, MFA secrets, or session tokens.
  • Customers were notified; users were told to enable MFA and watch for suspicious password-reset or authentication requests.

2. How the hack happened (public reporting only – high-level)

  1. An outside actor automated parts of the intrusion with agent-style offensive tooling.
  2. That path reached some internal tools that could read customer profile records.
  3. Profile fields (names, emails, roles, IDs) were exposed; deeper investigation data was not, per the company.
  4. Chainalysis contained the access, assessed scope per customer org, and published updates.
  5. Customers were asked to harden login (MFA) and treat unexpected reset mails as suspect.

3. How to stop it / defend (this lesson: protecting data)

Why: even “just email + name + role” is enough for targeted phishing against your staff and your customers.

Controls you can use:

  1. Separate profile stores from investigation vaults with different credentials and networks.
  2. Turn on MFA account-wide and check admin MFA coverage (Example 1).
  3. Alert on password-reset spikes after any vendor breach mail (Example 2).
  4. Publish a status page customers can trust when rumors start (Example 3).
  5. Least privilege on internal tools that can dump user directories – agents love wide API tokens.
  6. Log and review agent / automation identities the same way you review human admins.

Example 1: sanity-check cloud MFA posture on an account you own.

  1. Run aws iam get-account-summary 2>/dev/null | head -n 20
  2. Output: like "AccountMFAEnabled": 1,\n"Users": 42.
  3. What it means: root/account MFA is on. Still enforce MFA on every human and automation user.

Example 2: watch password-reset lines in your app auth log.

  1. Run grep -iE 'password.?reset|mfa|login' /var/log/app/auth.log 2>/dev/null | tail -n 5
  2. Output: like 2026-10-31T09:12:01Z WARN password_reset requested for user=alex@example.com ip=198.51.100.9.
  3. What it means: a reset from a strange IP right after a breach headline is a call to the user, not a quiet ignore.

Example 3: read your own status API (or skip if you have none).

  1. Run curl -s https://status.example.com/api/v2/summary.json 2>/dev/null | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d.get("status",{}).get("description","n/a"))' 2>/dev/null || echo status-check-skipped
  2. Output: like All Systems Operational.
  3. What it means: customers need one trusted place for “what was accessed” updates.

4. How to take care so it won't happen again (checklist)

  • [ ] Profile PII and investigation data sit in different trust zones.
  • [ ] MFA required for every customer and every internal admin.
  • [ ] Password-reset and new-device alerts are on.
  • [ ] Automation / agent service accounts are inventoried and short-lived.
  • [ ] Customer notice template names exactly which fields were / were not touched.
  • [ ] Post-incident: rotate tokens the agent path could have seen.

Source: Chainalysis blog, "Security Incident Information" (October 30 disclosure, updated November 2, 2026); BleepingComputer, The Hacker News, SecurityWeek and The Block coverage of the same notice.

Ravindra Bagale's Tip

“Only names and emails” is still phishing fuel. After an agentic intrusion, force MFA, watch password-reset spikes, and say clearly which fields were and were not touched.

Check if you're safe: Password Strength Checker

Real incident: Rakuten Securities (Japan) – real customer data copied into a test system leaked for up to 4.47 million accounts (Nov 2026)

1. What happened

In this lesson you learnt how to protect data in the cloud: lock storage, encrypt it and guard the keys. But protection only works if you know every place a copy of the data lives. This real case shows real customer data sitting in a test system, where nobody expects it.

  • Rakuten Securities is a large online stock trading company in Japan.
  • On 16 November 2026 it detected possible unauthorized access to part of its systems. It blocked that access point and fixed it.
  • Its check found that on 11 November 2026 some data kept in a test environment may have been taken out. It told the public on 17 November.
  • For up to about 4.47 million accounts, the data may include customer codes, login IDs, names, dates of birth, addresses, phone numbers, email addresses, employers, withdrawal bank accounts, self-declared income and financial assets, and holdings. For up to about 11.25 million accounts, it is customer codes and login IDs. Closed accounts are included.
  • The company said login passwords and trading PINs were not leaked, and no unauthorized trades linked to this were found.
  • Rakuten Securities told ITmedia NEWS that, for a system upgrade, it copied some real customer data into a test server for a period, and this data was not masked. It said test servers normally hold only dummy data.

2. How the hack happened (public reporting only – high-level)

  1. A system upgrade needed testing, and the team decided some checks needed real production data.
  2. Part of the real customer data was copied into a test server, without masking.
  3. Test systems usually get less protection and less watching than production.
  4. An attacker got into the test environment. The company told ITmedia a weakness was exploited; the exact entry method is still under investigation.
  5. On 11 November, the attacker may have taken the customer data stored there.
  6. The access was detected on 16 November and cut off. Customers were then warned to watch for fake emails, SMS and calls.

3. How to stop it / defend (this lesson: protecting data)

Why: a copy of the data needs the same protection as the original. Attackers look for the weakest copy, and that is often test or backup.

What you can do:

  1. Use fake or masked data in test. Replace names, emails, phones, bank and income details before data leaves production (Example 2).
  2. If real data is truly needed, copy only the columns and rows you need, give it an end date, and delete it the day testing ends.
  3. Protect test like production while it holds real data: same patching, MFA, network limits, encryption and logging.
  4. Keep a data map: a list of every place sensitive data is stored, including test, backup and reports.
  5. Check test databases regularly for real-looking data (Example 1).
  6. Watch for big data reads or exports from non-production systems and alert on them.

Example 1: check that a test database holds no real customer emails.

  1. Connect to your own test database with a read-only account.
  2. Run SELECT COUNT(*) FROM customers WHERE email NOT LIKE '%@example.test';
  3. Output (example): 0
  4. What it means: every email is a fake test address. Any number above 0 means real customer emails are sitting in test.

Example 2: mask a copy before it goes to test.

  1. Do this on the copy while it is still inside the protected production zone, never in the test system.
  2. Run UPDATE customers SET full_name = CONCAT('Test User ', id), email = CONCAT('user', id, '@example.test'), phone = NULL, bank_account = NULL, income = NULL;
  3. Output (example): Query OK, 25000 rows affected
  4. What it means: the rows keep their shape for testing, but names, contacts and money details are fake or empty. Now the copy can move to test.

If you are a customer of a breached service: turn on passkey login if offered, use the app's option to lock trading or withdrawals if you are worried, and do not click links in messages that claim to be from the company. Rakuten Securities says its emails do not contain URLs.

4. How to take care so it won't happen again (checklist)

  • [ ] Test and development use fake or masked data by default.
  • [ ] Any real-data copy to test needs approval, has an end date and is deleted on time.
  • [ ] Masking runs inside production before data moves out.
  • [ ] Test systems holding real data get production-level security.
  • [ ] We keep a data map of every copy of sensitive data.
  • [ ] We scan test databases for real data every month.
  • [ ] Big reads or exports from non-production raise an alert.

Source: Rakuten Securities press release on the possible leak of customer information, 17 November 2026; The Japan Times, "Rakuten Securities account information compromised in major data breach" (Ariana King), 18 November 2026; ITmedia NEWS report on why real customer data was in the test environment, 18 November 2026.

Ravindra Bagale's Tip

Ask one question before any copy of data: where will this copy live, and who guards it? A test server with real customer data is a production server with weaker locks. Mask first, copy second, and delete it the day testing ends.

Check if you're safe: Website Security Checklist

Real incident: Microsoft Azure API Management – a flaw in old Classic tiers was used to steal stored API secrets and tokens (Nov 2026)

1. What happened

In this lesson you learnt to keep secrets in a safe vault, not inside app settings. Why does this case matter? Because here many companies kept their secret keys inside a cloud service, and a flaw in that service let an attacker read them.

  • Azure API Management (APIM) is a Microsoft cloud service. Companies use it as a "front door" to publish, protect and manage their APIs.
  • To talk to the apps behind it, APIM often stores secrets: named values, client secrets for login providers, subscription keys and management tokens.
  • Microsoft told customers that it found a security flaw in the older APIM Classic tiers on 18 November 2026 and closed it on 19 November. The newer v2 tiers were not affected.
  • Microsoft said an unauthorized party could use the flaw to reach admin functions and read secrets stored in APIM, on Classic instances not set up as per its recommended security practices.
  • Norway's National Security Authority (NSM) said an unknown actor actively went after access tokens, secrets and named values. Energy companies Equinor and Skagerak Energi were among those hit. Both said they found no sign that data was stolen and that production went on normally.
  • Microsoft warned that its fix does not cancel secrets that were already taken. NSM told every APIM user to treat these secrets as stolen and rotate all of them. No one has named the attacker yet.

2. How the hack happened (public reporting only – high-level)

  1. Companies put API keys and secrets directly inside APIM, so APIM could call their back-end systems.
  2. Many were on the older Classic tier, and some did not follow Microsoft's security setup, for example keeping secrets in APIM instead of in Azure Key Vault.
  3. A flaw in the Classic tier's management side let an outsider do admin work without proper permission.
  4. The attacker used this to read the stored secrets, keys and tokens.
  5. Stolen secrets can open the apps and systems behind APIM. Equinor spotted the unusual activity and shared it with NSM, and Microsoft closed the path on 19 November.

3. How to stop it / defend (this lesson: protecting secrets)

Why: a secret stored in many places can leak from any one of them. A secret in one guarded vault is easier to protect, watch and change.

What a cloud team can do:

  1. Keep secrets in a vault. On Azure use Key Vault; on AWS use Secrets Manager or Parameter Store. Let services read the secret from the vault.
  2. Rotate at once after any alert. A vendor fix closes the door, but stolen keys still work until you change them.
  3. Give each key only the access it needs, so one stolen key cannot open everything.
  4. Move off old tiers and follow the vendor's security baseline. Check that your service got the security update.
  5. Watch the logs of the systems behind your API gateway, and of your vault, for logins at odd times or from odd places.
  6. Keep a list of which secrets live in which service. Then you know exactly what to rotate on a bad day.

Example: a simple "cloud vendor says secrets may be exposed" drill.

  1. Rule: a vendor advisory says secrets in one of your services may have been read.
  2. Action: from your secrets list, rotate every key and token stored there, and update the apps that use them.
  3. Check: read the back-end and vault logs since the date in the advisory, for use of the old keys.
  4. What it means: old stolen keys stop working, and you learn whether anyone used them.

4. How to take care so it won't happen again (checklist)

  • [ ] All secrets live in a vault, not as plain values inside app or gateway settings.
  • [ ] We keep a list of every secret and where it is used.
  • [ ] We can rotate any key quickly, and we practise it.
  • [ ] Each key has only the access it needs.
  • [ ] We are on supported service tiers and follow the vendor's security baseline.
  • [ ] Someone reads vendor security advisories and acts the same day.

Source: BleepingComputer, "Microsoft Azure flaw exploited to steal customers' API credentials", 23 November 2026 (quoting Microsoft's customer advisory MZK9-GH0); Norwegian National Security Authority (NSM), advisory on Azure API Management, 20 November 2026, updated 23 November 2026; The Record by Recorded Future News, "Norway says hackers exploited Microsoft security flaw to attack energy firms Equinor, Skagerak Energi", 23 November 2026.

Ravindra Bagale's Tip

A cloud service fix closes the door, but it does not take back the keys a thief already copied. Keep secrets in one vault, keep a list of where they are used, and practise rotating them, so a bad-news advisory becomes a one-hour job, not a crisis.

Check if you're safe: Password Strength Checker