Repository navigation
Data Exfiltration: flag snapshot, export and parameter-history actions (#654) - #668
Open
devteamaegis wants to merge 1 commit into
Open
devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
The Data Exfiltration finding only matched five read actions, although its risk definition already names rds:CreateDBSnapshot and rds:CopyDBSnapshot. - Add ssm:GetParameterHistory to READ_ONLY_DATA_EXFILTRATION_ACTIONS. - Add SNAPSHOT_AND_EXPORT_DATA_EXFILTRATION_ACTIONS for the Write-level snapshot, copy and export actions on RDS, EC2/EBS and DynamoDB. - Match the combined DATA_EXFILTRATION_ACTIONS in PolicyDocument and PolicyFinding, reported under the existing DataExfiltration finding. - secretsmanager:BatchGetSecretValue is left out: it is wildcard-only and requires secretsmanager:GetSecretValue on each secret, which is already flagged, so adding it would flag correctly scoped policies. - Add tests, regenerate the example data and update the glossary page. Refs salesforce#654
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Closes #654.
The Data Exfiltration finding only matched five read actions, although its risk definition already says
rds:CopyDBSnapshotandrds:CreateDBSnapshot"can be used to exfiltrate RDS database contents". A policy allowing those on*was not flagged.This takes option 1 from the issue: a second list, reported under the same Data Exfiltration finding. No new finding type, and no UI or schema change.
READ_ONLY_DATA_EXFILTRATION_ACTIONSkeeps its name (still read-only) and gainsssm:GetParameterHistory(Read; returns past values, decrypted withWithDecryption).SNAPSHOT_AND_EXPORT_DATA_EXFILTRATION_ACTIONS(all Write in policy_sentry):rds:CreateDBSnapshot,rds:CopyDBSnapshot,rds:CreateDBClusterSnapshot,rds:CopyDBClusterSnapshot,rds:StartExportTask,ec2:CreateSnapshot,ec2:CreateSnapshots,ec2:CopySnapshot,ec2:CreateInstanceExportTask,ec2:ExportImage,dynamodb:ExportTableToPointInTime.PolicyDocument.allows_data_exfiltration_actionsandPolicyFinding.data_exfiltrationmatchDATA_EXFILTRATION_ACTIONS(the two lists combined).exclude-actionsstill suppresses any of them.Left out:
secretsmanager:BatchGetSecretValue. policy_sentry has it as List level with no resource type, so it can only be granted on*, and cloudsplaining flags any allowed wildcard-only action. AWS also requiressecretsmanager:GetSecretValueon each secret (API reference). SoBatchGetSecretValueon*plusGetSecretValueonsecret:app/*can only readapp/*, but it would be flagged. WhenGetSecretValueis on*, that is already flagged. Happy to add it if you'd rather accept the noise.Tests
test/scanning/test_data_exfiltration_actions.py: no duplicates, and every action inDATA_EXFILTRATION_ACTIONSis detected when allowed on*. This guards against names policy_sentry doesn't recognise, liketest_privilege_escalation_methods.pydoes.test_policy_document.py: wildcard-capable actions are flagged; restrictable-only actions (rds:StartExportTask,dynamodb:ExportTableToPointInTime) are flagged on*; ARN-scoped grants are not flagged.test_policy_finding.py:PolicyFindingreports them, andexclude-actionssuppresses them.main; all 136 pass on this branch.Example data: regenerated
utils/example-iam-data.jsonandsampleData.js(kept in sync) andindex.html.just generate-reportreorders lists on each run, so I kept HEAD's ordering and applied only the semantic change (~80 lines instead of ~18k).just compare-reports: "no findings dropped (77 added, 0 removed)". The additions are in AmazonRDSFullAccess, AmazonEC2FullAccess and the overly permissive teaching policies. Updateddocs/glossary/data-exfiltration.md.Open question: the description string (
RISK_DEFINITION["DataExfiltration"]and its copy inglossary.js) still says "certain read-only IAM actions". Rewording it touches ~10 exact-string test expectations and needs adist/rebuild, so I left it out to keep this small. Glad to do it here or in a follow-up.Note: #625 edits the same lines in
PolicyFinding.data_exfiltration. If it merges first, the conflict resolution is to putDATA_EXFILTRATION_ACTIONSin its union.What gif best describes this PR or how it makes you feel?
n/a
Completion checklist
just lint,just unit-tests,just type-check,npm test,just safety-scan)index.htmlregenerated)This was investigated and written with an AI coding agent (Claude) working on my behalf.