SECURITY ENGINEERING · PART 10 · CLOUD SECURITY · DATA · 141 OF 229

S3 Bucket Security: Stop Public Bucket Leaks

The public storage bucket is the most famous cloud mistake, and it still happens. This episode covers object storage security: why buckets become public, the layered controls (account-wide block-public-access, bucket policies, ACLs, IAM), encryption and versioning, signed URLs for controlled sharing, detecting exposure, and the defaults that make a leak almost impossible.

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 9
  9. 10
  10. 11
  11. 12
  12. 13
  13. 14
  14. 15
  15. 16
  16. 17
  17. 18
  18. 19
  19. 20
  20. 21
  21. 22
  22. 23
  23. 24
  24. 25
  25. 26
  26. 27
  27. 28
  28. 29
  29. 30
  30. 31
  31. 32
  32. 33
  33. 34
  34. 35
  35. 36
  36. 37
  37. 38
  38. 39
  39. 40
  40. 41
  41. 42
  42. 43
  43. 44
  44. 45
  45. 46
  46. 47
  47. 48
  48. 49
  49. 50
  50. 51
  51. 52
  52. 53
  53. 54
  54. 55
  55. 56
  56. 57
  57. 58
  58. 59
  59. 60
  60. 61
  61. 62
  62. 63
  63. 64
  64. 106
  65. 107
  66. 108
  67. 109
  68. 110
  69. 111
  70. 112
  71. 113
  72. 114
  73. 115
  74. 116
  75. 117
  76. 118
  77. 119
  78. 120
  79. 121
  80. 122
  81. 123
  82. 124
  83. 125
  84. 126
  85. 127
  86. 128
  87. 129
  88. 130
  89. 131
  90. 132
  91. 133
  92. 134
  93. 135
  94. 136
  95. 137
  96. 138
  97. 139
  98. 140
  99. 141
  100. 142
  101. 143
  102. 144
1 / 10

Press play to hear the narration, or step through at your own pace.

Key takeaways

  • Block-public-access everywhere
  • least-privilege policies, no wildcards
  • encrypt and version
  • share with signed URLs

Notes

Why buckets leak

Why do buckets leak? Because several settings can each make a bucket public, and that is the trap. An access control list set to public-read. A bucket policy allowing a wildcard principal, meaning everyone. A careless make-public click to share a file. Config copied from a tutorial. The real problem is the confusion: multiple overlapping controls, and getting any one wrong exposes the data. That is why the providers added a single master switch, which we come to next.

Paths to public
  • a bucket ACL set to public- read
  • a bucket policy allowing "Principal": "*"
  • a careless "make public" click for convenience
  • copied config from a tutorial
  • the confusion: several controls, any one can expose it

Block public access

The most important control is block public access, an account-wide master switch. When on, it overrides any bucket policy or ACL that would make data public, so even a mistaken public setting has no effect. Turn it on for the entire account, and exempt a specific bucket only through a deliberate, reviewed process. This one setting prevents the classic public-bucket leak outright, so it should be a non-negotiable guardrail, and every cloud has an equivalent. Enable it everywhere and most of this risk disappears.

The single best control
  • account-wide "block public access" setting
  • overrides any bucket policy or ACL that would make data public
  • turn it ON for the whole account; exempt only with review
  • this one setting prevents the classic leak
  • GCP/Azure have equivalents

Layered access

Beneath the master switch, access is controlled by policies. IAM policies govern what identities in your account may do. Bucket policies handle cross-account and fine-grained access. The same rules as cloud IAM apply: avoid wildcard principals, grant least privilege, scope to specific identities and actions. Modern practice is to disable the older ACL mechanism and use policies only. Storage is private by default, like the network, and you open access deliberately.

Who can access
  • IAM policies: what identities in your account can do
  • bucket (resource) policies: cross-account and fine- grained rules
  • avoid wildcards; grant least privilege
  • disable ACLs where you can (prefer policies)
  • private by default, like the network

Encrypt and version

Two protections for the data itself. Encryption at rest is on by default now, and using a managed key gives you control and an audit trail, as the KMS episode covers. Versioning keeps old copies, so an accidental or malicious delete or overwrite can be recovered, which also helps against ransomware. Object lock can make objects undeletable for a period. Add lifecycle rules to expire old data and access logging to see who read what. These turn a bucket into a well-managed store.

Data protections
  • encryption at rest: on now, use KMS keys for control
  • versioning: keep old versions so deletes are recoverable
  • object lock: prevent deletion (ransomware, tampering)
  • lifecycle rules to expire old data
  • access logging on

Share without public

People make a bucket public to share a file, but that is the wrong tool. To share a single object, use a signed URL: a time-limited link to just that one object that expires on its own. The bucket stays private. For public websites or downloads, serve through a content delivery network with controlled access to the origin bucket, so the bucket itself is never directly public. Public is almost never the right answer; there is nearly always a scoped, temporary alternative.

Controlled sharing
  • share one object? do NOT make the bucket public
  • signed (pre-signed) URL: a time-limited link to one object, auto-expiring
  • or serve via a CDN with controlled origin access
  • public is almost never the answer

Detect exposure

Even with good defaults, mistakes happen, so detect exposure continuously. Posture management tools, which the coming episodes cover, flag public buckets across your accounts. Access analyzers report any resource shared outside your account. Alerts fire on policy or ACL changes that expose data. And you can scan your own storage like attackers do. The goal is to catch an accidental exposure in minutes, not months later in a breach report. Prevention plus detection is the full defence.

Find leaks before attackers
  • posture tools (CSPM) flag public buckets continuously
  • access analyzer reports externally shared resources
  • alert on policy/ACL changes that expose data
  • scan your own storage like attackers do
  • catch it in minutes, not a breach report

Common mistakes

Mistakes. Block-public-access left off at the account level, removing the one control that would prevent a leak. Wildcard principals in bucket policies, which grant everyone access. Making a whole bucket public to share a single file instead of using a signed URL. Relying on the confusing ACL mechanism rather than policies. No versioning, so an accidental or malicious delete is permanent. And no monitoring, so a bucket that becomes public stays that way unnoticed until it is found by someone else.

Avoid these
  • block-public-access off at the account level
  • wildcard principals in bucket policies
  • making a bucket public to share one file
  • ACLs instead of policies
  • no versioning, so a delete is permanent
  • no monitoring for newly public buckets

Say it like this

In the interview: the most important control is account-wide block-public-access, enforced as a guardrail, because it overrides any mistaken public policy or ACL. On top, storage is private by default with least-privilege bucket policies, no wildcard principals, ACLs disabled. I turn on encryption at rest and versioning so deletes are recoverable. For sharing, I use time-limited signed URLs or a CDN, not public. And I continuously scan for exposure, so an accidental public bucket is caught in minutes.

In the interview
  • "Turn on account-wide block- public-access as a guardrail;
  • it overrides any mistaken
  • public policy. Private by default, least-privilege
  • bucket policies, no wildcards, ACLs disabled. Encryption and versioning on. Share with signed URLs, not public, and scan continuously for exposure."

Interview questions

Q1Why do storage buckets become public accidentally?

Because multiple overlapping controls, object and bucket ACLs, bucket policies with wildcard principals, and manual "make public" actions, can each expose data. Getting any one wrong leaks the bucket, which is why a single master control to block public access was introduced.

Q2What is block public access?

An account-wide (and per-bucket) setting that overrides any bucket policy or ACL that would make data public. Enabling it across the account prevents the classic public-bucket leak regardless of other misconfigurations, and every major cloud has an equivalent.

Q3How should access to a bucket be controlled?

With least-privilege IAM policies for in-account identities and bucket (resource) policies for cross-account and fine-grained rules, avoiding wildcard principals. Disabling the older ACL mechanism in favour of policies removes a common source of accidental exposure.

Q4What is a pre-signed (signed) URL?

A time-limited link that grants temporary access to a single object without making the bucket public. It expires automatically and is scoped to one file, making it the correct way to share objects instead of exposing the whole bucket.

Q5Why enable versioning and object lock on storage?

Versioning keeps previous object versions so accidental or malicious deletes and overwrites can be recovered, which also helps against ransomware. Object lock can make objects undeletable for a set period, protecting against tampering and deletion.

Q6How do you serve public content without a public bucket?

By serving through a content delivery network with controlled (origin) access to a private bucket, so users reach content via the CDN while the bucket itself is never directly public. This keeps the storage private while still distributing content.

Q7How do you detect exposed buckets?

Use cloud security posture management tools to flag public buckets continuously, access analyzers to report externally shared resources, and alerts on policy or ACL changes that expose data, so accidental exposure is caught in minutes rather than in a breach.

Q8Is bucket encryption at rest enough to prevent leaks?

No. Encryption at rest protects against physical or storage-layer access but does nothing if the bucket is public or over-permissioned, because authorised reads return decrypted data. Access control and block-public-access are what prevent exposure.