You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
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)
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?
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
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.
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).
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.
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?
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?
🤔 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:
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.
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.
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.
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.
Activity
shykes commentedon Jan 13, 2023
I think this is wrong, that is supported with
file { secret }.Here's an example: https://play.dagger.cloud/playground/s13eReSxuy-
aluzzardi commentedon Jan 14, 2023
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)
samalba commentedon Jan 17, 2023
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.
shykes commentedon Jan 18, 2023
I agree, IMO we should at least discuss how to fix the security issue. Here's my earlier comment about this: #4339 (comment)
sagikazarmark commentedon Jan 18, 2023
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?
shykes commentedon Jan 18, 2023
@sagikazarmark, the following methods are considered safe:
withSecretVariableoperation. Here's an exampleThe 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.
sagikazarmark commentedon Jan 18, 2023
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?
jlongtine commentedon Jan 18, 2023
Yes, this is correct. At least for our current setup. The intent is to change that soon, so more dynamic secrets are possible.
shykes commentedon Jan 18, 2023
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.
marcindulak commentedon Jan 18, 2023
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"9 remaining items
marcosnils commentedon Jan 19, 2023
🤔 but in order to get the
SecretIDfrom the env var you needed to callwithSecretVariablein the first place? How could a user craft a request with a secret env var without calling the SDKwithSecretVariablein the query build chain?sipsma commentedon Jan 19, 2023
Right, the corner cases that remain are:
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.Connectbut with a bunch of caveats. I'm not sure if it's worth it relative to the other options available.marcosnils commentedon Jan 19, 2023
Agree, I briefly thought about those and kind of ignored them since as you mentioned, they're kind of "exceptional" cases.
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.
d3rp3tt3 commentedon Jan 24, 2023
Out of this list, the security issue is the most pressing to address: #4366Edit - @samalba caught this. I meant #4339 and #4413.
samalba commentedon Jan 24, 2023
Did you mean #4339?
d3rp3tt3 commentedon Jan 25, 2023
Yes! I meant #4339 and #4413.
d3rp3tt3 commentedon Mar 1, 2023
@samalba , I updated the original summary to use a task list, so it's easier for us to track.
mircubed commentedon May 4, 2023
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