Skip to content

Improvements to secrets support #4366

Closed

Description

@samalba

This serves as an index for all the issues related to secrets. If someone takes ownership on this issue, this should start by triaging the issues list below, corresponding to a proposal to add support for secrets.

What is supported

As of Dagger Engine 0.4.3, a secret can be...

What is currently not supported

As of Dagger Engine 0.4.3, the following limitations or problems exist:

### Tasks
- [ ] #4413 
- [ ] #4426 
- [ ] #4289
- [ ] #3323
- [ ] https://github.com/dagger/dagger/issues/4403
- [ ] https://github.com/dagger/dagger/issues/4339
- [ ] https://github.com/dagger/dagger/issues/4864
- [ ] https://github.com/dagger/dagger/issues/4896

Activity

  1. shykes commented on Jan 13, 2023

    @shykes
    Contributor
    • 0.3 does not support secret creation from a container

    I think this is wrong, that is supported with file { secret }.

    Here's an example: https://play.dagger.cloud/playground/s13eReSxuy-

  2. aluzzardi commented on Jan 14, 2023

    @aluzzardi
    Contributor

    Correct — creating a secret from a container is supported, but leaks the secret in the container image and cache.

    Also, not supported is creating a secret in code (#3442)

  3. samalba commented on Jan 17, 2023

    @samalba
    ContributorAuthor

    My bad, I did not know that was possible already. However, as @aluzzardi pointed out this isn't secure, not sure we should keep the support. I corrected the description above.

    When I mount a secret to a container, this is safe as it won't end up in my logs or cache layers. As user, I would expect this to be true for a secret created from a container, without having to deal with the underlying complexity.

  4. shykes commented on Jan 18, 2023

    @shykes
    Contributor

    My bad, I did not know that was possible already. However, as @aluzzardi pointed out this isn't secure, not sure we should keep the support. I corrected the description above.

    When I mount a secret to a container, this is safe as it won't end up in my logs or cache layers. As user, I would expect this to be true for a secret created from a container, without having to deal with the underlying complexity.

    I agree, IMO we should at least discuss how to fix the security issue. Here's my earlier comment about this: #4339 (comment)

  5. sagikazarmark commented on Jan 18, 2023

    @sagikazarmark
    Contributor

    Just to clarify: creating a secret from a container is what's "unsafe" at the moment, right?

    Creating a secret from an env var or even by talking to directly to Vault to fetch the secret value and then passing that in the container as an env var should be "safe" (ie. won't be stored anywhere unencrypted), right?

  6. shykes commented on Jan 18, 2023

    @shykes
    Contributor

    Just to clarify: creating a secret from a container is what's "unsafe" at the moment, right?

    Creating a secret from an env var or even by talking to directly to Vault to fetch the secret value and then passing that in the container as an env var should be "safe" (ie. won't be stored anywhere unencrypted), right?

    @sagikazarmark, the following methods are considered safe:

    • Load a secret from an environment variable on the host. Here's an example. NOTE: only variables set before opening the Dagger session are available in this way.
    • Injecting a secret into a container as an environment variable, using the withSecretVariable operation. Here's an example
    • Injecting a secret into a container as a file. Here's an example.

    The big inconvenience at the moment, is that the env var method is not dynamic: you can only access env variables that were set at the time the dagger session was open. In your case for example, you must talk to Vault, and export your secrets as environment variables before opening the dagger session.

    TLDR: there are safe ways to load secrets into Dagger, but they are not dynamic.

  7. sagikazarmark commented on Jan 18, 2023

    @sagikazarmark
    Contributor

    Let's see if I got this right: if I want to use a secret from a secret store, I have to fetch that secret before I call dagger.Connect (in Go) and set it as an environment variable manually (regardless if I want to access it as an env var or a file in the container).

    Is that correct?

  8. jlongtine commented on Jan 18, 2023

    @jlongtine
    Contributor

    Let's see if I got this right: if I want to use a secret from a secret store, I have to fetch that secret before I call dagger.Connect (in Go) and set it as an environment variable manually (regardless if I want to access it as an env var or a file in the container).

    Is that correct?

    Yes, this is correct. At least for our current setup. The intent is to change that soon, so more dynamic secrets are possible.

  9. shykes commented on Jan 18, 2023

    @shykes
    Contributor

    FYI I created an individual issue for the cache leak problem: #4403

    Fixing that would be the shortest path to safe, dynamic secrets creation. But we don't know (yet) how difficult it would be to implement.

  10. marcindulak commented on Jan 18, 2023

    @marcindulak

    Just to clarify: creating a secret from a container is what's "unsafe" at the moment, right?

    Creating a secret from an env var or even by talking to directly to Vault to fetch the secret value and then passing that in the container as an env var should be "safe" (ie. won't be stored anywhere unencrypted), right?

    I see the examples from #4366 (comment) are in GraphQL, but in practical terms, aren't the secrets from environment variables in a container stored also unencrypted in /proc/<pid>/environ?

    docker run --rm -e SECRET=TEST --name bash bash bash -c "cat /proc/1/environ | grep SECRET"
  11. 9 remaining items

  12. marcosnils commented on Jan 19, 2023

    @marcosnils
    Contributor

    I think one extra tricky part will be the need to handle the case where a secret env var is referenced inside of an ID

    🤔 but in order to get the SecretID from the env var you needed to call withSecretVariable in the first place? How could a user craft a request with a secret env var without calling the SDK withSecretVariable in the query build chain?

  13. sipsma commented on Jan 19, 2023

    @sipsma
    Contributor

    🤔 but in order to get the SecretID from the env var you needed to call withSecretVariable in the first place? How could a user craft a request with a secret env var without calling the SDK withSecretVariable in the query build chain?

    Right, the corner cases that remain are:

    1. Technically, users can use IDs between sessions. They really shouldn't in theory but we actually do this in our docs sometimes so it's sort of a "that ship has sailed" situation. We'd have to decide whether we care about this gotcha or not.
    2. If the env var changes at any point it won't get re-loaded with the new value. I don't think this is a very common use case at all, but it would be another gotcha lurking.

    Those aren't necessarily dealbreakers, but it does seem like we'd have to do a fair bit (setup sdk codegen hooks, setup a separate api in the session binary for updating the env vars) and then at the end we'd just get the ability to update env vars after dagger.Connect but with a bunch of caveats. I'm not sure if it's worth it relative to the other options available.

  14. marcosnils commented on Jan 19, 2023

    @marcosnils
    Contributor

    Right, the corner cases that remain are:

    1. Technically, users can use IDs between sessions. They really shouldn't in theory but we actually do this in our docs sometimes so it's sort of a "that ship has sailed" situation. We'd have to decide whether we care about this gotcha or not.
    2. If the env var changes at any point it won't get re-loaded with the new value. I don't think this is a very common use case at all, but it would be another gotcha lurking.

    Agree, I briefly thought about those and kind of ignored them since as you mentioned, they're kind of "exceptional" cases.

    and then at the end we'd just get the ability to update env vars after dagger.Connect but with a bunch of caveats.

    Also agree, I just thought it is a cheaper way to support dynamic secrets until we have the secrets store solution. Doing something like this (https://discord.com/channels/707636530424053791/1003718839739105300/1062063056626143242) would be very useful IMO.

  15. d3rp3tt3 commented on Jan 24, 2023

    @d3rp3tt3
    Contributor

    Out of this list, the security issue is the most pressing to address: #4366

    Edit - @samalba caught this. I meant #4339 and #4413.

  16. samalba commented on Jan 24, 2023

    @samalba
    ContributorAuthor

    Out of this list, the security issue is the most pressing to address: #4366.

    Did you mean #4339?

  17. d3rp3tt3 commented on Jan 25, 2023

    @d3rp3tt3
    Contributor

    Yes! I meant #4339 and #4413.

  18. d3rp3tt3 commented on Mar 1, 2023

    @d3rp3tt3
    Contributor

    @samalba , I updated the original summary to use a task list, so it's easier for us to track.

  19. mircubed commented on May 4, 2023

    @mircubed
    Contributor

    Thank you to everyone who provided input for these improvements and to @dolanor for all the work! You can read about the improvements here - https://dagger.io/blog/dagger-0-5-0

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/enginekind/user-request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions