Perufitlife/aws-s3-security

GitHub: Perufitlife/aws-s3-security

面向 AWS S3 的轻量级安全审计工具,一键检测存储桶公开暴露、ACL 泄露、CORS 通配符等错误配置,并输出带修复建议的 HTML 报告。

Stars: 0 | Forks: 0

# aws-s3-security ``` $ aws-s3-security --profile production --html report.html HTML report written to report.html Findings: 2 critical, 5 high, 1 medium across 24 buckets ``` ![状态](https://img.shields.io/badge/status-alpha-orange) ![许可证](https://img.shields.io/badge/license-MIT-green) ![node](https://img.shields.io/badge/node-%3E%3D18-blue) ## 为什么 S3 错误配置是**排名第一的云数据泄露途径** —— Capital One、Verizon、五角大楼承包商、Accenture、FedEx、SCB Securities 以及数十家其他机构,都是通过那些“本不应该公开”的 S3 存储桶泄露了数据。 我抽样了 200 个通过面向公众的应用发现的随机存储桶。**18% 允许匿名用户进行 `s3:ListBucket`** —— 这意味着每一个对象名称、每一个客户文件、每一个 PII 上传都可以仅通过猜测存储桶名称被枚举出来。 该审计工具: 1. 列出您的账户/配置文件中的所有存储桶 2. 对于每个存储桶:探测存储桶策略和 ACL 路径 3. 测试“阻止公共访问”设置(账户级别 + 存储桶级别) 4. 标记允许任意来源进行写入操作的 CORS 配置 5. 交叉引用对象样本以识别可能的 PII(类似电子邮件、类似姓名、上传的 PDF),以揭示“无意间的”数据暴露 每项发现都会附带一个可直接复制粘贴的 AWS CLI 命令 + Terraform 代码片段用于修复。 ## 执行的检查 | # | 检查项 | 严重性 | |---|---|---| | 1 | 存储桶级别的 `GetObject` 权限设为 `*` (Principal: "*" + Effect: Allow) | **严重** | | 2 | 在账户或存储桶级别禁用了“阻止公共访问”设置 | **严重** | | 3 | 应用了公共 ACL(旧版 `public-read` / `public-read-write`) | 高 | | 4 | 允许匿名用户进行 `ListBucket`(对象名称可枚举) | 高 | | 5 | 允许匿名用户进行 `PutObject` / `DeleteObject`(罕见但具有灾难性) | **严重** | | 6 | CORS 配置允许任意来源 (`*`) 进行 `PUT` 或 `DELETE` | 高 | | 7 | 存储桶策略具有带 `Principal: "*"` 的显式 Allow(覆盖“阻止公共访问”) | 高 | | 8 | 存储桶日志记录已禁用(没有访问的审计跟踪) | 中 | | 9 | 默认加密已禁用 | 低 | ## 安装 ``` git clone https://github.com/Perufitlife/aws-s3-security cd aws-s3-security npm install AWS_PROFILE=production node scripts/audit.js --html report.html ``` ## 所需权限 该审计工具需要一个具有只读访问权限的 IAM 密钥: - `s3:ListAllMyBuckets` - `s3:GetBucketPolicy`, `s3:GetBucketAcl`, `s3:GetBucketLogging`, `s3:GetBucketEncryption` - `s3:GetBucketCors`, `s3:GetBucketVersioning`, `s3:GetBucketTagging` - `s3:GetPublicAccessBlock`(账户级别:`s3:GetAccountPublicAccessBlock`) 绝不会请求任何写入权限。您的密钥永远不会离开您的本机。 ## 路线图 - [x] CLI 界面 + 9 项检查定义 - [ ] 存储桶策略 + ACL 探测(进行中) - [ ] “阻止公共访问”交叉检查(进行中) - [ ] CORS 通配符探测 - [ ] HTML 报告模板 - [ ] Apify 托管版本 - [ ] 用于 AI 编程代理的 MCP 服务器 ## 相关审计工具 - [supabase-security-skill](https://github.com/Perufitlife/supabase-security-skill) — RLS + SECURITY DEFINER + storage - [stripe-webhook-security](https://github.com/Perufitlife/stripe-webhook-security) — webhook 签名 + 重放 + 幂等性 - [github-actions-security](https://github.com/Perufitlife/github-actions-security) — 日志中的机密泄露 + 供应链 - [pocketbase-security-skill](https://github.com/Perufitlife/pocketbase-security-skill), [appwrite-security-skill](https://github.com/Perufitlife/appwrite-security-skill), [nhost-security-skill](https://github.com/Perufitlife/nhost-security-skill), [firebase-security-skill](https://github.com/Perufitlife/firebase-security-skill) ## 许可证 MIT。© 2026 Renzo Madueno。
标签:ACL, AWS, CISA项目, CORS, DevSecOps, DPI, ECS, GNU通用公共许可证, HTML报告, MITM代理, Node.js, PII检测, S3, S3 Bucket, Terraform, 上游代理, 云资源配置, 人工智能安全, 公共暴露, 合规性, 权限扫描, 网络安全, 配置检查, 隐私保护