fix(query): fn for IAM_Policies_With_Full_Privileges -- terraform/aws#7601
Merged
cx-artur-ribeiro merged 2 commits intoAug 14, 2025
Conversation
Contributor
…leges--terraform/aws
|
| GitGuardian id | GitGuardian status | Secret | Commit | Filename | |
|---|---|---|---|---|---|
| 4266022 | Triggered | Generic Password | e424d49 | assets/queries/cloudFormation/aws/amplify_branch_basic_auth_config_password_exposed/test/negative7.yaml | View secret |
| 9419039 | Triggered | Username Password | e424d49 | assets/queries/cloudFormation/aws/amplify_app_basic_auth_config_password_exposed/test/positive6.json | View secret |
🛠 Guidelines to remediate hardcoded secrets
- Understand the implications of revoking this secret by investigating where it is used in your code.
- Replace and store your secrets safely. Learn here the best practices.
- Revoke and rotate these secrets.
- If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.
To avoid such incidents in the future consider
- following these best practices for managing and storing secrets including API keys and other credentials
- install secret detection on pre-commit to catch secret before it leaves your machine and ease remediation.
🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.
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.








Reason for Proposed Changes
This query flags for samples when IAM policies are allowed full administrative privileges; however , it will only flag this result if the
Action/Resourcefields of a valid IAM policy resource or theactions/resourcesfields of aaws_iam_policy_documentdata both have the*permission; with this implementation it dismisses instances ofResource/resourceswith the expected * permission andAction/actionsfields that include"iam:*"permissions, and those results should also be flagged.The granted permission (
iam:*) allows for the creation/edition/deletion of policies, so it ends up being equivalent to*. (aws_guide page 1665/4071 - "to allow users to perform any IAM action, you can use iam:*")Proposed Changes
To flag for both relevant instances (
*/iam:*), i added ais_full_priviledge_permissionfunction to replace the simple check for*, allowing either permission type to result in a true evaluation for the policy.When analyzing the query i found the
searchLinevalues to be problematic , sometimes resulting in -1 ; to fix this the policy that handlesaws_iam_policy_documentdata had to be adjusted to better handle arrays vs single instances of statement(s) inside the data. Currently this handling is poor and thesearchLine/keyExpectedValue/keyActualValue/searchKeyvalues are all incorrectly referencing "policy" instead of theaws_iam_policy_documentequivalent (statements) resulting in the wrongsearchLine/Keyvalues.With the better case handling the correct relevant statement will now be indicated if there are multiple statements , the
searchLine/searchKeyvalues are now valid and more precise when there is an array of statement; previously the result would point to theaws_iam_policy_documentthe statements belonged to instead of the relevant statement.I submit this contribution under the Apache-2.0 license.