安全最佳实践-个人博客
  • 首页概览
    • 三个常见的云安全误解
    • AWS网络保险合作伙伴
    • 安全开源工具
    • Video + Podcast Series Conversations with Security Leaders
    • AWS Security Workshops
    • AWS Security Whitepaper
      • Organizing Your AWS Environment Using Multiple Accounts
    • AWS Jam
  • Multiple Accounts 多账号管理
    • 使用AWS Control Tower管理多账户
      • 通过AWS Control Tower简化跨账号部署
    • 多账户策略和最佳实践
      • 使用多账户的好处
      • 使用单组织OU
      • 多账户设计原则
      • 推荐使用的OU和账户
        • Security OU
          • 相关博客
            • Set up an organization-wide aggregator in AWS Config using a delegated administrator account
            • Simplify governance with declarative policies
        • Infrastructure OU
          • Backup account 备份账户
          • Identity account 身份账户
          • Network account 网络账户
            • 规模化管理IP地址-IPAM
          • Operations Tooling account 运维工具账户
          • Monitoring account 监控账户
          • Shared Services
            • Cross-account configuration with AWS AppConfig
    • 跨账户管理资源
      • 跨账户开启config
      • 跨账号访问S3存储桶
      • 跨账户以最小权限共享资源
    • 在 AWS 上构建安全的企业机器学习平台
    • 使用第三方代付的企业管理资源最佳实践
    • VMware’s Cloud Journey: AWS Account Management at Scale
  • 1. IAM 身份识别与访问控制
    • 新手起步
      • IAM常用术语
      • 什么是ABAC?
      • 中国区使用IAM编写策略需要注意的地方
      • 组织,管理账户和成员账户
      • 什么时候使用user,什么时候使用role
      • IAM Role的应用场景
      • IAM SCP的应用场景
      • IAM 策略类型:如何使用以及何时使用
      • AWS SIGv4 和 SIGv4A
      • 如何写condition
        • Services that work with IAM
        • AWS IAM Policy Condition Operators Explained
        • Every Condition Operator You Technically CAN Put in an IAM Policy
        • 限制IP地址段
        • 设置时间范围
        • 允许某个请求者操作 - ArnLike/ArnLikeIfExists
        • 允许AWS服务访问 aws:PrincipalIsAWSService
      • 添加虚拟MFA或硬件MFA
      • Authentication(AuthN) 和 Authorization(AuthZ)
      • How to Clear your AWS CLI Credentials
      • 通过CLI获取EC2的验证凭据的方式
      • Amazon Cognito
      • 去中心化标识符(Decentralized Identifier,DID)
    • 多因素认证MFA启用计划
      • 如何强制IAM用户使用MFA
      • 多因素身份验证可防范哪些类型的攻击?
    • ABAC权限控制方式
      • 给云资源打标签
      • 标记 Amazon EC2 资源
      • 标记Amazon S3
      • ABAC的应用
        • 如何根据标签定义配置访问 Amazon 资源的权限
        • 如何使用SAML session tags实现SSO的ABAC权限管理
        • Identity Center的Attribute Based Access Control (ABAC)
      • How to implement SaaS tenant isolation with ABAC and AWS IAM
    • Privileged Access Management 特权访问管理
      • 限制使用AdministratorAccess策略的用户或者角色
      • 使用SCP限制根用户的行为
      • Centralize Root Access In AWS(AssumeRoot)
      • 用SCP限制创建IAM User结合安全规范要求指定人员才能创建
      • 特权账号管理实践
      • 禁用不使用的服务和区域
    • Data Perimeters 数据防护边界
      • SCP(Service control policies)示例策略
        • 通过Service Control Policies(SCP)限制只能使用某个区域的AWS服务
        • 禁止成员账户访问管理账户/指定账户
        • 限制高危操作
          • 指定角色才能操作名称中含有security-nono的secrets
        • tagging:阻止标记被修改,除非由授权委托人修改
        • tagging:要求创建/运行某类资源时必须打了标签
        • iam:阻止根用户的访问
        • iam: 阻止创建根用户的AKSK
        • ec2:防止在没有 IMDSv2 的情况下启动 EC2 实例
        • RAM: 阻止外部共享
        • S3: 限制仅从预期网络可以访问
        • S3: 防止上传文件到未授权的存储桶
        • S3:防止上传 Amazon S3 未加密对象
        • S3:关键S3存储桶保护
        • S3:防止开放到公网
        • lambda: 确保开发部署lambda程序只能从VPC连接
        • 安全日志管理涉及的安全控制
        • 安全产品管理涉及的安全控制
        • 阻止 IaC 已经支持的所有行动
        • kms: 阻止组织外使用KMS
        • 拒绝生产账户使用 DisableKey 和 ScheduleKeyDeletion
        • 仅可信网络/预期网络
        • 仅访问可信资源
      • 资源策略(Resource-based policies)示例策略
        • IAM Role Trust Policy
        • S3存储桶策略
          • Examples of Amazon S3 bucket policies
          • 仅限OU范围内共享存储桶
          • 必须采用加密传输访问S3存储桶
        • KMS key策略
        • Secrets Manager Secret策略
        • SNS策略
        • SQS队列策略
      • 资源控制策略Resource control policies (RCPs)
        • 增强KMS保护
        • 增强secrets保护
        • 增强网络防护边界
        • 上传到 S3 的文件都必须加密
      • VPC端点策略(VPC endpoint policies)示例策略
        • VPCE和第三方资源
        • VPCE和AWS托管的资源
        • VPCE和S3
        • VPCE和组织内资源
      • blog-如何使用 data perimeter helper 评估影响并完善数据边界控制
    • Workforce Identity Integration 单点登录
      • IAM Identity Center作为IdP
        • 如何将IAM User迁移到IAM Identity Center
        • AWS Lake Formation Integrating IAM Identity Center
        • Authenticate AWS Client VPN users with SAML
        • 如何将 IAM Identify Center 与 Amazon Cognito User Pool集成?
        • Federated access to Amazon Athena using AWS IAM Identity Center
        • Integrate Identity Provider (IdP) with Amazon Redshift Query Editor V2 and SQL Client using AWS IAM Identity Center for seamless Single Sign-On
        • Jenkins 如何与 AWS Identity Center 集成
        • SAML Single Sign On (SSO) into Jira using AWS as IDP
      • IAM Identity Center作为SP
        • 配置 SAML assertions 用于授权响应
        • 将Okta 作为权限集中管理的控制中心,整合AWS IAM Identity Center 来访问AWS
        • Configure SAML and SCIM with Google Workspace and IAM Identity Center
        • Single Sign-On between Okta Universal Directory and AWS
      • AWS SSO用户如何使用CLI
      • AWS Federated Authentication with Active Directory Federation Services (AD FS)
      • 通过Identity Store API大规模管理和审计 AWS IAM 身份中心的用户和组操作
      • 令牌认证和单点登录协议
        • OpenID Connect (OIDC)
        • 代码交换证明密钥(Proof Key for Code Exchange,简称PKCE)
        • OpenID协议
        • SCIM 2.0
        • SAML2.0
          • 常见缩略语和定义
          • SAML2 Assertion 示例
          • SAML tokens
          • 在线工具
          • SP Metadata示例
        • OAuth 2.0授权模型
          • OAuth 2.0
          • OAuth 2.0 Simplified
          • OAuth 2.0 Simplified by okta
      • AWS IAM Identity Center Region Switch
      • How to bulk import users and groups from CSV into AWS IAM Identity Center
    • AWS认证和授权:IAM最佳实践
      • AWS CLI 和 AWS SDKs配置权限的几种方式
      • 通过IAM Role连接Github
      • IAM 账户设置最佳实践
      • 一些权限策略中可以用到的condition
        • AllowSSLRequestsOnly
        • Time-based access control
      • 场景化IAM实践-应用程序安全
        • IAM Role for RDS
        • IAM Roles for Amazon EC2
        • IAM role for GitHub OIDC
        • IAM Role for EKS
      • 场景化IAM实践-人员安全
        • IAM Identity Center for human
        • FinanceManager
        • FinanceUser
        • SystemsManager
        • AuditManager
        • SecurityManager
        • IAMAdmin
        • Developers
        • KMS Admin
        • 基于时间的访问控制
        • 第三方访问您的AWS资源
    • IAM相关的开源解决方案
      • Temporary elevated access management (TEAM)
        • Unable to deploy due to AWS Codecommit being deprecated #293
      • 免费开源的CIAM解决方案
        • ZITADEL
        • keycloak
      • 备份和恢复IAM Identity Center权限集和用户
      • 自动审阅AWS IAM Identity Center权限
      • AWS IAM Identity Center Region Switch
      • An AWS IAM Security Tooling Reference [2024]
    • 目录服务AWS Directory Service
      • 在 AWS Managed AD 和运行 Windows Server Core 版本的本地 Active Directory 之间创建信任关系
      • 轻量级目录访问协议(Lightweight Directory Access Protocol,LDAP)
    • CIAM,即客户身份和访问管理(Customer Identity and Access Management)
      • APP认证系统:Amazon Cognito最佳实践
        • 通过简单的登录注册APP学习SAML和OAuth
          • `aws-amplify/auth`中`signIn`函数的完整代码示例,包含错误处理和用户体验改进
        • 基本概念
          • 身份令牌 (ID Token) 和访问令牌 (Access Token)
          • Auth2.0
            • OAuth 2.0 安全最佳实践
          • user pool JSON web tokens (JWTs)
        • machine-to-machine authorization
        • 高级安全功能
        • 与IAM Identity Center结合
        • 如何在 Amazon Cognito 中使用 OAuth 2.0:了解不同的 OAuth 2.0 授权
        • SaaS authentication: Identity management with Amazon Cognito user pools
        • Adding threat detection to custom authentication flow with Amazon Cognito advanced security features
      • APP授权系统:Amazon Verified Permissions最佳实践
        • 使用 Amazon Verified Permissions 和 Amazon Cognito 为 API Gateway API授权
        • 使用 Amazon Verified Permissions 和 Amazon Cognito 授权 API Gateway API
        • 使用 Amazon Verified Permissions 管理 AWS IoT smart home 应用的权限
    • AWS EKS Access Management
  • 2. 基础架构安全
    • 网络安全架构设计案例
    • 端口管控
  • 3. 数据保护
    • 识别及标识敏感数据
      • 如何系统地打标签Tag
      • 使用Tag Policies和Service Control Policies控制对包含 PII 数据的 AWS 资源的访问
      • 自动识别敏感数据
      • 敏感数据扫描与匿名化开源工具
    • 保护敏感数据
      • 数据匿名化方法概览
      • 日志匿名化处理
      • 保护S3的数据
        • Secure your Media Workloads with JWT Token with Lambda@Edge
      • CloudFront预签名
      • 重要数据备份
      • 关系型数据库字段级加密
      • 如何加密数据
      • 数据完整性校验
      • Amazon RDS 数据库密码管理
      • Web3的私钥托管
      • 防止未授权访问
      • 代码中使用SecureString保存敏感的参数
      • 交易签名
      • 隐私计算:构建可信执行环境
      • 如何实现代码中不出现明文口令
        • 通过AWS Secrets Manager统一管理混合云上的安全凭据
      • PKI构建
        • How to build a CA hierarchy across multiple AWS accounts and Regions for global organization
    • 数据资产管理与保护
  • 4. 日志与监控
    • 日志集中管理
      • 使用CloudWatch Logs Insights检索日志
        • 收集数据库审计日记
      • 使用Amazon Security Lake收集安全日志
        • Open Cybersecurity Schema Framework(OCSF)
        • 通过Security Lake构建你的安全数据湖
        • 使用Security Lake和Athena分析日志
          • Unauthorized attempts
          • 调查可疑用户
          • 检索某账号AKSK在指定时间范围内做了什么
          • 调查GuardDuty的发现
          • 错误使用aws_sts_getsessiontoken
        • 使用Security Lake & Jupyter Notebooks实现事件响应
      • SIEM on Amazon OpenSearch Service
        • 如何配置OpenSearch发送安全告警
        • 使用IAM Identity Center 登录OpenSearch Cluster
        • Configure SAML federation for Amazon OpenSearch Serverless with AWS IAM Identity Center
      • 使用Athena分析日志
      • 理解并利用CloudTrail
        • 了解 IAM Identity Center 登录事件
        • Understanding IAM Identity Center sign-in events
        • 使用CloudTrail Lake进行日志筛选
        • 跨多账号收集CloudTrail日志
    • 安全基线检查与配置监控
      • AWS Config
        • Using AWS Config custom resources to track any resource on AWS
        • Simplify compliance management of multicloud or hybrid resources with AWS Config
        • Discover duplicate AWS Config rules for streamlined compliance
    • 告警通知设置
      • AWS Security Hub发送Slack告警通知
      • AWS Security Hub 发送邮件通知
      • 应用CloudTrail实现告警通知常见场景
        • API未授权访问告警通知
        • 安全组更改告警通知
        • NACL更改告警通知
        • IGW更改告警通知
        • 路由表更改告警通知
        • VPC更改告警通知
        • 没有通过MFA登录时的告警通知
        • 根用户使用时的告警通知
        • IAM策略变更告警通知
        • AWS控制台登录失败告警通知
        • 禁用或计划删除客户管理密钥告警通知
        • 更改S3 Bucket Policy 告警通知
        • 更改Amazon Config告警通知
        • AWS Personal Health Dashboard告警通知
        • CloudTrail配置变更告警通知
        • Ten Ways to Improve Your AWS Operations
  • 5. 事件响应
    • 安全自动化合规审计与自动修复
    • Security Hub安全检查与自动修复
    • 安全合规自动审计
      • 基础:使用AWS Security Hub
        • 导出Security Hub的发现
      • 进阶:使用AWS Config扩展检查项目
      • 进阶:使用Chef InSpec profiles with Systems Manager实现主机和容器的基线检查
      • 高级:通过JIRA+Security Hub实现SOC安全运营中心
      • 合规检测规则集
        • GDPR(Global AWS Config)
        • 等保3级(中国区AWS Config)
    • 自动安全响应与修复
      • Security Hub发现自动修复
        • IAM.3-自动轮换IAM用户AK/SK
      • WAF自动拦截恶意请求
        • 在WAF上自动部署 web 访问控制列表过滤web攻击
        • 允许或阻止来自特定国家/地区或地理位置的请求
        • ATP 托管规则组
        • 登录页WAF验证码
        • 登录页面的基于速率的规则
        • 服务器端代码执行防范
      • AWS Trusted Advisor 发现自动修复
      • GuardDuty告警自动响应
        • IAM AKSK泄漏自动响应
        • 基于 Amazon GuardDuty 威胁级别的自动化通知
        • 删除EC2上的恶意文件
        • 拦截恶意IP访问EC2实例或者阻止EC2实例外联恶意IP
        • 创建自定义脚本自动隔离EC2实例
      • Config+SSM 的方式自动修复
        • config: restricted-ssh
        • config: required-tags
      • 利用custodian实现自动修复
        • 为S3存储桶自动打标签
        • 为EC2自动打标签
      • 自动修复常见场景
        • 自动生成组织策略
        • 自动抑制告警,减少噪音
        • 自动添加自定义字段到Findings告警,"Tag production findings"
        • 自动升级Security Hub的严重等级
      • 高级:使用Systems Manager自动修复
    • 自动补丁管理
  • 安全合规
    • 安全认证和合规框架
      • Cloud Controls Matrix (CCM)
      • 中国-三级等级保护合规检测
      • ISO 27001:2022
      • US Cyber Trust Mark
    • 全球各国法律速查
      • USA 美国
        • 拜登总统发布行政命令保护美国人的敏感个人数据
        • 美国出口管理条例(EAR)
        • 医疗-HIPAA
        • 信息格式标准-OSCAL
      • Canada加拿大
      • Europ欧洲
        • 汽车-UNECE Regulation No. 155(UN R155)
      • Singapore 新加坡
      • Japan 日本
      • Australia 澳大利亚
      • China 中国
      • 行业类隐私数据保护
        • 生物医疗出海企业需要满足的合规要求
      • 数据跨境流通要求
        • GDPR-数据跨境流通应对方案
        • 新加坡数据跨境流通应对方案
        • 中国-个人信息跨境处理活动安全认证规范
        • 全球数据本地化要求与AWS region
          • 如何选择合适的region
        • 数据泄露通知要求
          • 数据泄漏通知建设建议
      • 什么是GDPR
        • GDPR法规详细解读
        • 如何销毁数据满足GDPR
        • 隐私保护安全评估模板
          • 个人数据保护影响评估(DPIA)-GDPR
          • 个人隐私数据保护自查清单
    • AWS Privacy Reference Architecture (AWS PRA)
    • 数据安全合规
    • 可证明安全性 Provable Security
      • 自动推理如何帮助亚马逊 S3 实现大规模创新
      • AWS 如何利用自动推理帮助您实现大规模安全
    • 亚马逊云科技是值得客户信任的云
      • AWS Fault Isolation Boundaries
    • 敏感数据分级分类
      • 按照客户数据和业务数据分类
      • 金融领域
  • 安全产品成本估算
    • 计算器地址与报价地址
    • 安全合规持续检测和自动修复费用
    • MATTER认证费用
    • WEB应用防护和DDOS防护费用
    • 数据库和S3加密费用
    • Amazon Security Lake收集日志并分析的费用
    • Amazon Security Lake 和 AWS CloudTrail Lake做日志分析的成本对比
    • 如何实现AWS账单预警
  • 📑安全体系建设
    • 风险管理
    • 事件管理/ 安全事件应急响应
      • Cyber Incident Response – Readiness Checklist
      • Playbooks / 网络事件应对计划和操作手册
    • 安全价值衡量指标与展现
      • IAM项目投资价值衡量指标
由 GitBook 提供支持
在本页
  1. 安全体系建设
  2. 云资产入侵防范
  3. S3存储桶被入侵防范

防止Amazon S3存储桶被未授权访问并安全地开放到公网

为了防止Amazon S3存储桶被未授权访问并安全地开放到公网,以下是一些最佳实践:

  1. 使用Amazon CloudFront:CloudFront是一个内容分发网络(CDN)服务,它可以在全球范围内安全、高效地分发您的静态和动态Web内容。通过使用CloudFront,您可以将内容缓存到全球的边缘位置,只有这些边缘节点会直接与您的S3存储桶通信,而终端用户则从CloudFront获取内容。

  2. 保持S3存储桶私有:确保您的S3存储桶配置为私有,这样它就不会公开可访问。这意味着未经授权的用户无法直接通过互联网访问存储桶中的数据。

  3. 利用源访问身份(OAI):使用CloudFront的源访问身份(OAI)来限制对S3存储桶的访问,只允许CloudFront访问您的S3存储桶,从而增加一层额外的保护。

  4. 实施存储桶策略和IAM策略:创建和实施IAM策略和S3存储桶策略,精确控制哪些用户或服务可以访问您的S3资源,以及他们可以执行的操作。

  5. 启用访问日志记录:启用S3访问日志记录,以监控和记录所有对S3存储桶的请求。这有助于您跟踪使用模式,检测异常行为,并在必要时采取行动。

  6. 使用AWS WAF和AWS Shield:集成AWS WAF(Web应用程序防火墙)和AWS Shield以提供额外的安全层,保护您的CloudFront分发和S3存储桶免受网络攻击。

  7. 实施版本控制和对象锁定:使用S3版本控制和对象锁定来防止关键数据被意外更改或删除,确保数据完整性。

  8. 使用HTTPS:确保所有通过CloudFront分发的内容都使用HTTPS,这可以保护传输中的数据免受中间人攻击。

  9. 定期审查和更新策略:定期审查您的安全设置和策略,确保它们仍然符合您的安全要求,并根据需要进行更新。

  10. 使用AWS Config:利用AWS Config监控和评估S3存储桶的配置,确保它们没有被错误地配置为对公网开放。

通过遵循这些最佳实践,您可以最大限度地减少S3存储桶被未授权访问的风险,同时有效地向公网提供内容。

通过CloudFront保持S3存储桶私有并允许公共访问

要允許使用 Amazon CloudFront公開訪問私有 Amazon S3 桶中的內容,您應該遵循以下步驟:

  1. 创建S3存储桶并禁用所有公共访问: Ensure that your S3 bucket is configured as private to prevent direct public access. This is a crucial initial step to maintain security over your assets。

  2. 创建CloudFront分发,选择Web作为选项,并确保选择“Restrict Bucket Access”以创建“Origin Access Identity(OAI)”。Set up a CloudFront distribution with your S3 bucket as the origin. CloudFront acts as a reverse proxy and caches the content from your S3 bucket at its edge locations.

  3. CloudFront将为OAI创建IAM凭证,并授予其从存储桶读取对象的权限。当公共用户请求对象时,CloudFront将从S3存储桶获取对象并缓存在边缘位置,然后提供给用户。Use an Origin Access Identity (OAI) that CloudFront creates for you automatically when you set up the distribution. This OAI allows CloudFront to access your S3 bucket without exposing it to the public. Modify the bucket policy to allow access only via the OAI.

  4. 等待CloudFront分发完成部署,然后可以开始托管文件。可以通过CloudFront URL访问文件,而不是直接使用S3链接,以确保私有内容受到保护。

  5. Signed URLs or Cookies: For secure access to private content, use CloudFront signed URLs or signed cookies. This requires generating a signature that CloudFront checks before serving the content. You can set up signed URLs or cookies to control access to specific content, and you can define policies for the URLs or cookies, such as validity period and allowed IP addresses.

  6. Update Bucket Policy: Update the S3 bucket policy to reflect the CloudFront OAI and to ensure that only CloudFront can access the bucket. An example policy is provided in the AWS documentation, which you can modify according to your specific needs.

  7. Deploy SSL/TLS Certificate: Use SSL/TLS to encrypt the data in transit. CloudFront automatically uses HTTPS when creating signed URLs, enhancing security.

  8. AWS WAF Integration: Optionally, integrate AWS Web Application Firewall (WAF) with your CloudFront distribution to add an additional layer of security.

  9. Test the Configuration: After setting up the CloudFront distribution and the necessary policies, test the configuration by accessing the content through the CloudFront URL. Ensure that the content is accessible only when using the signed URL or cookie and not directly through the S3 bucket URL.

  10. Monitor and Adjust: Monitor the access logs in CloudFront to ensure that the setup is working as intended and adjust the security settings as necessary.

By following these steps, you can use CloudFront to securely allow public access to your private S3 bucket's content. Remember to regularly review and update your security settings to adapt to new requirements or threats.

For detailed instructions and code examples, refer to the AWS documentation:

参考资料

最后更新于1年前

For creating a CloudFront distribution and setting up OAI, see .

For configuring Signed URLs or Cookies, see .

For updating bucket policy with OAI, see .

📑
Amazon CloudFront Developer Guide
Serving Private Content through CloudFront
Restricting Access to S3
Using CloudFront to allow public access to content in private S3 bucket