Securing S3 Buckets
AWSOfficialPublished by AWS
- Skill
- Workflow
- Cloud and DevOps
- Apache-2.0
- No issues found
AutoGineer summary
Written by AutoGineer from the skill’s own files, not by the author
This skill provides a structured approach to managing AWS S3 security. It covers the entire lifecycle of a bucket, from initial secure creation to ongoing auditing and remediation of misconfigurations. It enforces strict security standards, including mandatory HTTPS enforcement, encryption configurations, and monitoring, while ensuring that all policy modifications are handled safely through backup and validation procedures.
What it does
- Secures new S3 buckets with default encryption, versioning, and HTTPS-only policies.
- Audits existing buckets against a comprehensive security checklist.
- Remediates identified security findings with verified commands.
- Configures S3 encryption using SSE-S3 or customer-managed KMS keys.
- Enables logging and monitoring via CloudTrail and AWS Config.
- Safely manages bucket policies by backing up existing configurations before updates.
When to use it
- When deploying a new S3 bucket and ensuring it meets security standards from day one.
- When performing a security review of existing S3 infrastructure.
- When you need to fix specific security findings or compliance gaps in S3 buckets.
- When configuring encryption settings or enabling logging for auditability.
Advantages
- Ensures consistent application of AWS Well-Architected security principles.
- Reduces human error during complex policy modifications through mandatory backup steps.
- Provides clear, actionable audit reports with severity levels.
- Enforces secure-by-default configurations like blocking SSE-C and enabling S3 Bucket Keys.
Usage examples
- “Secure a new S3 bucket named my-app-data in us-east-1.”
- The agent will create the bucket, enable versioning, enforce HTTPS, configure SSE-S3 encryption, and apply the required security policies.
- “Audit the bucket my-existing-bucket for security issues.”
- The agent will run a series of read-only checks and provide a report detailing PASS/FAIL status for controls like public access, encryption, and logging.
Install
Download the skill as a ZIP:
https://autogineer.com/agent-skills/aws/securing-s3-buckets/downloadUnzip it into the cross-client skills folder of your project:
mkdir -p .agents/skills && unzip securing-s3-buckets.zip -d .agents/skills
Documentation by AWS
Overview
Implements layered S3 security controls across five workflows: securing new buckets, auditing existing configurations, remediating findings, configuring encryption, and enabling monitoring. Follows AWS Well-Architected security best practices.
Execute commands using the AWS MCP server when connected (sandboxed execution, audit logging, observability). Fall back to AWS CLI or shell otherwise.
Common Tasks
0. Verify Dependencies
Check for required tools before starting.
Constraints:
You MUST inform the user if required tools are missing
You SHOULD confirm credentials with
aws sts get-caller-identity
See references/iam-permissions.md for IAM permissions by workflow.
1. Classify the Request
| User intent | Workflow |
|---|---|
| Secure a new bucket | A: Secure New Bucket |
| Audit / review existing bucket | B: Audit Existing Bucket |
| Fix a specific finding | C: Remediate Issue |
| Configure encryption | D: Configure Encryption |
| Enable logging / monitoring | E: Enable Monitoring |
Constraints:
You MUST ask for all required parameters upfront
You MUST confirm bucket name and region before any write operation
You MAY infer region from user context if clearly stated
You SHOULD run
aws iam simulate-principal-policyto validate permissions before write operationsYou SHOULD display write commands and wait for confirmation before executing
put-bucket-policy Safety Rules
These rules apply to ALL workflows that call put-bucket-policy:
You MUST attempt to retrieve the existing policy first (
aws s3api get-bucket-policy) —put-bucket-policyreplaces the entire policyIf a policy exists, you MUST back it up before modifying:
aws s3api get-bucket-policy --bucket <name> --output text > backup-policy-$(date +%s).jsonIf
NoSuchBucketPolicyis returned, proceed with a new policy — no backup is neededYou MUST merge new statements into the existing policy's Statement array (if one exists)
You MUST validate merged JSON syntax before applying (e.g.
echo '<policy>' | python3 -m json.tool)You SHOULD display the full
put-bucket-policycommand and wait for confirmation
2. Workflow A — Secure New Bucket
See references/workflows.md for full CLI steps.
Required steps (execute in order, do not skip):
Create bucket with
--bucket-namespace account-regionalEnable versioning
Enable encryption (SSE-S3 + Bucket Keys + block SSE-C)
Enable logging (ask user which option — conditional)
Enforce HTTPS-only via
DenyInsecureTransportbucket policyEnable ABAC
Constraints:
You MUST pass
--bucket-namespace account-regionaloncreate-bucketcall — this is REQUIRED, not optional. Example:aws s3api create-bucket --bucket <name> --bucket-namespace account-regional --region <region>You MUST NOT change Block Public Access — S3 enables it by default on new buckets
You MUST NOT change ACL ownership controls — S3 disables ACLs (
BucketOwnerEnforced) by defaultYou MUST apply a bucket policy with a
DenyInsecureTransportstatement that deniess3:*whenaws:SecureTransportisfalse— this is REQUIRED, not optional. Example:aws s3api put-bucket-policy --bucket <name> --policy '{"Version":"2012-10-17","Statement":[{"Sid":"DenyInsecureTransport","Effect":"Deny","Principal":"*","Action":"s3:*","Resource":["arn:aws:s3:::<name>/*","arn:aws:s3:::<name>"],"Condition":{"Bool":{"aws:SecureTransport":"false"}}}]}'You MUST ask the user which logging option they want before step 4
You MUST follow the put-bucket-policy safety rules for steps 4 and 5
You SHOULD confirm each step succeeded before proceeding
3. Workflow B — Audit Existing Bucket
See references/audit-checklist.md for the full checklist.
Constraints:
You MUST run all read-only audit commands before reporting findings
You MUST NOT execute any write or modify commands during an audit
You MUST report each control as PASS / FAIL / NOT CONFIGURED with severity
For logging: report PASS if either S3 server access logging OR CloudTrail data events are enabled; NOT CONFIGURED only if neither
4. Workflow C — Remediate Issue
See references/remediation.md for fix commands by issue type.
Constraints:
You MUST identify the issue type before applying any fix
You MUST follow the put-bucket-policy safety rules when modifying policies
You MUST re-run the relevant audit check after applying the fix to confirm resolution
5. Workflow D — Configure Encryption
See references/encryption.md for encryption options and commands.
Constraints:
You MUST default to SSE-S3 with S3 Bucket Keys and SSE-C blocked unless the user explicitly requests KMS
When using SSE-KMS, you MUST use a customer managed key — NEVER the AWS managed
aws/s3keyYou MUST specify customer-managed KMS keys by full ARN, not alias
You MUST include
BucketKeyEnabled: trueandBlockedEncryptionTypes: [SSE-C]in all configurationsNote: The S3 API accepts
aws/s3and aliases without error — agent-enforced constraints. Verify withget-bucket-encryptionafter applying.
6. Workflow E — Enable Monitoring
See references/workflows.md for full CLI steps.
Constraints:
You MUST check whether a GuardDuty detector already exists before creating one
You MUST use the trail's home region (not the bucket's region) for CloudTrail commands
You SHOULD enable all four core recommended AWS Config rules
Troubleshooting
ObjectLockConfigurationNotFoundError — Object Lock is not enabled. Treat as NOT CONFIGURED, not a failure.
AccessDenied on audit commands — Check IAM policy, bucket policy, Block Public Access, VPC endpoint policy, and SCPs/RCPs. Use aws iam simulate-principal-policy to diagnose.
put-bucket-policy silently removes existing statements — See put-bucket-policy safety rules.
GuardDuty BadRequestException: detector already exists — Run aws guardduty list-detectors first; only call create-detector if empty.
CloudTrail changes not taking effect — Verify you are using --region <trail-home-region>, not the bucket's region. Find it with aws cloudtrail describe-trails --query 'trailList[*].[Name,HomeRegion]'.
Additional Resources
references/iam-permissions.md — IAM permissions by workflow
references/audit-checklist.md — Per-control checklist with severity and pass conditions
references/encryption.md — Encryption options, KMS guidance, SSE-C blocking
references/remediation.md — Fix commands for common findings
references/workflows.md — Full CLI command sequences for Workflows A and E
Files
- ATTRIBUTION.mdAdded by AutoGineer925 B
- LICENSELicence file added by AutoGineer9.9 KiB
- NOTICELicence file added by AutoGineer67 B
- SKILL.md7.7 KiB
- references/audit-checklist.md2.3 KiB
- references/encryption.md4.9 KiB
- references/iam-permissions.md1.4 KiB
- references/remediation.md5.1 KiB
- references/workflows.md7.6 KiB
references/audit-checklist.md
S3 Security Audit Checklist
Critical (fix immediately)
| Control | Check command | Pass condition |
|---|---|---|
| Block Public Access | get-public-access-block | All 4 flags true |
| No public bucket policy | get-bucket-policy | No "Principal": "*" or "Principal": {"AWS": "*"} with Allow |
| HTTPS enforced | get-bucket-policy | DenyInsecureTransport statement present |
| ACLs disabled | get-bucket-ownership-controls | BucketOwnerEnforced |
High
| Control | Check command | Pass condition |
|---|---|---|
| Default encryption enabled | get-bucket-encryption | SSEAlgorithm set |
| S3 Bucket Keys enabled | get-bucket-encryption | BucketKeyEnabled: true |
| SSE-C blocked | get-bucket-encryption | BlockedEncryptionTypes.EncryptionType contains SSE-C |
| Not using AWS managed key | get-bucket-encryption | KMSMasterKeyID is NOT aws/s3 |
Medium
| Control | Check command | Pass condition |
|---|---|---|
| Versioning enabled | get-bucket-versioning | Status: Enabled |
| Logging enabled | get-bucket-logging + cloudtrail get-event-selectors | PASS if either S3 server access logging OR CloudTrail data events is configured; NOT CONFIGURED if neither |
| GuardDuty S3 Protection | list-detectors + get-detector | S3_DATA_EVENTS feature is ENABLED |
Prerequisites
IAM Access Analyzer: The audit checklist requires an active analyzer. Before running list-findings, verify one exists:
aws accessanalyzer list-analyzers --region <region>If the result is empty, report as a finding: "No IAM Access Analyzer configured in <region>". Creating the analyzer is a remediation action (Workflow C), not part of the audit.
Low / Compliance
| Control | Check command | Pass condition |
|---|---|---|
| Object Lock (WORM) | get-object-lock-configuration | Enabled if compliance required |
| Cross-region replication | get-bucket-replication | Configured if DR required |
| Bucket in account namespace | bucket name | Ends with -<account-id>-<region>-an |
AWS Config Rules
Core (always enable):
s3-bucket-public-read-prohibited
s3-bucket-ssl-requests-only
s3-bucket-versioning-enabled
s3-bucket-logging-enabledOptional (enable if compliance requires):
s3-bucket-public-write-prohibited
s3-account-level-public-access-blocks
s3-bucket-replication-enabled
cloudtrail-s3-dataevents-enabledRequirements and compatibility
Works with: Claude Code, Claude apps, OpenAI Codex, GitHub Copilot, Cursor, Gemini CLI, Kiro, OpenCode, Goose, Amp, Roo Code, JetBrains Junie, Factory Droid, Devin (ex-Windsurf), Mistral Vibe, OpenHands, Letta
“Works with” means the tool reads the open Agent Skills format; a skill written for one tool may use features others lack.
Needs: Needs an MCP server, Needs Python
Security
No issues found by our static scan· No issues found
A static scan is not a guarantee. Skills are third-party content: review a skill before you let an agent use it.
Attribution and licence
- Published by
- AWS
- Publisher
- AWS (Official)
- Source
- aws/agent-toolkit-for-aws · skills/specialized-skills/storage-skills/securing-s3-buckets · commit 0a218f8
- Licence
- Apache License 2.0 (redistribution allowed)
- LICENSE (added by AutoGineer from LICENSE)
- NOTICE (added by AutoGineer from NOTICE)
- ATTRIBUTION.md (written by AutoGineer)
- Synced
AutoGineer is not affiliated with or endorsed by AWS or AWS.
Download ZIP
The ZIP holds the skill’s files, its licence files and an ATTRIBUTION.md. Download securing-s3-buckets.zip