In the processes of setting up continuous deployment for an open source project with Travis I came across a predicament, can the encrypted private key be easily exfilitrated? For context, the deployment workflow is:

  1. In a Travis build job, build and test code
  2. If it passes, deploy the code
  3. Decrypt the encrypted private SSH key and start the SSH client
  4. Push to the Git remote on the production server

Using travis encrypt-file deploy_rsa --add, the private key is encrypted and only decryptable within the Travis build job. Am I correct in the assumption that someone forking the repo and creating a Travis build job will not be able to decrypt the key? In addition, the only attack vector would be for someone with push rights to modify the .travis-ci script to decrypt the key and send it to themselves?

  • 1
    Fork, add a dump of the key somewhere in the build, make a pull request, if pull requests are built the key will be shown in the public build log of Travis...
    – Tensibai
    Commented Feb 17, 2018 at 19:28
  • 1
    This is not the case, at least for Travis docs.travis-ci.com/user/pull-requests/…
    – Moritz
    Commented Feb 17, 2018 at 22:16
  • So you have your answer :) (but the Travis-ci file is still not the only attack vector for someone allowed to push)
    – Tensibai
    Commented Feb 18, 2018 at 8:29
  • What else should I consider?
    – Moritz
    Commented Feb 18, 2018 at 15:29
  • Whatever build system is used, scripts, even the code could exfil datas during unit tests, usually that's not a real concern on open source projects and/or build and deploy are separated. Some quality test of code (sonar/checkmark) can test for suspicious patterns also
    – Tensibai
    Commented Feb 18, 2018 at 16:42

1 Answer 1


You essentially have three threats here:

  1. Someone could modify .travis-ci and use that to exfiltrate the unencrypted key material.
  2. You could accidentally check-in or publish the decrypted key material as part of your release process.
  3. Someone could attempt to attack the encrypted key-material directly; this is very unlikely given modern practice and current computing power.

The challenge of secret management is common in open source projects; one approach I have taken in the past is to have a second "deploy" stage in a private repository and pipeline. A private repository and pipeline, then ring-fences the sensitive data from malicious actors entirely, protecting yourself from 1 and 3. You can safeguard against two by whitelisting files that can be checked in to decrease the probability of making a mistake.

Finally, an approach that can be used to increase the detectability of an attack is to store the key in AWS CloudHSM, Google Cloud HSM or Azure KeyVault with the goal of marking the private key as non-exportable and then handing off any encrypt, wrap or sign requests to the cloud. This means even if the credentials for the HSM/KeyVault do get exfiltrated you know every time they are used to sign something and can effectively revoke access to the key entirely. Unfortunately, there doesn't seem to be any way of doing this with SSH keys at the moment, however, it works will with code-signing certificates.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.