-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix(provider-codegen): prevent env var secrets from leaking into generated docs #4658
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
base: main
Are you sure you want to change the base?
fix(provider-codegen): prevent env var secrets from leaking into generated docs #4658
Conversation
…ing into generated docs
leseb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Severity is not that high IMO, so perhaps we should concentrate on converting to SecretStr the remaining secrets. Thanks!
|
@leseb I have opened #4681 to use I still do feel there's benefit to the static code analysis approach used in this PR (even if it feels a bit hacky). It prevents any environment variable (or redaction "********") from accidentally being committed -- these may be easy to miss in large diffs. |
Not sure, i'd rather use a dedicated pre-commit hook rather than our own script, hooks like https://github.com/awslabs/git-secrets or https://github.com/Yelp/detect-secrets should help. Bonus point, this works across the code not just doc. What do you think? |
I think that's a good call. I'll look into adding one of these to our pre-commit config. The benefit of this PR is that it ensures env vars will never be added to docs, regardless of whether they are secrets, redacted content, or less interesting things like the list below. Even with the These could all potentially end up getting added to docs -- not a big deal for most, but could cause some confusion for users if they were to get merged, and also some frustration for developers whose pre-commit docs check constantly fails and generates unwanted changes:
|
💯 this! we should not capture developer or ci environment details in the docs. |
leseb
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we reset env vars when running https://github.com/llamastack/llama-stack/blob/main/.pre-commit-config.yaml#L106? something like env -i bash?
good idea |
Summary
Fixes #4657 - security vulnerability where
provider_codegen.pyleaked AWS credentials and other secrets from environment variables into generated documentation.Changes
default_factorysource code before executing to detect environment variable accessgetenv("VAR", "fallback")patterns instead of executing"60"to"60.0"for claritySecurity Impact
Before: Running
./scripts/provider_codegen.pywith AWS credentials in environment wrote actual secrets to docs:After: Secrets are never executed or written:
Testing