fix:reorder env var redaction checks to scan values first#21059
fix:reorder env var redaction checks to scan values first#21059scidomino merged 2 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a security vulnerability where environment variables, despite having allowed names, could inadvertently leak sensitive information if their values contained secrets. The core change involves reordering the redaction logic to first check variable values against known secret patterns, ensuring that any sensitive data is redacted regardless of the variable's name. This significantly enhances the security posture by preventing accidental exposure of credentials or private keys. Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses a critical security vulnerability by reordering the environment variable redaction checks. The previous logic could have allowed sensitive values, such as API keys, to be exposed if they were part of an environment variable whose name was on an allowlist (e.g., PATH or HOME). The fix correctly prioritizes scanning the variable's value for secret patterns before checking its name against any allowlists. The implementation is sound, and the addition of specific regression tests effectively validates that the vulnerability is resolved. The changes are well-executed and improve the security of the application.
Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
4cd164b to
f3959a5
Compare
…ini#21059) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
…ini#21059) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
…ini#21059) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
…ini#21059) Signed-off-by: Kartik Angiras <angiraskartik@gmail.com>
Summary
Previously
shouldRedactEnvironmentVariablewould immediately allow variables in ALWAYS_ALLOWED_ENVIRONMENT_VARIABLES (like PATH, HOME, USER) without checking their values for secrets. This could allow API tokens, private keys, or other sensitive credentials to leak if embedded in the value of an allowed by name variable.Details
The fix reorders the checks to prioritise value scanning: all variables have their values checked against NEVER_ALLOWED_VALUE_PATTERNS before any name based allowlist is applied. This ensures even if a variable name is allowed, a secret value will still be caught and redacted
Related Issues
fixes #15349
How to Validate
npm run test --workspace=packages/core -- environmentSanitizationAll 22 tests pass, including the 4 new security regression tests.
Pre-Merge Checklist