How can I avoid clear text passwords when using curl?

I want to avoid using a clear text password in my deployment project.

I have several interactions with the application server via curl.  I created a service account on the app server and need to provide the password via http basic authentication. 

So my script task in the bamboo deployment project calls curl -u and includes a variable containing the service account user:pass.

However, the service account password is visible to anyone who has access to the variables configuration screen on the environment. I want to make sure someone with root access to the bamboo server, admin access in bamboo, and full access to the code cannot retrieve this service account password.

Do I have any options to prevent any access to the service account password? 

3 answers

1 accepted

0 vote

 I want to make sure someone with root access to the bamboo server, admin access in bamboo, and full access to the code cannot retrieve this service account password.

These are pretty strong requirements. With these, you obviously cannot store the password on the bamboo server, so they must reside on the agent.
What you should do is you should use curl with a .netrc file that will store the password. The important step is to make the file unreadable to the bamboo agent user. So, assuming your bamboo agent user is, say bamboo_agent, create a new user called e.g. appdeployment.
Secure your .netrc file like this:
sudo chown appdeployment /SECURE_LOCATION/.netrc
sudo chmod 600 /SECURE_LOCATION/.netrc
Make sure the bamboo agent cannot read that netrc file.
Then either make sure your agent can run curl as appdeployment user (via sudo) or (which may be easier, but more fragile) create a suid (not suid root!) binary of curl and use it instead of curl:
cp /usr/bin/curl /SECURE_LOCATION/suidcurl
sudo chown appdeployment /SECURE_LOCATION/suidcurl
sudo chmod u+s /SECURE_LOCATION/suidcurl

 

Oh, and either dedicate that agent to that deployment or add an agent capability password_to_my_app and require that capability in your deployment.

Thanks for your help!

 

You can use global, or environment variables.  If they have 'PASSWORD' in the name, they will be obfuscated when they appear in the log.

 

-Rich

0 vote

Hello @Evan Stevens,

As Rich mentioned if your variable has 'password' in the name it will be obfuscated in UI and build/deployment logs.

But there's workaround that user can create script task with

echo $password_var > text.txt

and publish artifact with this file, then you should define that variable at deployment environment level and restrict access to that environment. It will not save you from administrator user.

Unfortunately it will not save against user with direct access to DB. In Bamboo 5.15 we added functionality to encrypt secret variables in DB to prevent unauthorized access to variables, repository credentials and shared credentials.

We are going to release Bamboo 5.15 within few weeks

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Renan Battaglin
Published May 18, 2017 in Bamboo

FAQ: How to Upgrade Bamboo Server

Bamboo 5.9 will no longer be supported after June 12, 2017. What does this mean? As part of our End of Life policy, Atlassian supports major versions for two years after the first major iteratio...

1,319 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you