withAWS() puts secret key into Jenkins log file if env vars are printed...
See original GitHub issueDescription
Secret key is readable in the Jenkins pipeline log file.
Steps to Reproduce
- In your pipeline use withAWS in option block of declarative pipeline:
def AWS_ROLE = "arn:aws:iam::321724181329:role/QEAutomation" // AWS role used to create EC2 infrastructure (instances, DNS entries...)
def AWS_ID = "AwsDspDevAutoAccount" // ID of Jenkins credentials that safely stores AWS keys
def AWS_REGION = "us-east-1" // Region to create EC2 infrastructure in
withAWS(region: AWS_REGION, role: AWS_ROLE, credentials: AWS_ID)
- Print env vars (in this instance on windows):
echo "ENVIRONMENT VARIABLES FOR THIS BUILD:" echo "set"
Expected behavior: AWS secret access keys should be scrubbed from log (****) like username and passwords pulled out of withCredentials()
Actual behavior: [What actually happened] AWS key, secret and session token are visible in log file:
AWS_ACCESS_KEY_ID=ASIAU11111111GH7B
AWS_DEFAULT_REGION=us-east-1
AWS_REGION=us-east-1
AWS_SECRET_ACCESS_KEY=1111++5bT/WEVfD
AWS_SESSION_TOKEN=11111wEaDLzAu+u2D/gC5pAsiCL8ASAxtPdkR+ouQHwAD4B/3SV0miFuWT1ENRgEmj/PBz3AYz6E1RW3OgeSFo9qVgermFiqSab2O7vMWTei3G7mmo+/m2O9uoMgFHpgVVkCceco+PlolpAcRBKtSWVunL7XDfhhIV9zaC+CiZqxuS2VizsVT0JulTcBZaljHMLX1Mrrv7i7EB5e9e/3Psl34o/vmi0rkm1m49bqn3YP0la6WdoOrBBH6tyuN68dCuMsLxwT8j1Q0ANZktQONURauPUTYopw2g7ch2/jRuO46v46GGf8E9fQOjunaLFpTfavKjIjE+fOvU3BH2GT/1111111111111111111111111==
Issue Analytics
- State:
- Created 5 years ago
- Reactions:9
- Comments:9 (3 by maintainers)
I have 2 issues with this plugin:
AWS_SESSION_TOKEN
when the role is set in the credentialsBoth are solved by using
withCredentials
as suggested by @mattemooreFor example, I have a credentials created by doing:
my-example-creds
Then trying to use this plugin I have something like:
Which prints out:
And then the
get-caller-identity
call fails with the following error becauseAWS_SESSION_TOKEN
was not set.Contrast that with running this:
Which outputs:
Note that it is masked and
AWS_SESSION_TOKEN
is defined.Then also the
get-caller-identity
call succeeds:withAws(credentials: 'my-example-creds')
is far more expressive and readable thanwithCredentials([[$class: 'AmazonWebServicesCredentialsBinding', credentialsId: 'my-example-creds']])
so it’d be really nice if under the hood they did the same thing.Maybe there is a way that if you get a call to
withAws
that only provides acredentials
param, that is somehow passed off towithCredentials
for handling?This is the plugin that provides the
AWS Credentials
option when creating credentials: https://github.com/jenkinsci/aws-credentials-pluginThis is the plugin that provides the
withCredentials
step and does the masking: https://github.com/jenkinsci/credentials-binding-pluginFor declarative pipeline, initialize AWS credentials in the environment block. It is pretty concise,
The
environment
block syntax requires the actual assignment of creds to a variable, henceNOOP_CREDS_VAR
On aside note. This issue is a glaring security hole and prevents the plugin adoption