Skip to Content
Cloud Engineering Academy
17. Daily-Work Playbooks & Career

Playbook: S3 bucket accidentally public

Contain an exposed S3 bucket in minutes with Block Public Access, work out who changed it and who read from it using CloudTrail and access logs, preserve evidence, and hand a factual timeline to the incident and data protection teams.

intermediate⏱ 1 h 15 min🟢 FreeSCS-C03SOA-C03DOP-C02SAA-C03

Assumes: .NET 10 LTS · AWS SDK for .NET v4 (AWSSDK.S3) · AWS CLI v2 · Amazon S3 · Region us-east-1. Verified against official sources on 2026-11-18.

Learning objectives

By the end of this playbook you can:

  • Contain a publicly exposed bucket in the first minutes without destroying evidence.
  • Explain the four Block Public Access settings and why account-level and bucket-level settings both matter.
  • Find who made the bucket public and when from CloudTrail management events.
  • Find who read from it using CloudTrail data events, S3 server access logs or CloudFront logs, and state honestly what you cannot know when those logs were off.
  • Hand the incident and data protection teams a factual timeline, without declaring a breach yourself.
  • Run a C# scanner that reports the public-access status of every bucket in an account.

Prerequisites

Why this matters in banking

A developer creates a bucket harbourline-statements-export to share a month of customer statement PDFs with a printing partner. To make the partner's download work quickly, they add a bucket policy with "Principal": "*". The policy is meant to last an afternoon. Nobody removes it. Three weeks later an external security researcher emails the bank: "your statements bucket is listable from the internet".

Two things must happen at once. First, stop the exposure now: every minute the bucket stays open, more data can be read. Second, do not destroy the evidence the bank needs to answer "who accessed what, and when". A hasty "delete the bucket" or "delete the logs" turns a containable event into an unprovable one. The decision on whether this is a reportable personal data breach belongs to the data protection officer and legal team, not to the engineer. Your job is containment, evidence and a precise timeline. Under UK GDPR, a notifiable breach generally must be reported to the regulator within 72 hours of the organisation becoming aware, so the clock matters; the data protection team confirms how it applies.

The idea in plain language

A bucket is public when something allows anyone (the whole internet, no sign-in) to read or list it. There are four ways that can happen:

  1. A bucket policy with a wildcard principal.
  2. An ACL (access control list) granting access to "everyone" (AllUsers) or "any authenticated AWS user".
  3. An access point policy with a wildcard.
  4. A CloudFront or website configuration exposing it on purpose with the wrong scope.

AWS gives you a single master switch, Block Public Access, with four settings that you can apply per bucket or for a whole account:

SettingWhat it stops
BlockPublicAclsNew public ACLs and uploads that include them
IgnorePublicAclsExisting public ACLs: S3 ignores them
BlockPublicPolicyNew bucket policies that grant public access
RestrictPublicBucketsExisting public policies: only AWS services and authorised users in the account can use the bucket

RestrictPublicBuckets is the containment tool, because it neutralises a public policy that is already attached. Turning on all four at the account level is the strongest single control, and it overrides bucket-level settings for the public-access decision.

Analogy: The bucket policy is a notice on the door saying "anyone may come in". Block Public Access is the building manager's master lock: with it on, the notice is ignored. You engage the master lock first, then investigate who wrote the notice and who walked in while it was up.

What problem the AWS services solve

  • S3 Block Public Access gives a fast, reversible containment switch that does not alter the policy or the data, which keeps the evidence intact.
  • CloudTrail management events record PutBucketPolicy, PutBucketAcl and DeleteBucketPublicAccessBlock: who changed access, when, from which IP and with which role.
  • CloudTrail data events (opt-in, and charged per event) record object-level GetObject and ListObjects-style calls with the caller identity and IP.
  • S3 server access logging records requests to a bucket to another bucket, on a best-effort basis (a few hours of delay and occasional gaps are possible).
  • IAM Access Analyzer raises findings for resources shared outside your zone of trust, including public S3 buckets.
  • AWS Config rules such as s3-bucket-public-read-prohibited flag buckets that allow public read.
  • Amazon Macie (see the Macie lesson) tells you what kind of data (names, account numbers) is in the bucket, which feeds the impact assessment.

What AWS cannot do: it cannot tell you what was read if object-level logging was off. In that case you must say "we cannot determine", which is a finding in itself and a reason to enable data events for sensitive buckets by policy.

Current defaults (⚠ VERIFY before quoting)

New buckets are created with Block Public Access on and ACLs disabled (Object Ownership "bucket owner enforced") by default since April 2023. An exposed bucket in a modern account therefore usually means somebody turned protection off or the bucket is old. Both are worth proving from CloudTrail.

Microsoft / Azure comparison

You know (Microsoft/Azure)AWS equivalentWhat's different
Storage account "Allow Blob public access" offS3 Block Public Access (account or bucket)Four separate settings, and an account-level master that applies to all buckets
Container access level "Blob" or "Container"Bucket policy or ACL granting *Public access is expressed through policy, not a container level
Azure Policy deny rule for public storageOrganizations policy or Config rule plus SCPPreventive controls come from several places; use SCPs to prevent changing the block
Azure Activity Log for Microsoft.Storage changesCloudTrail management eventsSame idea. Object-level reads need data events on AWS
Storage Analytics logsS3 server access logs and CloudTrail data eventsTwo sources with different guarantees and costs
Defender for Storage alertsGuardDuty S3 protection, MacieSeparate services you enable
SAS token leakedPre-signed URL leakedA pre-signed URL is a different exposure: bucket not public, but a URL works until it expires

Architecture

The incident flow

Security-boundary view

Step-by-step implementation

Minutes 0 to 5: confirm and open the incident

  1. Record who reported it, the bucket name and the time you were told (UTC). This starts the awareness clock the data protection team will ask about.
  2. Confirm exposure without downloading data: run get-bucket-policy-status (does the policy make it public?) and check the ACL. An anonymous HEAD request to a known object key, using a request with no credentials, confirms it from the outside. Do not download customer files to prove the point.
  3. Open your incident record using your bank's process (Incident Manager is closed to new customers, see the module overview; use your own incident tooling) and notify the security lead.

Minutes 5 to 10: contain

Turn on all four Block Public Access settings on the bucket, then on the account if it is not already on. This does not delete the policy or change the objects, so it preserves evidence. Re-run the anonymous check: it should now fail. Note the exact time of containment.

Check the legitimate users: if the partner's download relied on the public policy, tell the business owner it will stop working, and plan a proper replacement (pre-signed URLs, a cross-account role, or AWS Transfer Family).

Minutes 10 to 25: preserve evidence

Before changing anything else, save: the bucket policy JSON, the ACL, the public access block configuration (before and after), the bucket's logging and versioning configuration, and a listing of object keys (names, sizes and dates, not contents). Store them in the incident record. Do not delete the bucket, empty it, shorten log retention or "clean up" objects. If Object Lock or a legal hold is appropriate for the logs, ask the security team.

Minutes 25 to 50: who changed it, and who read it

Who changed it (management events, retained 90 days in Event history, longer in a trail):

  • PutBucketPolicy, PutBucketAcl, DeleteBucketPolicy, PutBucketPublicAccessBlock, DeleteBucketPublicAccessBlock, PutAccountPublicAccessBlock or DeletePublicAccessBlock (the account-level call is on the S3 Control endpoint).
  • Capture eventTime, userIdentity.arn (the role, and the session name if present), sourceIPAddress and userAgent.

Who read it:

  1. CloudTrail data events for the bucket, if enabled: GetObject, with userIdentity of AWSAccount and ANONYMOUS_PRINCIPAL style entries for unauthenticated access (⚠ VERIFY the exact anonymous identity wording in your records).
  2. S3 server access logs, if enabled: requester - indicates unauthenticated requests. Filter for requests from outside your known IPs during the exposure window.
  3. CloudFront logs, if the bucket sat behind a distribution.
  4. If none were enabled: record plainly that access cannot be determined and that all objects must be assumed readable. That statement drives the impact assessment.

The exposure window runs from the change that made the bucket public (from CloudTrail) to the containment time.

Minutes 50 to 75: impact, handover and prevention

  1. Classify what was in the bucket. Ask the bucket owner and, if available, run a Macie discovery job on it. Distinguish personal data, financial account data, cardholder data (a PCI DSS matter) and non-sensitive files.
  2. Write the timeline (all UTC): exposure begins, discovered, contained, evidence of external reads, assessments.
  3. Hand over to the incident manager and data protection officer with the facts. They decide on regulatory and customer notification. You do not.
  4. Prevent recurrence: account-level Block Public Access, an SCP to stop principals changing it, a Config rule and alert for public buckets, data events on sensitive buckets, and a review of how the engineer was allowed to attach a wildcard policy in the first place.

AWS Console instructions

  1. Console → S3 → Buckets → (bucket) → Permissions: check Block public access (bucket settings), the Bucket policy and the Access control list (ACL). A bucket flagged Publicly accessible shows a banner. Choose Edit on Block public access and tick all four boxes.
  2. Console → S3 → Block Public Access settings for this account (left menu): turn on all four settings for the account.
  3. Console → CloudTrail → Event history: filter Event source s3.amazonaws.com and Event name PutBucketPolicy (then PutBucketAcl) to see who changed access. For long retention use your trail's S3 bucket with Athena.
  4. Console → S3 → (bucket) → Properties: look at Server access logging and, further down, Event notifications and whether CloudTrail data events cover the bucket (CloudTrail console → Trails → Data events).
  5. Console → IAM → Access Analyzer → Findings: filter for the bucket resource type to see the public-access finding.

AWS CLI

# 1. Is the bucket public according to its policy?
aws s3api get-bucket-policy-status --bucket harbourline-statements-export \
  --query 'PolicyStatus.IsPublic' --profile learn-sandbox

# 2. EVIDENCE FIRST: save the policy, ACL and block settings before changing anything.
mkdir -p evidence && cd evidence
aws s3api get-bucket-policy --bucket harbourline-statements-export --profile learn-sandbox > policy-before.json
aws s3api get-bucket-acl    --bucket harbourline-statements-export --profile learn-sandbox > acl-before.json
aws s3api get-public-access-block --bucket harbourline-statements-export --profile learn-sandbox > bpa-before.json
aws s3api get-bucket-logging --bucket harbourline-statements-export --profile learn-sandbox > logging.json

# 3. CONTAIN: turn on all four Block Public Access settings on the bucket.
aws s3api put-public-access-block --bucket harbourline-statements-export \
  --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true \
  --profile learn-sandbox

# 4. CONTAIN: the same at account level (the account ID is fictional).
aws s3control put-public-access-block --account-id 111122223333 \
  --public-access-block-configuration BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true \
  --profile learn-sandbox

# 5. Who changed access? Look up the management events for this bucket's policy changes.
aws cloudtrail lookup-events --lookup-attributes AttributeKey=EventName,AttributeValue=PutBucketPolicy \
  --start-time 2026-10-25T00:00:00Z --end-time 2026-11-18T23:59:59Z \
  --query 'Events[].[EventTime,Username,EventName]' --output table --profile learn-sandbox

# 6. Keep a key listing as evidence of what was in the bucket (names and sizes only).
aws s3api list-objects-v2 --bucket harbourline-statements-export \
  --query 'Contents[].[Key,Size,LastModified]' --output text --profile learn-sandbox > object-listing.txt

An Athena query over a CloudTrail table (named cloudtrail_logs here; yours may differ) for who changed bucket access and who read objects, if data events were on:

-- Who changed access to the bucket?
SELECT eventtime, eventname, useridentity.arn AS actor, sourceipaddress, useragent
FROM cloudtrail_logs
WHERE eventsource = 's3.amazonaws.com'
  AND eventname IN ('PutBucketPolicy','PutBucketAcl','DeleteBucketPublicAccessBlock','PutBucketPublicAccessBlock')
  AND json_extract_scalar(requestparameters, '$.bucketName') = 'harbourline-statements-export'
ORDER BY eventtime;

-- Who read objects during the exposure window (requires data events)?
SELECT eventtime, useridentity.type AS identity_type, useridentity.arn AS actor, sourceipaddress, count(*) AS reads
FROM cloudtrail_logs
WHERE eventsource = 's3.amazonaws.com'
  AND eventname = 'GetObject'
  AND json_extract_scalar(requestparameters, '$.bucketName') = 'harbourline-statements-export'
  AND eventtime BETWEEN '2026-10-28T00:00:00Z' AND '2026-11-18T12:00:00Z'
GROUP BY eventtime, useridentity.type, useridentity.arn, sourceipaddress
ORDER BY eventtime;

Infrastructure as Code

Preventive controls: a bucket that cannot be made public, encrypted at rest, with TLS enforced and server access logs going to a separate bucket, plus a Config rule that flags public buckets. The account-level Block Public Access setting is set separately (Terraform resource below, or the CLI above; ⚠ VERIFY whether your CloudFormation version has a native resource).

using Amazon.CDK;
using Amazon.CDK.AWS.Config;
using Amazon.CDK.AWS.S3;
using Constructs;

public class StatementsBucketStack : Stack
{
    public StatementsBucketStack(Construct scope, string id, IStackProps props) : base(scope, id, props)
    {
        var logs = new Bucket(this, "AccessLogs", new BucketProps
        {
            BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,
            Encryption = BucketEncryption.S3_MANAGED,
            EnforceSSL = true,
            RemovalPolicy = RemovalPolicy.RETAIN
        });

        var statements = new Bucket(this, "Statements", new BucketProps
        {
            BucketName = null,                                // let CloudFormation name it
            BlockPublicAccess = BlockPublicAccess.BLOCK_ALL,   // all four settings
            Encryption = BucketEncryption.KMS_MANAGED,
            EnforceSSL = true,
            Versioned = true,
            ServerAccessLogsBucket = logs,
            ServerAccessLogsPrefix = "statements/",
            RemovalPolicy = RemovalPolicy.RETAIN
        });

        // Managed Config rule that flags buckets allowing public read.
        new ManagedRule(this, "NoPublicRead", new ManagedRuleProps
        {
            Identifier = ManagedRuleIdentifiers.S3_BUCKET_PUBLIC_READ_PROHIBITED,
            Description = "Flags buckets that allow public read. See playbook s3-bucket-accidentally-public."
        });

        Amazon.CDK.Tags.Of(this).Add("Project", "cea-lab");
        Amazon.CDK.Tags.Of(this).Add("Lab", "m17-playbook-public-bucket");
    }
}

An Organizations service control policy (SCP) that stops anyone but a break-glass role from weakening the setting, as a sketch (test in a sandbox organisation first). Deleting a bucket-level block is authorised by the same s3:PutBucketPublicAccessBlock action (⚠ VERIFY against the S3 actions reference):

{
  "Version": "2012-10-17",
  "Statement": [{
    "Sid": "DenyChangingPublicAccessBlock",
    "Effect": "Deny",
    "Action": [
      "s3:PutAccountPublicAccessBlock",
      "s3:PutBucketPublicAccessBlock"
    ],
    "Resource": "*",
    "Condition": {
      "StringNotLike": { "aws:PrincipalArn": "arn:aws:iam::*:role/hl-security-breakglass" }
    }
  }]
}

Complete code

A scanner for public-access status across an account

This tool lists every bucket, then reports its Block Public Access settings and whether its policy makes it public. It uses AWSSDK.S3 v4 and the default credential chain (use the learn-sandbox profile through AWS_PROFILE). It is read-only.

BucketExposureScan/Program.cs
using Amazon.S3;
using Amazon.S3.Model;

using var s3 = new AmazonS3Client();
var buckets = (await s3.ListBucketsAsync()).Buckets ?? new List<S3Bucket>();
Console.WriteLine($"{"bucket",-45} {"BPA all four",-13} {"policy public",-14} verdict");

var exposed = 0;
foreach (var bucket in buckets)
{
    var name = bucket.BucketName;
    try
    {
        var bpa = await GetBlockSettingsAsync(s3, name);
        var policyPublic = await IsPolicyPublicAsync(s3, name);
        var verdict = Classify(bpa.AllFour, policyPublic);
        if (verdict != "ok") exposed++;
        Console.WriteLine($"{name,-45} {bpa.AllFour,-13} {(policyPublic ? "yes" : "no"),-14} {verdict}");
    }
    catch (AmazonS3Exception ex)
    {
        // For example a bucket in another Region or one we cannot read: report, never ignore silently.
        Console.WriteLine($"{name,-45} {"?",-13} {"?",-14} could not check ({ex.ErrorCode})");
    }
}

Console.WriteLine($"{buckets.Count} buckets checked, {exposed} need attention.");
return exposed == 0 ? 0 : 2;

static async Task<(bool AllFour, string Detail)> GetBlockSettingsAsync(IAmazonS3 s3, string bucket)
{
    try
    {
        var response = await s3.GetPublicAccessBlockAsync(new GetPublicAccessBlockRequest { BucketName = bucket });
        var c = response.PublicAccessBlockConfiguration;
        var all = c.BlockPublicAcls == true && c.IgnorePublicAcls == true
               && c.BlockPublicPolicy == true && c.RestrictPublicBuckets == true;
        return (all, $"acls={c.BlockPublicAcls} ignore={c.IgnorePublicAcls} policy={c.BlockPublicPolicy} restrict={c.RestrictPublicBuckets}");
    }
    catch (AmazonS3Exception ex) when (ex.ErrorCode == "NoSuchPublicAccessBlockConfiguration")
    {
        return (false, "no bucket-level configuration");
    }
}

static async Task<bool> IsPolicyPublicAsync(IAmazonS3 s3, string bucket)
{
    try
    {
        var status = await s3.GetBucketPolicyStatusAsync(new GetBucketPolicyStatusRequest { BucketName = bucket });
        return status.PolicyStatus?.IsPublic == true;
    }
    catch (AmazonS3Exception ex) when (ex.ErrorCode == "NoSuchBucketPolicy")
    {
        return false;
    }
}

static string Classify(bool allFour, bool policyPublic) => (allFour, policyPublic) switch
{
    (_, true) when !allFour => "EXPOSED: public policy and protection not fully on",
    (_, true) => "policy is public but blocked by BPA: remove the policy",
    (false, false) => "weak: Block Public Access not fully on",
    _ => "ok"
};

Create a console project targeting net10.0 and add the package with dotnet add package AWSSDK.S3 (the current 4.x version). Run it with AWS_PROFILE=learn-sandbox dotnet run.

Code explained line by line

  1. new AmazonS3Client() uses the default credential chain, so no keys appear in code. With AWS_PROFILE=learn-sandbox it uses your SSO profile.
  2. ListBucketsAsync returns every bucket in the account. In SDK v4 collections can be null, so the code guards with ?? new List<S3Bucket>().
  3. GetPublicAccessBlockAsync reads the bucket-level settings. A bucket with none throws NoSuchPublicAccessBlockConfiguration, which the code treats as "not protected at bucket level" (the account-level setting may still protect it).
  4. Comparing each flag with == true works whether the SDK property is bool or bool?, which is how v4 models optional values.
  5. GetBucketPolicyStatusAsync asks S3 to evaluate whether the policy makes the bucket public. A missing policy raises NoSuchBucketPolicy, which means "not public by policy".
  6. The catch (AmazonS3Exception) in the loop prints a ? row instead of skipping. A scanner that hides errors gives false comfort.
  7. Classify puts the dangerous combination first: public policy without full protection. A public policy that Block Public Access neutralises is still a finding, because switching the block off would expose it at once.
  8. The exit code is 2 when anything needs attention, so a pipeline can fail on it.

Security considerations

⚠ Learning shortcut — not for production

The scanner reads bucket settings but not the account-level Block Public Access, and it does not look at ACLs, access points or website hosting. A real posture check uses Access Analyzer, Config and Security Hub across all accounts and Regions. The scanner is for learning and for an incident-time first look. Also, never confirm exposure by downloading real customer files; check metadata only.

  • Containment before investigation, but evidence before deletion. Never delete a bucket, policy history or logs during the incident.
  • Least privilege for the investigators. Give responders read access to logs and the ability to set Block Public Access, not blanket admin.
  • Protect the log bucket. Server access logs and CloudTrail logs are evidence. Keep them in a separate, locked-down account or bucket, with Object Lock where policy requires.
  • Do not paste object names or customer identifiers into chat. File names themselves can be personal data.
  • Pre-signed URLs are not "public" but behave like bearer links. Keep expiries short and do not log full URLs.
  • KMS encryption does not make a public bucket safe. With a public policy, S3 decrypts SSE-S3 objects for anonymous readers. For SSE-KMS objects, an anonymous reader needs KMS permission, which usually fails: a useful extra barrier, not a control to rely on.
  • Notification decisions are not yours. State facts and timestamps. The data protection officer decides on notifying the regulator or customers. Nothing here is legal advice or a compliance claim.

Banking use case

For Harbourline, three controls turn this incident into a non-event. The account has Block Public Access on at account level and an SCP that stops everyone except a break-glass role from weakening it, so the wildcard policy in the story would have been rejected at the time it was written. Sensitive buckets (statements, KYC documents) have CloudTrail data events and server access logs, so "who read it?" is answerable. A Config rule and an Access Analyzer finding raise an alert within minutes, which keeps the exposure window short. The incident record for the story above shows the timeline the responders produced: policy added 2026-10-28 14:12 UTC by a named role, reported 2026-11-18 09:40 UTC, contained 09:48 UTC, 3 external IPs in the logs for the window, 2 of them the partner's known addresses, and the unexplained one passed to the security team.

Common mistakes

  • Deleting the bucket or the policy first. It destroys evidence and may remove data the bank must retain.
  • Only fixing the one bucket. Check the whole account and turn on the account-level setting.
  • Assuming "no reads" because there are no logs. Absence of logs is not absence of access.
  • Downloading customer files to confirm exposure. It creates another copy of personal data.
  • Declaring "no breach" or "breach" as an engineer. That is a data protection decision.
  • Fixing the symptom only. Without an SCP or a Config alert the same mistake repeats next quarter.
  • Forgetting other exposure routes: an ACL, an access point, a CloudFront distribution or leaked pre-signed URLs.

Troubleshooting

SymptomLikely causeFix
put-public-access-block returns AccessDeniedMissing s3:PutBucketPublicAccessBlock, or an SCP blocks itUse a role with the permission, or the break-glass role the SCP excludes
Bucket still reachable after setting the blockExposure through CloudFront, a pre-signed URL or a different bucketCheck distributions and access points, and rotate any signing credentials involved
Partner download broke after containmentIt relied on the public policyReplace with pre-signed URLs, a role the partner assumes, or Transfer Family
NoSuchPublicAccessBlockConfigurationNo bucket-level settings existCreate the configuration with put-public-access-block
No GetObject records in CloudTrailData events were not enabledState that reads cannot be determined, check server access logs and CloudFront logs
Server access logs have gapsBest-effort deliveryTreat as incomplete, and note this in the findings
Event history lacks the changeOlder than 90 days, or in another RegionSearch the trail's S3 bucket with Athena, check the right Region
Access Analyzer finding stays active after the fixFinding not re-evaluated yetRescan or wait, then verify the status turns resolved

Cost and cleanup

Cost label: free for reading the lesson and running the scanner. The optional sandbox reproduction creates a tiny bucket (pennies at most) and, if you enable CloudTrail data events, charges per event (⚠ VERIFY current price), so use a sandbox account, do not turn on data events beyond a short test, and tear down afterwards. Never make a bucket public in an account that holds real data. For the exercise, use a bucket containing only a dummy text file.

# Empty and delete the sandbox bucket (versioned buckets also need versions removed)
aws s3 rm s3://<sandbox-bucket> --recursive --profile learn-sandbox
aws s3api delete-bucket --bucket <sandbox-bucket> --profile learn-sandbox

# Remove the Config rule if you created it
aws configservice delete-config-rule --config-rule-name hl-s3-no-public-read --profile learn-sandbox

# Confirm nothing tagged for this lesson remains
aws resourcegroupstaggingapi get-resources --tag-filters Key=Lab,Values=m17-playbook-public-bucket --profile learn-sandbox

Exercises

  • 🟢 Guided: In a sandbox account, create a bucket with one dummy file, temporarily turn the bucket-level Block Public Access off and attach a public-read bucket policy. Run the scanner and read the verdict. Turn Block Public Access on and run it again.
  • 🟡 Challenge: Extend the scanner to also fetch the account-level block settings with AmazonS3ControlClient and report buckets that are weak at the bucket level but protected by the account. Add a column for it.
  • 🔴 Live problem: "A researcher says harbourline-kyc-uploads is listable. Block Public Access is already on for the bucket. Nobody changed the policy this month." List where else the exposure could come from and which evidence you collect first.

Assignment

Write an S3 exposure runbook for your portfolio: containment commands in order, an evidence checklist, the two Athena queries adapted to your account, a timeline template and the preventive controls from this lesson. Commit as runbooks/s3-public-bucket.md with fictional names and no real data.

Solutions

Knowledge check

Interview questions

  • A public S3 bucket has been reported. What are your first three actions? Confirm exposure without downloading data, contain with Block Public Access, and preserve the policy, ACL and logs as evidence.
  • How do you find out who accessed the objects? CloudTrail data events, S3 server access logs and CloudFront logs, filtered to the exposure window. If none were enabled, say so.
  • How do you stop it happening again? Account-level Block Public Access, an SCP preventing weakening it, Config and Access Analyzer alerts, and data events on sensitive buckets.
  • What is the difference between a public bucket and a leaked pre-signed URL? The first is open to everyone through bucket configuration, the second is a bearer link to specific objects that works until it expires.
  • Is encrypting the bucket with KMS enough? No. It adds a barrier for SSE-KMS objects, but a public policy is still a control failure.

Certification practice

Completion checklist

  • I can name the four Block Public Access settings and which one handles an existing policy
  • I can list the evidence to save before changing anything
  • I know which CloudTrail events show who changed access and which show who read objects
  • I ran the scanner or the CLI checks in a sandbox
  • I can explain why the notification decision is not an engineer's
  • I ran the cleanup steps and confirmed nothing tagged m17-playbook-public-bucket remains

Key takeaways

  • Contain first with Block Public Access, and keep every piece of evidence.
  • CloudTrail management events say who changed access, data events and access logs say who read.
  • No logs means "unknown", not "nobody".
  • Engineers give facts and timelines, the data protection team decides on notification.
  • Prevent with account-level blocking, an SCP, Config and data events on sensitive buckets.

Further reading

Independent learning resource — not affiliated with, endorsed or sponsored by Amazon Web Services. AWS and related marks are trademarks of Amazon.com, Inc. or its affiliates. All banking data in examples is fictional. Sample architectures are for learning and are not automatically compliant with GDPR, PCI DSS or any banking regulation.

On this page