Are Heroku's environmental variables a secure way to store sensitive data?

heroku, ruby, ruby-on-rails

Solution

Several things (mostly my opinion):

--

1. API Key != Password

When you talk about `API Keys`, you're talking about a public token which is generally already very secure. The nature of API's nowadays is they need some sort of prior authentication (either at app or user level) to create a more robust level of security.

I would firstly ensure what type of data you're storing in the `ENV` variables. If it's pure passwords (for email etc), perhaps consider migrating your setup to one of the cloud providers (`SendGrid` / `Mandrill` etc), allowing you to use only API keys

The beauty of API keys is they can be changed whilst not affecting the base account, as well as limiting interactivity to the constrains of the API. Passwords affect the base account

--

2. ENV Vars are OS-level

They are part of the operating environment in which a process runs. For example, a running process can query the value of the TEMP environment variable to discover a suitable location to store temporary files, or the HOME or USERPROFILE variable to find the directory structure owned by the user running the process.

You must remember Environment Variables basically mean you store the data in the `environment` you're operating. The generally means the "OS", but can be the virtual instance of an OS too, if required.

The bottom line is your ENV vars are present in the core of your server. The same way as text files would be sitting in a directory on the hard drive - Environment Variables reside in the core of the OS

Unless you received a hack to the server itself, it would be very difficult to get the ENV variable data pro-grammatically, at least in my experience.

Problem

I use Heroku to deploy a Rails app. I store sensitive data such as API keys and passwords in Heroku's environment variables, and then use the data in rake tasks that utilize various APIs. I am just wondering how secure Heroku's environmental variables are? Is there a way to hash these variables while retaining the ability to use them in the background somehow? I came across a previous thread here: Is it secure to store passwords as environment variables (rather than as plain text) in config files?. But it doesn't quite cover instances when I still need to unhashed password to perform important background tasks.

Original source

Related problems