Securing Jenkins when using AWS

This article shows how to protect AWS credentials in Jenkins using the Credentials Binding plugin to map secrets safely into standard environment variables. It also includes a practical shell tip for suppressing command echo output so sensitive values are not leaked in job logs.

Coveros Staff

May 15, 2015

Dear Loyal Readers,

Security, like safety, almost always makes your life harder. It is inefficient.  Now, as I said before, for scripting and organizing project operations and today I’d like to talk about a security feature that can help you have your cake and eat it too.

The challenge for us is that Jenkins must function, while not revealing to anyone but a select few exactly how it accomplishes its missions. That is, I want to authorize someone to click the button, but not get the root password from the console output.

Enter the credentials binding plugin:

blog_jenkins_credplugin

This plugin lets you map secrets to environment variables or secret files to a path available via environment variable.  For using AWS we’ll make two secret, one for the Access Key ID, and one for the Secret Access Key.

blog_jenkins_cred_accesskey

 

Finally, we can directly map these secrets to the standard AWS sdk environment variables.

And there it is! Simple, and secure; what more can one ask for?

BONUS TIP

You can silence Jenkins echoing (which sometimes might write secret things to the console output like this:

set +x
echo “About to execute ./set_password -u my_user -p ******”
./set_password -u my_user -p $PASSWORD
set -x

Coveros Staff

Coveros Staff

This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.