Skip to content

Using external credential managers for build credentials #291

Closed

Description

@xoebus

Motivation

There are so many credentials flowing through a Concourse server at the moment that it's keeping me up at night. Some of this risk can be mitigated by fetching the secrets as late as possible and using pipeline templates to insert them into the pipeline. This at least means that you'll never have the pipeline secrets stored on local workstations.

This isn't good enough.

Credentials are still stored in the Concourse database, aren't internally rotated, and do not have any audit trail as to which jobs and builds used them. Let's fix these things.

Goals

  • Build credentials are never stored on a disk (apart from in Vault where they are stored encrypted).
  • Build credentials are never stored locally when setting the pipeline using fly.
  • An audit trail of which build used a secret and when it used it should be visible.

Proposal

I don't want to have to build a secret management system. This means that we're looking to use one of the existing ones. There are a few to choose from in this regard but I'd like to go forward by using Vault. Vault seems to strike the right balance of confidence in implementation, good technical decisions, and generically usable. I'm not ruling out the ability to use a different secret store in the future. In fact, a good implementation of this proposal would allow pluggable secret stores with minimal effort.

So, what would this look like?

resources:
- name: s3-file
  type: s3
  source:
    access_key_id: {{!vault.s3-file.access_key_id}}
    secret_access_key: {{!vault.s3-file.secret_access_key}}

Here we have a snippet of pipeline configuration. Everything looks normal except the secrets on the last 2 lines. This would be a new syntactic convention that the regular templating would ignore and pass directly up to the server. When the server needed to do something that required a realized value of one of these references it would fetch it as late as possible from the server and then handle revoking it once it isn't required anymore. This means that (assuming Vault is set up correctly) each check run and each build would get a single use credential that would become invalid immediately. This is rad. 💯

The syntax shown above is not finalized but needs to have a few components:

  • vault refers to the name of the secret store from which the credential should be fetched. This would allow multiple stores per Concourse server as long as they were all named uniquely. A secret store should probably belong to a team rather than being global.
  • s3-file refers to the name of the secret inside Vault.
  • access_key_id and secret_access_key refer to the attributes on the secret.

Open Questions

  • What if the server goes down in the middle of using one of these secrets. Who revokes it?
  • How does Concourse authenticate with the secret store? Does this just move the problem?

Risks

  • Yet another thing to deploy next to Concourse in order to use the feature. This moves away from secure by default. This could be partially mitigated by making it easy for people to get started with Vault. (BOSH release, adding something to the monolithic binaries)

Activity

  1. concourse-bot commented on Feb 17, 2016

    @concourse-bot

    Hi there!

    We use Pivotal Tracker to provide visibility into what our team is working on. A story for this issue has been automatically created.

    The current status is as follows:

    • #141798327 I can configure a CredHub backend for my team
    • #126871499 I can configure a Vault backend for my team
    • #127009961 When the same property is referenced multiple times, it should only be fetched once
    • #140235551 Using Vault for Build Credentials

    This comment, as well as the labels on the issue, will be automatically updated as the status in Tracker changes.

  2. cppforlife commented on Mar 1, 2016

    @cppforlife

    one thing to think about is pipeline scoped creds e.g. two pipelines with same config but different creds. (same problem exists for similar style of creds in bosh where each deployment may need different scope of creds).

  3. zachgersh commented on Apr 11, 2016

    @zachgersh
    Contributor

    Hey @xoebus I've been thinking about this question:

    How does Concourse authenticate with the secret store? Does this just move the problem?

    Why doesn't fly handle unsealing / sealing the secret store? Each ATC could also be provided with a read-only token to the secret store. The secret store could be resealed and the token could be set to expire after a reasonable time period (don't know whether the ATC handles these things). Even though you've "moved the problem" you still have made the pipelines more secure by default.

  4. robdimsdale commented on Apr 11, 2016

    @robdimsdale
    Contributor

    @zachgersh if the ATC can't renew its token automatically it could potentially be a poor user experience: "my builds all stopped working after a month". If it can renew its token, how much more secure is it? I think I agree with you that it's probably more secure, but it doesn't feel like the final answer in security to me.

  5. eddiewebb commented on Jun 15, 2016

    @eddiewebb

    thanks for starting this conversation! I love the potential that concourse brings, but it's not viable in our environment until we address the encryption and management of secrets.

    @cppforlife - agree on need for pipeline scoped credentials. Seems plausible to align to vaults tree concept.

    @xoebus - is the revocation risk not addressable with reasonable lease windows in vault? I would prefer to trust a lease to destroy cred than a final type task in pipeline.

  6. holstvoogd commented on Jun 21, 2016

    @holstvoogd

    I have been thinking about how this could be set up with the App ID auth backend. I would say each worker should have an unique User ID and each Pipeline should have an unique App ID. Builds get access to secrets based on their App ID and User ID, so they would be scope-able per pipeline and it ensures only known workers are used.

    This all would require some manual configuration whenever you add a new pipeline and/or worker. But I guess that is kind of the point of ensuring it is secure: all secrets are managed out of band in vault as well as the access to it.

    I've considered some setups where ATC manages App & User IDs for you, but this just seems to break the security model of vault and it becomes very complicated fast ;-)

  7. eddiewebb commented on Jun 27, 2016

    @eddiewebb

    ANyone know how Stark & Wayne's planned summit topic relates?
    https://cfsummit2016.sched.org/event/6Zld/air-marshal-no-more-secrets-in-your-manifests-michael-brodhead-stark-wayne

    Enter Air Marshal. Air Marshal acts as a proxy between staff workstations and BOSH or Concourse. Manifests checked into source control have placeholders wherever secrets are necessary. Air Marshal reads secrets from a secure back-end, adding them to manifests where needed.

    CC: @mkb

  8. xoebus commented on Jun 27, 2016

    @xoebus
    ContributorAuthor

    It's an interesting, pragmatic, and novel solution but doesn't solve the core problem of the credentials being stored in plain text in the system.

  9. eddiewebb commented on Jun 27, 2016

    @eddiewebb

    Yeah, i agree @xoebus,
    I reviewed the video with my team today, might be suitable for some use cases, but not the enterprise ready solution that moves away from assuming such frequent human access over CLI.

    We'd like a system (or user) to configure the pipeline independent of cipher values, which should be decrypted at time of use, not time of configuration. This is important to allow key rotation and the like.

    So any solution that depends on fly interaction to replace values in manifest is not viable.

  10. freelock commented on Jun 27, 2016

    @freelock
    Contributor

    I've come up with a similar solution -- I have a bot in a Matrix chat room that listens for git commits, and when it sees them, it uses fly to update the pipeline to the latest version. The bot has access to the secrets, regular users don't. So this allows our regular users that the bot authorizes to update the pipeline without having access to the secrets.

    I'm still interested in how secrets may be stored in the ATC, though, especially as we add clients that may have more governance issues to address than we currently have, and might need to have different sets of secrets for different clients/pipelines.

  11. eddiewebb commented on Jul 8, 2016

    @eddiewebb

    The use of variables is one area that has pretty wide impact. Validation in fly cli for instance doesn't like {{!secret}} and using {{secret}} requires vars provided at config time.

    So do we want to invade fly and other points to tolerate a new format, or find something that flies under the radar of yaml validation, or more simply use a hack of forcing quotes of an alternate format

    resources:
    - name: s3-file
      type: s3
      source:
        access_key_id: "{{!vault.s3-file.access_key_id}}"
        secret_access_key: "{{!vault.s3-file.secret_access_key}}"
    

    Playing a bit all components support that pattern without validation or configuration errors.

    That also lets the altered manifest go unnoticed by all existing systems, and would let us focus enhancements in ATC as the place to trade out properties for actual values (I think -- ATC is aware of pipeline config, assigns workers, and could grant and revoke secrets based on lifecycle of workers.).

    I'm still learning/exploring concourse architecture, would love feedback on those thoughts.

  12. 137 remaining items

  13. vito commented on Jun 26, 2017

    @vito
    Contributor

    Slight change from before: we went ahead and just made the auth fully generic. So you specify --vault-auth-backend and --vault-auth-param.

    For example, to use TLS auth, you'd just say --vault-auth-backend cert (or whatever you named your cert auth backend mount) and specify a client cert/key. To configure approle you'd do something like --vault-auth-backend approle --vault-auth-param role_id=db02de05-fa39-4855-059b-67221c5c2f63 --vault-auth-param secret_id=6a174c20-f6de-a53c-74d2-6018fcceff64.

    We also now test cert, approle, and direct token configurations, and also test that they're renewed by the ATC automatically (using a periodic token for direct token configuration).

    Next step is to try dogfooding again now that we've got the auth flow fleshed out.

  14. added a commit that references this issue on Jun 26, 2017
  15. vito commented on Jun 27, 2017

    @vito
    Contributor

    I've converted all our pipelines over to Vault, and all is going well so far. I wrote a little tool to make the migration easier.

  16. vito commented on Jun 28, 2017

    @vito
    Contributor

    Looks good so far; calling this done as of now! The remaining bits of work will be modeled as separate issues.

  17. rkoster commented on Jul 6, 2017

    @rkoster
    Contributor

    @vito what is the timeline for credhub support?

  18. added a commit that references this issue on Jul 17, 2018
  19. SleeperSmith commented on Aug 6, 2019

    @SleeperSmith

    Hi Guys. Tinkering around with Concourse.

    I am running concourse workers on ECS and ECS Task Role doesn't seem to be working. From concourse/docker-image-resource#109 it seems that the preference is to explicitly define the credential is it?

    • When executing docker-image push to ecr, it seems to be picking up the EC2 IAM role. This should be disabled if the design goal is to be explicit?
    • Perhaps model the IAM task role permission as a provider and allow it to be used upon explicit reference? The permission is attached to the deployment of worker "groups" (as a service on ECS) so perhaps make it a requirement to specify worker requirement alone with the configuration?

    I just find it odd the worker can access the ec2 task role while not the ecs task role.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions