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

Terraform: Flag embededded access key and secret key as insecure #6228

Open
pcgeek86 opened this issue Mar 13, 2023 · 4 comments
Open

Terraform: Flag embededded access key and secret key as insecure #6228

pcgeek86 opened this issue Mar 13, 2023 · 4 comments
Labels
community Community contribution feature request Community: new feature request

Comments

@pcgeek86
Copy link

Is your feature request related to a problem? Please describe.

Terraform projects generally should not hard-code credentials (AWS IAM Access Key, Secret Key) into the Terraform provider configuration. During my testing, KICS didn't flag this.

  • If the provider "aws" block is detected, then ....
  • The access_key property should not be present
  • The secret_key property should not be present

image

@pcgeek86 pcgeek86 added community Community contribution feature request Community: new feature request labels Mar 13, 2023
@kaplanlior
Copy link
Contributor

Thanks Trevor for the report.

Do you want to try and create a query to catch this case?
https://docs.kics.io/latest/creating-queries/

We'll be happy to help if you're up to the challenge (:

@pcgeek86
Copy link
Author

I'll have to see what level of effort is required to contribute that query! Just wanted to get it documented for starters. :)

@FooBartn
Copy link

I'll have to see what level of effort is required to contribute that query! Just wanted to get it documented for starters. :)

There is a secrets query that would catch this in a different way. It goes off of specific formatting. Your example access key and secret do not look like real ones. Just a note in case that would work for you

@pcgeek86
Copy link
Author

Yeah, I know they aren't real access key and secret key. Posting real ones wouldn't have been prudent.

Also keep in mind that you might not necessarily find "real" values hard-coded in these templates. You might also find insecure references to variables, such as var.aws_key_id or var.aws_secret_key. In that scenario, a secrets detector wouldn't be adequate.

The AWS provider for Terraform accepts environment variables as inputs, so you don't need to specify these credential values in the provider block at all.

I wouldn't only consider this a "critical" level issue if someone did indeed hard-code credentials. Specifying variable references could still be a "warning" level or similar, and recommend using environment variables. There's not really a right or wrong way, just suggestions to help developers understand their options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Community contribution feature request Community: new feature request
Projects
None yet
Development

No branches or pull requests

3 participants