Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

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/Resource fields of a valid IAM policy resource or the actions/resources fields of a aws_iam_policy_document data both have the * permission; with this implementation it dismisses instances of Resource/resources with the expected * permission and Action/actions fields 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 a is_full_priviledge_permission function 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 searchLine values to be problematic , sometimes resulting in -1 ; to fix this the policy that handles aws_iam_policy_document data had to be adjusted to better handle arrays vs single instances of statement(s) inside the data. Currently this handling is poor and the searchLine/keyExpectedValue/keyActualValue/searchKey values are all incorrectly referencing "policy" instead of the aws_iam_policy_document equivalent (statements) resulting in the wrongsearchLine/Key values.

  • With the better case handling the correct relevant statement will now be indicated if there are multiple statements , the searchLine/searchKey values are now valid and more precise when there is an array of statement; previously the result would point to the aws_iam_policy_document the statements belonged to instead of the relevant statement.

I submit this contribution under the Apache-2.0 license.

@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner July 29, 2025 13:00
@github-actions github-actions bot added query New query feature terraform Terraform query aws PR related with AWS Cloud labels Jul 29, 2025
@github-actions
Copy link
Contributor

kics-logo

KICS version: v2.1.11

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

Copy link
Contributor

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Choose a reason for hiding this comment

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

LGTM

@gitguardian
Copy link

gitguardian bot commented Aug 14, 2025

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
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
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. 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


🦉 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.

@cx-artur-ribeiro cx-artur-ribeiro merged commit 5aa1163 into master Aug 14, 2025
26 checks passed
@cx-artur-ribeiro cx-artur-ribeiro deleted the AST-40772--FN-IAM_Policies_With_Full_Privileges--terraform/aws branch August 14, 2025 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws PR related with AWS Cloud query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants