Communitygithub.com

Auditoría de Permisos de Buckets S3 en AWS

Auditar sistemáticamente los permisos de los buckets S3 de AWS para identificar datos expuestos públicamente.

¿Qué es Auditoría de Permisos de Buckets S3 en AWS?

Esta skill proporciona un flujo de trabajo completo para realizar auditorías de seguridad de los permisos de los buckets S3 en AWS. Es ideal para evaluaciones de seguridad, incorporación de nuevas cuentas, respuesta a alertas de exposición de datos, cumplimiento normativo (SOC 2, PCI DSS, HIPAA) o revisión posterior a una brecha. La skill guía a través de siete pasos clave: enumerar todos los buckets y la configuración de bloqueo de acceso público a nivel de cuenta, verificar los bloques de acceso público y las ACL de cada bucket, analizar las políticas de bucket en busca de acceso demasiado permisivo, verificar el cifrado y el versionado, ejecutar comprobaciones específicas de S3 con Prowler, utilizar IAM Access Analyzer para identificar hallazgos de acceso público o entre cuentas, y generar un informe de auditoría con remediación. Incluye scripts detallados para AWS CLI, integración con herramientas como Prowler, IAM Access Analyzer, S3audit y ScoutSuite, y cubre conceptos clave como S3 Block Public Access, Bucket Policies, ACLs, Server-Side Encryption y CIS AWS Foundations Benchmark. La skill está diseñada para ser utilizada directamente desde la línea de comandos y es compatible con AWS CLI, Prowler, IAM Access Analyzer y otras herramientas de auditoría.

Compatible con~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/mukul975/Anthropic-Cybersecurity-Skills/tree/main/skills/auditing-aws-s3-bucket-permissions

Preguntar en tu IA favorita

Abre un nuevo chat con esta habilidad de agente ya precargada.

Documentación

¿Qué hace Auditoría de Permisos de Buckets S3 en AWS?

Cuándo Usarlo

  • Al realizar una evaluación de seguridad de entornos AWS para identificar datos expuestos públicamente
  • Al incorporar una nueva cuenta de AWS y establecer una línea base de seguridad para los recursos de almacenamiento
  • Al responder a una alerta sobre una posible exposición de datos S3 desde AWS Trusted Advisor o Security Hub
  • Cuando los marcos de cumplimiento (SOC 2, PCI DSS, HIPAA) requieren una revisión periódica de los controles de acceso a los datos
  • Cuando una brecha o compromiso de credenciales requiere una revisión inmediata de todos los recursos S3 accesibles

No usar para auditar almacenamiento de objetos que no sea AWS (usar herramientas específicas del proveedor), para monitoreo en tiempo real (usar S3 Event Notifications con Lambda) o para auditar patrones de acceso a S3 (usar S3 Access Analyzer o CloudTrail S3 data events).

Prerrequisitos

  • AWS CLI v2 configurado con credenciales que tengan permisos s3:GetBucketPolicy, s3:GetBucketAcl, s3:GetBucketPublicAccessBlock, s3:GetEncryptionConfiguration y s3:ListAllMyBuckets
  • Prowler instalado (pip install prowler) para comprobaciones automatizadas del benchmark CIS
  • S3audit o una herramienta de enumeración similar para la detección rápida de buckets públicos
  • Acceso a AWS Organizations si se audita en múltiples cuentas
  • Python 3.8+ con boto3 para scripts de auditoría personalizados

Flujo de Trabajo

Paso 1: Enumerar Todos los Buckets S3 y el Bloqueo de Acceso Público a Nivel de Cuenta

Primero, verifique la configuración de Bloqueo de Acceso Público a nivel de cuenta, luego enumere todos los buckets con sus regiones.

# Verificar la configuración de Bloqueo de Acceso Público a nivel de cuenta
aws s3control get-public-access-block \
  --account-id $(aws sts get-caller-identity --query Account --output text) \
  --output json

# Listar todos los buckets con fechas de creación
aws s3api list-buckets \
  --query 'Buckets[*].[Name,CreationDate]' \
  --output table

# Obtener las regiones de cada 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}"
done

Paso 2: Verificar el Bloqueo de Acceso Público y la Configuración de ACL de Cada Bucket

Itere sobre todos los buckets para evaluar sus bloques de acceso público individuales y las concesiones de ACL.

# Verificar la configuración de Bloqueo de Acceso Público por bucket
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 se ha configurado Block Public Access"

  # Verificar ACL en busca de concesiones públicas
  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
done

Paso 3: Analizar las Políticas de Bucket en Busca de Acceso Demasiado Permisivo

Revise las políticas de bucket en busca de principals comodín, condiciones faltantes y declaraciones que permitan un acceso amplio.

# Extraer y analizar las políticas de bucket
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 "=== Política de $bucket ==="
    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'  ADVERTENCIA: {effect} con principal comodín')
        print(f'  Acciones: {stmt.get(\"Action\", \"\")}')
        print(f'  Condición: {stmt.get(\"Condition\", \"NINGUNA\")}')
"
  fi
done

Paso 4: Verificar la Configuración de Cifrado y Versionado

Compruebe que todos los buckets tengan el cifrado del lado del servidor habilitado y el versionado configurado para la protección de datos.

# Verificar el estado del cifrado y el versionado para todos los buckets
for bucket in $(aws s3api list-buckets --query 'Buckets[*].Name' --output text); do
  echo "=== $bucket ==="

  # Configuración de cifrado
  aws s3api get-bucket-encryption --bucket "$bucket" 2>/dev/null \
    && echo "  Cifrado: HABILITADO" \
    || echo "  Cifrado: DESHABILITADO"

  # Estado del versionado
  aws s3api get-bucket-versioning --bucket "$bucket" \
    --query 'Status' --output text

  # Estado del registro de acceso
  aws s3api get-bucket-logging --bucket "$bucket" \
    --query 'LoggingEnabled' --output text 2>/dev/null
done

Paso 5: Ejecutar las Comprobaciones Específicas de S3 con Prowler

Ejecute las comprobaciones centradas en S3 de Prowler alineadas con el benchmark CIS AWS Foundations.

# Ejecutar comprobaciones específicas de S3 con Prowler
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/

# Ver resumen
prowler aws --checks s3 -M csv -o ./prowler-s3-audit/

Paso 6: Usar IAM Access Analyzer para Hallazgos S3 Públicos y entre Cuentas

Aproveche IAM Access Analyzer para identificar buckets compartidos externa o públicamente.

# Listar hallazgos de Access Analyzer para 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

# Crear un analizador si no existe
aws accessanalyzer create-analyzer \
  --analyzer-name s3-access-audit \
  --type ACCOUNT

Paso 7: Generar Informe de Auditoría y Remediar

Compile los hallazgos en un informe procesable y aplique la remediación para los problemas críticos.

# Remedio rápido: Habilitar Block Public Access en un bucket
aws s3api put-public-access-block \
  --bucket TARGET_BUCKET \
  --public-access-block-configuration \
  'BlockPublicAcls=true,IgnorePublicAcls=true,BlockPublicPolicy=true,RestrictPublicBuckets=true'

# Habilitar el cifrado predeterminado con 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}]}'

# Habilitar versionado
aws s3api put-bucket-versioning \
  --bucket TARGET_BUCKET \
  --versioning-configuration Status=Enabled

Conceptos Clave

TérminoDefinición
S3 Block Public AccessConfiguraciones a nivel de cuenta y de bucket que anulan ACL y políticas para evitar el acceso público independientemente de las configuraciones de recursos individuales
Bucket PolicyPolítica de recursos basada en JSON adjunta a un bucket que define quién puede acceder al bucket y qué acciones pueden realizar
ACL (Lista de Control de Acceso)Mecanismo heredado de control de acceso a S3 que otorga permisos a cuentas de AWS o grupos predefinidos como AllUsers o AuthenticatedUsers
IAM Access AnalyzerServicio de AWS que analiza las políticas de recursos para identificar recursos compartidos con entidades externas o el público
Cifrado del Lado del ServidorCifrado aplicado por S3 a nivel de objeto usando SSE-S3, SSE-KMS o SSE-C antes de escribir datos en el disco
CIS AWS Foundations BenchmarkEstándar de mejores prácticas de seguridad del Center for Internet Security con controles específicos para la configuración de buckets S3

Herramientas y Sistemas

  • AWS CLI: Interfaz principal para consultar configuraciones de buckets S3, políticas, ACL y configuraciones de cifrado
  • Prowler: Herramienta de seguridad de código abierto con más de 50 comprobaciones específicas de S3 alineadas con los controles CIS, PCI DSS e HIPAA
  • IAM Access Analyzer: Servicio nativo de AWS para la supervisión continua de políticas de recursos que otorgan acceso externo
  • S3audit: Herramienta ligera para la enumeración rápida de buckets S3 públicos en una cuenta
  • ScoutSuite: Herramienta de auditoría multinube que recopila datos de configuración de S3 y genera informes HTML con puntuación de riesgo

Escenarios Comunes

Escenario: Identificar un Bucket Legible Públicamente que Contiene Datos de Clientes

Contexto: Un ingeniero de seguridad recibe una alerta de Trusted Advisor sobre un bucket S3 accesible públicamente. El bucket fue creado por un equipo de desarrollo para una demostración y nunca fue protegido.

Enfoque:

  1. Ejecute aws s3api get-bucket-acl y encuentre una concesión a AllUsers con permiso READ
  2. Verifique get-bucket-policy y descubra una política con Principal: "*" y s3:GetObject
  3. Confirme que Block Public Access no está habilitado a nivel de bucket ni de cuenta
  4. Enumere el contenido del bucket para evaluar la sensibilidad de los datos
  5. Habilite inmediatamente Block Public Access en el bucket
  6. Revise los eventos de datos de CloudTrail S3 para determinar si ocurrió un acceso no autorizado
  7. Informe el hallazgo con la línea de tiempo, el inventario de datos y la confirmación de la remediación

Errores Comunes: Habilitar Block Public Access puede romper aplicaciones que intencionalmente sirven contenido públicamente (sitios web estáticos). Siempre verifique el uso previsto del bucket antes de aplicar restricciones. Verifique las distribuciones de CloudFront u otros servicios que dependan del acceso público del bucket.

Formato de Salida

Informe de Auditoría de Permisos de Buckets S3
===============================================
Cuenta: 123456789012 (Producción)
Fecha: 2026-02-23
Auditor: Equipo de Ingeniería de Seguridad
Total de Buckets: 47

CONFIGURACIONES A NIVEL DE CUENTA:
  Block Public Access: HABILITADO (las cuatro configuraciones)

HALLAZGOS CRÍTICOS:
[S3-001] Acceso de Lectura Pública a través de ACL
  Bucket: marketing-assets-prod
  Problema: Grupo AllUsers tiene permiso READ a través de ACL
  Riesgo: Cualquier usuario de Internet puede listar y descargar el contenido del bucket
  Sensibilidad de Datos: Contiene activos de marketing no sensibles orientados al cliente
  Remediación: Eliminar la concesión ACL de AllUsers, habilitar Block Public Access

[S3-002] Principal Comodín en la Política del Bucket
  Bucket: data-exchange-partner
  Problema: La política permite s3:GetObject con Principal "*" y sin condición de VPC/IP
  Riesgo: Intencionado para acceso de socios pero accesible para cualquiera que conozca el nombre del bucket
  Remediación: Agregar condición aws:SourceVpce o aws:SourceIp para restringir el acceso

RESUMEN:
  Buckets con acceso público:           3 / 47
  Buckets sin cifrado:                   5 / 47
  Buckets sin versionado:               12 / 47
  Buckets sin registro de acceso:       18 / 47
  Buckets con políticas demasiado amplias: 7 / 47

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

abusing-dpapi-for-credential-access

Extract and decrypt Windows DPAPI-protected secrets (Credential Manager, browser logins/cookies, Wi-Fi credentials, KeePass keys) online or offline using SharpDPAPI, SharpChrome, Mimikatz, or Impacket

abusing-shadow-credentials-for-privesc

Take over Active Directory accounts by writing attacker-controlled public keys to msDS-KeyCredentialLink (Shadow Credentials) with pyWhisker, Whisker, or Certipy, then authenticate via PKINIT to recover the target

achieving-cmmc-level-2-compliance

>-

acquiring-disk-image-with-dd-and-dcfldd

Create forensically sound bit-for-bit disk images with dd or dcfldd on a Linux forensic workstation, preserving evidence integrity through hash verification (MD5/SHA) during acquisition. Use when imaging a suspect drive, USB device, or memory card for investigation, preserving volatile disk evidence during incident response, or producing a verified copy for legal or law-enforcement proceedings before any destructive analysis.

analyzing-active-directory-acl-abuse

Detect dangerous ACL misconfigurations in Active Directory using ldap3

analyzing-android-malware-with-apktool

Perform static analysis of Android APK malware using apktool for resource decompilation, jadx for Java source recovery, and androguard for manifest inspection, dangerous permission-combination detection, and identification of obfuscated code, dynamic code loading, and reflection-based API calls. Use to statically triage a suspicious APK without executing it or to build mobile malware detection rules.

analyzing-api-gateway-access-logs

Parses API Gateway access logs (AWS API Gateway, Kong, Nginx) to detect

analyzing-apt-group-with-mitre-navigator

Query ATT&CK data with attackcti, mitreattack-python, and stix2, then build MITRE ATT&CK Navigator layers and multi-layer heatmap overlays mapping one or more APT groups

analyzing-azure-activity-logs-for-threats

Queries Azure Monitor activity logs and sign-in logs via azure-monitor-query

analyzing-bootkit-and-rootkit-samples

Analyzes bootkit and advanced rootkit malware infecting the Master

analyzing-browser-forensics-with-hindsight

Parse Chromium-based browser databases with Hindsight to extract and correlate browsing history, downloads, cookies, cached content, autofill data, saved passwords, and extensions from Chrome, Edge, Brave, Opera, and Vivaldi into a unified timeline (XLSX, JSON, or SQLite output). Use during incident response, insider-threat investigations, or criminal cases when you need to reconstruct a user

analyzing-campaign-attribution-evidence

Systematically evaluate cyber-campaign evidence to attribute an operation to a threat actor, using the Diamond Model and Analysis of Competing Hypotheses (ACH) to weigh infrastructure overlaps, TTP consistency, malware code similarity, and timing/language artifacts into confidence-weighted attribution assessments. Use when an incident investigation needs a defensible attribution confidence level.

analyzing-certificate-transparency-for-phishing

Monitor Certificate Transparency logs using crt.sh and Certstream to

analyzing-cloud-storage-access-patterns

Detect abnormal access in AWS S3, GCS, and Azure Blob Storage by analyzing CloudTrail Data Events, GCS audit logs, and Azure Storage Analytics for after-hours bulk downloads, new-IP access, and API-call spikes (e.g. GetObject) via statistical baselines and time-series anomaly detection. Use when investigating suspected cloud data exfiltration or building related detection rules.

analyzing-cobalt-strike-beacon-configuration

Extract and analyze Cobalt Strike beacon configuration from PE files

analyzing-cobaltstrike-malleable-c2-profiles

Parse and analyze Cobalt Strike Malleable C2 profiles with dissect.cobaltstrike (profiles and beacon-payload configs) and pyMalleableC2 (AST parsing) to extract HTTP/DNS transforms, URIs, headers, sleep/jitter, and injection behavior, then generate network detection signatures. Use when reverse-engineering a captured malleable profile or building detections against Cobalt Strike Beacon traffic.

analyzing-command-and-control-communication

Analyzes malware C2 communication over HTTP, HTTPS, DNS, and custom

analyzing-cyber-kill-chain

Analyzes intrusion activity against the Lockheed Martin Cyber Kill Chain

analyzing-disk-image-with-autopsy

Perform comprehensive forensic analysis of raw (dd), E01, or AFF disk images with Autopsy and The Sleuth Kit, recovering deleted files, examining metadata and embedded artifacts, keyword searching, and building investigation timelines with visual reports. Use for structured analysis of a forensic disk image or when stakeholders need visual reports from evidence.

analyzing-dns-logs-for-exfiltration

Analyzes DNS query logs to detect data exfiltration via DNS tunneling,

Skills relacionados