Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

False Positive: AWS Access Key for aws:cdk:path #559

Closed
AjkayAlan opened this issue May 27, 2022 · 2 comments · Fixed by #571
Closed

False Positive: AWS Access Key for aws:cdk:path #559

AjkayAlan opened this issue May 27, 2022 · 2 comments · Fixed by #571
Labels
enhancement The issue is related to improving a certain aspect of the project. false positives P4 Future work. E.g. something we might to get on in the future. Might be used for future ideas too. selected The issue has been selected to be worked on.

Comments

@AjkayAlan
Copy link

Background

I have been using detect-secrets and absolutely love it! Particularly, I use it via checkov, which scans AWS CloudFormation templates (among other things). I am using the AWS CDK to generate my CloudFormation, which adds some metadata

The Problem

Some CDK metadata in CloudFormation can trigger a false positive on AWSKeyDetector. The offending regex is at

re.compile(r'aws.{0,20}?[\'\"]([0-9a-zA-Z/+]{40})[\'\"]'),

Two examples I have that were from valid generated CloudFormation (from cdk) are:

  • "aws:cdk:path": "VaDataVaultCdkPoc/rBucketKeyCdk/Resource"
  • "aws:cdk:path": "AuroraRdsStack/DbCluster/Subnets/Default"

The Solution

I am not quite sure - in part that I don't have all the context behind the validity of this regex when it was originally introduced/sourced from a third party.

Final Thoughts

I am willing to make a contribution if someone has a good idea on how to change this to be effective, but still not alert on the scenarios I have put above. Otherwise if someone has a good idea, go for it!

@lorenzodb1
Copy link
Member

Hi @AjkayAlan! Thank you for your kind words and for reporting this issue. I believe one solution could be to change the regex to look for specific keywords on the left-hand side of the value-assignment statement (such as key, I think we already do this in other plugins). This should avoid that metadata to be flagged as sensitive.

@jpdakran do you have any thoughts about this?

@jpdakran jpdakran added pending The issue still needs to be reviewed by one of the maintainers. enhancement The issue is related to improving a certain aspect of the project. false positives P4 Future work. E.g. something we might to get on in the future. Might be used for future ideas too. triaged The issue has been reviewed but has not been solved yet. and removed pending The issue still needs to be reviewed by one of the maintainers. labels Jun 15, 2022
@jpdakran
Copy link
Member

Yes this seems like a good candidate for a regex refactor. Let me see what I can come up with.

@jpdakran jpdakran added selected The issue has been selected to be worked on. and removed triaged The issue has been reviewed but has not been solved yet. labels Jun 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement The issue is related to improving a certain aspect of the project. false positives P4 Future work. E.g. something we might to get on in the future. Might be used for future ideas too. selected The issue has been selected to be worked on.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants