Skip to content

fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries#8030

Open
cx-andre-pereira wants to merge 4 commits intoCheckmarx:masterfrom
cx-andre-pereira:AST-145579_FP_on_IAM_Policy_Allows_For_Data_Exfiltration
Open

fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries#8030
cx-andre-pereira wants to merge 4 commits intoCheckmarx:masterfrom
cx-andre-pereira:AST-145579_FP_on_IAM_Policy_Allows_For_Data_Exfiltration

Conversation

@cx-andre-pereira
Copy link
Copy Markdown
Contributor

@cx-andre-pereira cx-andre-pereira commented Apr 8, 2026

Closes #7960

Reason for Proposed Changes

Proposed Changes

  • Implemented the missing check, identical to similar queries : common_lib.equalsOrInArray(statement.Resource, "*"), with the exception of the Terraform's "data" resources where the target field is slightly different : common_lib.equalsOrInArray(statement.resources, "*")

  • Added negative tests to show the relevant check is being done, the new negative tests avoid triggering the query by having a sample with a "Resource" value of arn:aws:dynamodb:us-east-1:123456789012:table/Users over the permissive wildcard *.

  • Slight changes to positive tests were done to show that array search is supported for both queries:

  • I made the choice to test these only on positive tests since the only way to know the check is working for the array search is to have the query flag precisely because it managed to check that inside the array the wildcard target was included.

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review April 8, 2026 17:04
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner April 8, 2026 17:04
@cx-artur-ribeiro cx-artur-ribeiro changed the title fix(query); fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries fix(query): fix FP results on "IAM policy allows for data exfiltration" CloudFormation and Terraform queries Apr 14, 2026
Copy link
Copy Markdown
Contributor

@cx-artur-ribeiro cx-artur-ribeiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(terraform): iam_policy_allows_for_data_exfiltration is too restrictive

2 participants