-
Notifications
You must be signed in to change notification settings - Fork 638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
credential_process requires an available shell #2879
Comments
/cc @xibz |
Hi @anuraaga , |
@KaibaLopez I'm not aware of any workaround other than installing a shell into the docker image but many projects may not be able to do this, so we lose the ability to use credential process. |
Hello! I work with @xibz (who opened the issue in Something like:
and then run the container that uses the AWS SDK with Needless to say we're unhappy with this (gross) workaround, but it does work for now as an intermediary between the Go program using the AWS SDK and our Alternatively you could also write a statically linked program – in Go, C, or Rust maybe – that recognizes Both approaches feel super hacky, more like "a workaround is possible if you really want it" rather than "here's a great way to resolve the issue". Just running the credentials provider directly seems like the better long-term fix. |
@KaibaLopez I would also point out even other SDKs disagree on this point. Ruby and Python (and thus by extension the CLI) do not use the shell. However, C# does. One interesting implication is that Go will ultimately perform environment variable expansion, while other languages will not. package main
import (
"fmt"
"os"
"github.com/aws/aws-sdk-go/aws/credentials/processcreds"
)
func main() {
creds := processcreds.NewCredentials(`echo '{"Version":1,"AccessKeyId":"'"${FOO}"'","SecretAccessKey":"'"${BAR}"'"}'`)
os.Setenv("FOO", "foo")
os.Setenv("BAR", "bar")
got, err := creds.Get()
if err != nil {
panic(err)
}
// {AccessKeyID:foo SecretAccessKey:bar SessionToken: ProviderName:ProcessProvider}
fmt.Printf("%+v\n", got)
} The actual documentation for I would say that:
|
I don't believe this issue can be easily resolved, as arguably there is not limited to just Go and C#, Java, Javascript, PHP, Ruby, and C++ also rely on the shell for argument parsing and the respective environment. Any change of behavior would need to be done across all the SDKs to standardize on one set of behavior, and provide a mechanism which would designate or opt-in to the desired behavior, whatever that is determined to be. This issue is would likely be better driven by being sent to the aws-sdk tracking repository of issues as this is a cross-cutting behavior that we likely can't change in a vacuum.
Edit: Updated with more findings. |
@skmcgrail Would you be able to transfer the issue to |
see also: aws/aws-sdk-net#1845 |
Crazy hacky idea. Would publishing some public images where /bin/sh is actually not really a proper shell but a binary that runs the credential process (maybe written in go so we can target all platforms) and possibly takes some parameters. These would just be the base distroless images with this one extra file copied in and avoid an RCE attack. Pretty gross but if it gets traction it might incentivise AWS to sort out the underlying issue. Another option we're looking into is dropping a sidecar in our pods (we're in eks land) and asking for creds over http over the pod localhost. https://docs.aws.amazon.com/sdkref/latest/guide/feature-container-credentials.html Would love to hear if anyone has had any luck with this. The pod identities docs don't mention this specifically but this guide mentions pod identities 🤔 I expect that pod identities being relatively new as opposed to irsa means their docs are in need of some tlc |
@jgrigg I had the exact same hack idea several years ago as well. It works flawlessly ever since.
it runs a sidecar in our clusters using this image:
|
Confirm by changing [ ] to [x] below to ensure that it's a bug:
Describe the bug
credential_process
always executes commands in a shellhttps://github.com/aws/aws-sdk-go/blob/main/aws/credentials/processcreds/provider.go#L301
This prevents it from being usable in Docker images that don't have a shell such as
scratch
ordistroless
. There doesn't seem to be any reason that it shouldn't be possible to invoke a binary directly throughcredential_process
without a shell in such environments, for statically compiled Go binaries, those base images are fairly popular now.Omitting remaining sections since issue is obvious from the code.
The text was updated successfully, but these errors were encountered: