
Auditing Aws S3 Bucket Permissions
- 242 installs
- 27.3k repo stars
- Updated August 2, 2026
- mukul975/anthropic-cybersecurity-skills
An agent skill that audits AWS S3 bucket permissions to detect public exposure and misconfigured access policies. A builder uses it to harden cloud storage before or after shipping. Name-only content means the exact chec
About
An agent skill that audits AWS S3 bucket permissions to detect public exposure and misconfigured access policies. A builder uses it to harden cloud storage before or after shipping. Name-only content means the exact checks are inferred from the skill title.
- S3 permission audit
- Misconfiguration detection
- Cloud security
Auditing Aws S3 Bucket Permissions by the numbers
- 242 all-time installs (skills.sh)
- +11 installs in the week ending Aug 4, 2026 (Skillselion tracking)
- Ranked #703 of 2,203 Security skills by installs in the Skillselion catalog
- Security screen: LOW risk (skills.sh audit)
- Data as of Aug 5, 2026 (Skillselion catalog sync)
npx skills add https://github.com/mukul975/anthropic-cybersecurity-skills --skill auditing-aws-s3-bucket-permissionsAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 242 |
|---|---|
| repo stars | ★ 27.3k |
| Security audit | 3 / 3 scanners passed |
| Last updated | August 2, 2026 |
| Repository | mukul975/anthropic-cybersecurity-skills ↗ |
Audit AWS S3 bucket permissions to find misconfigurations and exposure.?
Audit AWS S3 bucket permissions to find misconfigurations and exposure.
Who is it for?
A developer or small team who needs audit aws s3 bucket permissions to find misconfigurations and exposure..
Skip if: Teams with no use for auditing-aws-s3-bucket-permissions or anyone needing capabilities outside what the skill documents.
When should I use this skill?
When you need to audit aws s3 bucket permissions to find misconfigurations and exposure..
What you get
Deliverables covering s3 permission audit, misconfiguration detection, cloud security from the auditing-aws-s3-bucket-permissions skill.
Files
Auditing AWS S3 Bucket Permissions
When to Use
- When conducting a security assessment of AWS environments to identify publicly exposed data
- When onboarding a new AWS account and establishing a security baseline for storage resources
- When responding to an alert about potential S3 data exposure from AWS Trusted Advisor or Security Hub
- When compliance frameworks (SOC 2, PCI DSS, HIPAA) require periodic review of data access controls
- When a breach or credential compromise necessitates immediate review of all accessible S3 resources
Do not use for auditing non-AWS object storage (use provider-specific tools), for real-time monitoring (use S3 Event Notifications with Lambda), or for auditing S3 access patterns (use S3 Access Analyzer or CloudTrail S3 data events).
Prerequisites
- AWS CLI v2 configured with credentials that have
s3:GetBucketPolicy,s3:GetBucketAcl,s3:GetBucketPublicAccessBlock,s3:GetEncryptionConfiguration, ands3:ListAllMyBucketspermissions - Prowler installed (
pip install prowler) for automated CIS benchmark checks - S3audit or similar enumeration tool for quick public bucket detection
- Access to AWS Organizations if auditing across multiple accounts
- Python 3.8+ with boto3 for custom audit scripts
Workflow
Step 1: Enumerate All S3 Buckets and Account-Level Block Public Access
Check the account-level S3 Block Public Access settings first, then list all buckets with their regions.
# Check account-level S3 Block Public Access settings
aws s3control get-public-access-block \
--account-id $(aws sts get-caller-identity --query Account --output text) \
--output json
# List all buckets with creation dates
aws s3api list-buckets \
--query 'Buckets[*].[Name,CreationDate]' \
--output table
# Get bucket regions for each bucket
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
region=$(aws s3api get-bucket-location --bucket "$bucket" --query 'LocationConstraint' --output text)
echo "$bucket -> ${region:-us-east-1}"
doneStep 2: Check Each Bucket's Public Access Block and ACL Configuration
Iterate through all buckets to evaluate their individual public access blocks and ACL grants.
# Check per-bucket Block Public Access settings
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
echo "=== $bucket ==="
aws s3api get-public-access-block --bucket "$bucket" 2>/dev/null || echo " No Block Public Access configured"
# Check ACL for public grants
aws s3api get-bucket-acl --bucket "$bucket" \
--query 'Grants[?Grantee.URI==`http://acs.amazonaws.com/groups/global/AllUsers` || Grantee.URI==`http://acs.amazonaws.com/groups/global/AuthenticatedUsers`]' \
--output json
doneStep 3: Analyze Bucket Policies for Overly Permissive Access
Review bucket policies for wildcard principals, missing conditions, and statements that allow broad access.
# Extract and analyze bucket policies
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
policy=$(aws s3api get-bucket-policy --bucket "$bucket" --output text 2>/dev/null)
if [ -n "$policy" ]; then
echo "=== $bucket policy ==="
echo "$policy" | python3 -c "
import json, sys
policy = json.load(sys.stdin)
for stmt in policy.get('Statement', []):
principal = stmt.get('Principal', {})
effect = stmt.get('Effect', '')
if principal == '*' or principal == {'AWS': '*'}:
print(f' WARNING: {effect} with wildcard principal')
print(f' Actions: {stmt.get(\"Action\", \"\")}')
print(f' Condition: {stmt.get(\"Condition\", \"NONE\")}')
"
fi
doneStep 4: Verify Encryption and Versioning Settings
Check that all buckets have server-side encryption enabled and versioning configured for data protection.
# Check encryption and versioning status for all buckets
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
echo "=== $bucket ==="
# Encryption configuration
aws s3api get-bucket-encryption --bucket "$bucket" 2>/dev/null \
&& echo " Encryption: ENABLED" \
|| echo " Encryption: DISABLED"
# Versioning status
aws s3api get-bucket-versioning --bucket "$bucket" \
--query 'Status' --output text
# Logging status
aws s3api get-bucket-logging --bucket "$bucket" \
--query 'LoggingEnabled' --output text 2>/dev/null
doneStep 5: Run Prowler S3-Specific Checks
Execute Prowler's S3-focused checks aligned with CIS AWS Foundations Benchmark.
# Run Prowler S3-specific checks
prowler aws \
--checks s3_bucket_public_access \
s3_bucket_default_encryption \
s3_bucket_policy_public_write_access \
s3_bucket_server_access_logging_enabled \
s3_bucket_versioning_enabled \
s3_bucket_acl_prohibited \
-M json-ocsf \
-o ./prowler-s3-audit/
# View summary
prowler aws --checks s3 -M csv -o ./prowler-s3-audit/Step 6: Use IAM Access Analyzer for S3 Public and Cross-Account Findings
Leverage IAM Access Analyzer to identify buckets shared externally or publicly.
# List Access Analyzer findings for S3
aws accessanalyzer list-findings \
--analyzer-arn $(aws accessanalyzer list-analyzers --query 'analyzers[0].arn' --output text) \
--filter '{"resourceType": {"eq": ["AWS::S3::Bucket"]}}' \
--query 'findings[*].[resource,status,condition,principal]' \
--output table
# Create an analyzer if one does not exist
aws accessanalyzer create-analyzer \
--analyzer-name s3-access-audit \
--type ACCOUNTStep 7: Generate Audit Report and Remediate
Compile findings into an actionable report and apply remediation for critical issues.
# Quick remediation: Enable Block Public Access on a bucket
aws s3api put-public-access-block \
--bucket TARGET_BUCKET \
--public-access-block-configuration \
'BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true'
# Enable default encryption with SSE-S3
aws s3api put-bucket-encryption \
--bucket TARGET_BUCKET \
--server-side-encryption-configuration \
'{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"alias/aws/s3"},"BucketKeyEnabled":true}]}'
# Enable versioning
aws s3api put-bucket-versioning \
--bucket TARGET_BUCKET \
--versioning-configuration Status=EnabledKey Concepts
| Term | Definition |
|---|---|
| S3 Block Public Access | Account-level and bucket-level settings that override ACLs and policies to prevent public access regardless of individual resource configurations |
| Bucket Policy | JSON-based resource policy attached to a bucket that defines who can access the bucket and what actions they can perform |
| ACL (Access Control List) | Legacy S3 access control mechanism granting permissions to AWS accounts or predefined groups like AllUsers or AuthenticatedUsers |
| IAM Access Analyzer | AWS service that analyzes resource policies to identify resources shared with external entities or the public |
| Server-Side Encryption | Encryption applied by S3 at the object level using SSE-S3, SSE-KMS, or SSE-C before writing data to disk |
| CIS AWS Foundations Benchmark | Security best practice standard from Center for Internet Security with specific controls for S3 bucket configuration |
Tools & Systems
- AWS CLI: Primary interface for querying S3 bucket configurations, policies, ACLs, and encryption settings
- Prowler: Open-source security tool with 50+ S3-specific checks aligned to CIS, PCI DSS, and HIPAA controls
- IAM Access Analyzer: AWS-native service for continuous monitoring of resource policies that grant external access
- S3audit: Lightweight tool for quick enumeration of public S3 buckets across an account
- ScoutSuite: Multi-cloud auditing tool that collects S3 configuration data and generates risk-scored HTML reports
Common Scenarios
Scenario: Identifying a Publicly Readable Bucket Containing Customer Data
Context: A security engineer receives a Trusted Advisor alert about a publicly accessible S3 bucket. The bucket was created by a development team for a demo and was never locked down.
Approach: 1. Run aws s3api get-bucket-acl and find a grant to AllUsers with READ permission 2. Check get-bucket-policy and discover a policy with Principal: "*" and s3:GetObject 3. Confirm Block Public Access is not enabled at the bucket or account level 4. Enumerate bucket contents to assess data sensitivity 5. Immediately enable Block Public Access on the bucket 6. Review CloudTrail S3 data events to determine if unauthorized access occurred 7. Report the finding with timeline, data inventory, and remediation confirmation
Pitfalls: Enabling Block Public Access can break applications that intentionally serve content publicly (static websites). Always verify the bucket's intended use before applying restrictions. Check for CloudFront distributions or other services relying on the bucket's public access.
Output Format
S3 Bucket Permissions Audit Report
=====================================
Account: 123456789012 (Production)
Date: 2026-02-23
Auditor: Security Engineering Team
Total Buckets: 47
ACCOUNT-LEVEL SETTINGS:
Block Public Access: ENABLED (all four settings)
CRITICAL FINDINGS:
[S3-001] Public Read Access via ACL
Bucket: marketing-assets-prod
Issue: AllUsers group granted READ permission via ACL
Risk: Any internet user can list and download bucket contents
Data Sensitivity: Contains customer-facing but non-sensitive marketing assets
Remediation: Remove AllUsers ACL grant, enable Block Public Access
[S3-002] Wildcard Principal in Bucket Policy
Bucket: data-exchange-partner
Issue: Policy allows s3:GetObject with Principal "*" and no VPC/IP condition
Risk: Intended for partner access but accessible to anyone with the bucket name
Remediation: Add aws:SourceVpce or aws:SourceIp condition to restrict access
SUMMARY:
Buckets with public access: 3 / 47
Buckets without encryption: 5 / 47
Buckets without versioning: 12 / 47
Buckets without access logging: 18 / 47
Buckets with overly broad policies: 7 / 47
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to the Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by the Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding any notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. Please do not remove or change
the license header comment from a contributed file except when
necessary.
Copyright 2026 mukul975
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
API Reference: Auditing AWS S3 Bucket Permissions
boto3 S3 Client
List Buckets
import boto3
s3 = boto3.client("s3")
response = s3.list_buckets()
for bucket in response["Buckets"]:
print(bucket["Name"], bucket["CreationDate"])Get Bucket ACL
acl = s3.get_bucket_acl(Bucket="my-bucket")
for grant in acl["Grants"]:
print(grant["Grantee"], grant["Permission"])Get/Put Public Access Block
# Check settings
resp = s3.get_public_access_block(Bucket="my-bucket")
config = resp["PublicAccessBlockConfiguration"]
# Enable all blocks
s3.put_public_access_block(
Bucket="my-bucket",
PublicAccessBlockConfiguration={
"BlockPublicAcls": True,
"IgnorePublicAcls": True,
"BlockPublicPolicy": True,
"RestrictPublicBuckets": True,
},
)Get Bucket Policy
import json
policy_str = s3.get_bucket_policy(Bucket="my-bucket")["Policy"]
policy = json.loads(policy_str)
for stmt in policy["Statement"]:
print(stmt["Effect"], stmt["Principal"], stmt["Action"])Check Encryption
enc = s3.get_bucket_encryption(Bucket="my-bucket")
rules = enc["ServerSideEncryptionConfiguration"]["Rules"]
print(rules[0]["ApplyServerSideEncryptionByDefault"]["SSEAlgorithm"])Check Versioning
resp = s3.get_bucket_versioning(Bucket="my-bucket")
print(resp.get("Status", "Disabled"))Key S3 API Methods for Security Auditing
| Method | Returns |
|---|---|
list_buckets() | All buckets in account |
get_bucket_acl() | ACL grants (AllUsers, AuthenticatedUsers) |
get_public_access_block() | Block public access configuration |
get_bucket_policy() | Bucket policy JSON (wildcard principals) |
get_bucket_encryption() | Default encryption algorithm |
get_bucket_versioning() | Versioning status |
get_bucket_logging() | Access logging configuration |
get_bucket_location() | Bucket region |
Public Grant URIs to Flag
| URI | Risk |
|---|---|
http://acs.amazonaws.com/groups/global/AllUsers | Public read/write |
http://acs.amazonaws.com/groups/global/AuthenticatedUsers | Any AWS account |
References
- boto3 S3 docs: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/s3.html
- AWS S3 security: https://docs.aws.amazon.com/AmazonS3/latest/userguide/security.html
#!/usr/bin/env python3
"""Agent for auditing AWS S3 bucket permissions using boto3."""
import os
import json
import argparse
from datetime import datetime
import boto3
from botocore.exceptions import ClientError
def get_session(profile=None, region=None):
"""Create a boto3 session."""
kwargs = {}
if profile:
kwargs["profile_name"] = profile
if region:
kwargs["region_name"] = region
return boto3.Session(**kwargs)
def list_all_buckets(session):
"""List all S3 buckets in the account."""
s3 = session.client("s3")
response = s3.list_buckets()
buckets = []
for b in response.get("Buckets", []):
loc = s3.get_bucket_location(Bucket=b["Name"])
region = loc.get("LocationConstraint") or "us-east-1"
buckets.append({"name": b["Name"], "created": str(b["CreationDate"]), "region": region})
return buckets
def check_public_access_block(session, bucket_name):
"""Check bucket-level public access block settings."""
s3 = session.client("s3")
try:
response = s3.get_public_access_block(Bucket=bucket_name)
config = response["PublicAccessBlockConfiguration"]
return {
"configured": True,
"block_public_acls": config.get("BlockPublicAcls", False),
"ignore_public_acls": config.get("IgnorePublicAcls", False),
"block_public_policy": config.get("BlockPublicPolicy", False),
"restrict_public_buckets": config.get("RestrictPublicBuckets", False),
}
except ClientError:
return {"configured": False}
def check_bucket_acl(session, bucket_name):
"""Check bucket ACL for public grants."""
s3 = session.client("s3")
acl = s3.get_bucket_acl(Bucket=bucket_name)
public_grants = []
public_uris = [
"http://acs.amazonaws.com/groups/global/AllUsers",
"http://acs.amazonaws.com/groups/global/AuthenticatedUsers",
]
for grant in acl.get("Grants", []):
grantee = grant.get("Grantee", {})
if grantee.get("URI") in public_uris:
public_grants.append({
"grantee": grantee.get("URI"),
"permission": grant.get("Permission"),
})
return public_grants
def check_bucket_policy(session, bucket_name):
"""Check bucket policy for wildcard principals."""
s3 = session.client("s3")
try:
policy_str = s3.get_bucket_policy(Bucket=bucket_name)["Policy"]
policy = json.loads(policy_str)
issues = []
for stmt in policy.get("Statement", []):
principal = stmt.get("Principal", {})
if principal == "*" or principal == {"AWS": "*"}:
issues.append({
"effect": stmt.get("Effect"),
"action": stmt.get("Action"),
"condition": stmt.get("Condition", "NONE"),
})
return {"has_policy": True, "wildcard_issues": issues}
except ClientError:
return {"has_policy": False, "wildcard_issues": []}
def check_encryption(session, bucket_name):
"""Check if default encryption is enabled."""
s3 = session.client("s3")
try:
enc = s3.get_bucket_encryption(Bucket=bucket_name)
rules = enc.get("ServerSideEncryptionConfiguration", {}).get("Rules", [])
if rules:
algo = rules[0].get("ApplyServerSideEncryptionByDefault", {}).get("SSEAlgorithm")
return {"enabled": True, "algorithm": algo}
except ClientError:
pass
return {"enabled": False, "algorithm": None}
def check_versioning(session, bucket_name):
"""Check if versioning is enabled."""
s3 = session.client("s3")
resp = s3.get_bucket_versioning(Bucket=bucket_name)
return {"status": resp.get("Status", "Disabled")}
def check_logging(session, bucket_name):
"""Check if server access logging is enabled."""
s3 = session.client("s3")
resp = s3.get_bucket_logging(Bucket=bucket_name)
enabled = "LoggingEnabled" in resp
return {"enabled": enabled}
def audit_bucket(session, bucket_name):
"""Run full security audit on a single bucket."""
return {
"bucket": bucket_name,
"public_access_block": check_public_access_block(session, bucket_name),
"public_acl_grants": check_bucket_acl(session, bucket_name),
"bucket_policy": check_bucket_policy(session, bucket_name),
"encryption": check_encryption(session, bucket_name),
"versioning": check_versioning(session, bucket_name),
"logging": check_logging(session, bucket_name),
}
def classify_risk(audit_result):
"""Classify risk level for a bucket based on audit findings."""
risk = "LOW"
if audit_result["public_acl_grants"]:
risk = "CRITICAL"
elif audit_result["bucket_policy"]["wildcard_issues"]:
risk = "HIGH"
elif not audit_result["encryption"]["enabled"]:
risk = "MEDIUM"
elif not audit_result["public_access_block"]["configured"]:
risk = "MEDIUM"
audit_result["risk_level"] = risk
return audit_result
def main():
parser = argparse.ArgumentParser(description="AWS S3 Bucket Permissions Audit Agent")
parser.add_argument("--profile", default=os.getenv("AWS_PROFILE"))
parser.add_argument("--region", default=os.getenv("AWS_DEFAULT_REGION"))
parser.add_argument("--bucket", help="Audit a specific bucket")
parser.add_argument("--output", default="s3_audit_report.json")
args = parser.parse_args()
session = get_session(args.profile, args.region)
account_id = session.client("sts").get_caller_identity()["Account"]
print(f"[+] Auditing S3 buckets in account {account_id}")
if args.bucket:
buckets = [{"name": args.bucket}]
else:
buckets = list_all_buckets(session)
print(f"[+] Found {len(buckets)} buckets")
results = []
for b in buckets:
name = b["name"]
print(f" Auditing {name}...")
audit = audit_bucket(session, name)
audit = classify_risk(audit)
results.append(audit)
if audit["risk_level"] in ("CRITICAL", "HIGH"):
print(f" [{audit['risk_level']}] {name}")
report = {
"account": account_id,
"audit_date": datetime.utcnow().isoformat(),
"total_buckets": len(results),
"critical": sum(1 for r in results if r["risk_level"] == "CRITICAL"),
"high": sum(1 for r in results if r["risk_level"] == "HIGH"),
"buckets": results,
}
with open(args.output, "w") as f:
json.dump(report, f, indent=2, default=str)
print(f"[+] Report saved to {args.output}")
if __name__ == "__main__":
main()
Related skills
FAQ
What is auditing-aws-s3-bucket-permissions?
An agent skill that audits AWS S3 bucket permissions to detect public exposure and misconfigured access policies. A developer uses it to harden cloud storage before or after shipping. Name-only content means the exact checks are inferred from the skill
When should I use auditing-aws-s3-bucket-permissions?
When you need to audit aws s3 bucket permissions to find misconfigurations and exposure.
Is Auditing Aws S3 Bucket Permissions safe to install?
skills.sh reports 3 of 3 security scanners passed. Review the Security Audits panel on this page before installing in production.