May 19, 2025
Auditing AWS S3 Bucket Permissions with S3 Inspector

Auditing AWS S3 Bucket Permissions with S3 Inspector
Misconfigured S3 buckets are a common security risk. If your cloud environment stores sensitive data in S3, it’s critical to ensure no buckets are unintentionally public. S3 Inspector is a lightweight tool that helps you scan for public access and generate a clear, actionable report.
It works across Linux, macOS, and Windows, and supports both Python 2.7 and 3. You can also deploy it as an AWS Lambda function.
What S3 Inspector Does
When you run S3 Inspector, it checks all buckets in your account and provides:
- A public/private status indicator for each bucket
- A breakdown of permissions for any bucket marked public
- A list of accessible URLs (if public)
This gives you a quick view of potential exposure and access risks across your S3 environment.
Getting Started: IAM Setup
Option 1: Create a New IAM User
- Open the IAM console
- Click Users → Add user
- Choose a username and check Programmatic access
- Click Next: Permissions
- Attach the AmazonS3ReadOnlyAccess policy
- Create the user and copy the Access key ID and Secret access key
- Create a ~/.aws/credentials file with the following:
ini
CopyEdit
[default]
aws_access_key_id = YOUR_ACCESS_KEY
aws_secret_access_key = YOUR_SECRET_KEY
Option 2: Use an Existing IAM Profile
If you already have a profile in ~/.aws/credentials, you can run the script with that:
bash
CopyEdit
python s3inspector.py
When prompted:
Enter your AWS profile name [default]:
Use default or enter your specific profile name.
Running S3 Inspector
To execute the scan:
bash
CopyEdit
python s3inspector.py
You’ll receive a report listing each bucket’s public access status and related details.
Running S3 Inspector as a Lambda Function
You can also deploy S3 Inspector as a Lambda function and automate regular checks.
Step 1: Create an SNS Topic
- Open the SNS console
- Click Topics → Create topic
- Set a name and description
- Create a subscription with Email protocol
- Confirm the subscription via the email you receive
- Copy the topic ARN and set it in the SNS_RESOURCE_ARN variable in the s3inspector.py script
Step 2: Create the Lambda Function
- Open the Lambda console
- Choose Create function → Author from scratch
- Name the function s3inspector
- Assign a role with Lambda execution and S3 read permissions
- In the configuration:
- Set runtime to Python 2.7
- Set the handler to s3inspector.lambda_handler
- Paste the script contents into the editor
- Set timeout to at least 1 minute
- Set runtime to Python 2.7
- Save and test with an empty event or configure a trigger
Final Thoughts
S3 Inspector is a simple, effective way to scan for public access in your AWS environment. Whether used as a one-off script or deployed as part of a continuous audit via Lambda, it helps teams proactively secure data stored in Amazon S3.
—
Need help with AWS security audits or IAM best practices? Talk to AVM Consulting