Repository navigation
fix(core): keep GIT_CONFIG_* environment triplets internally consistent - #28938
Shivansh1980 wants to merge 5 commits into
Conversation
Redaction is value-first, so a GIT_CONFIG_VALUE_n holding a credential is dropped while its GIT_CONFIG_KEY_n and the declared GIT_CONFIG_COUNT survive. Git treats that gap as fatal -- 'error: missing config value GIT_CONFIG_VALUE_0' followed by 'fatal: unable to parse command-line config' -- and refuses to run at all, so every git invocation in the sanitized environment fails. Separately, parseInt() on an inherited GIT_CONFIG_COUNT yields NaN for a non-numeric value, emitting GIT_CONFIG_COUNT=NaN, which git rejects with 'bogus count in GIT_CONFIG_COUNT'. Rebuild the numbered slots from the pairs that survived redaction, renumbering them contiguously and restating the count, and ignore an unusable inherited count when appending the sandbox overrides. Value-first redaction is preserved: a secret-bearing value is still never emitted, the whole directive is dropped instead.
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 issues where environment variable redaction caused Git configuration to become invalid. By ensuring that GIT_CONFIG_* triplets remain contiguous and that the GIT_CONFIG_COUNT is always a valid integer, the changes prevent Git from failing during execution in sanitized environments. Highlights
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 the 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 counterproductive. 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. Footnotes
|
|
📊 PR Size: size/L
|
There was a problem hiding this comment.
Code Review
This pull request introduces logic to normalize GIT_CONFIG_* environment variable triplets during environment sanitization, ensuring that if a sensitive value is redacted, the corresponding key is also removed and the remaining variables are renumbered contiguously to prevent Git from failing. However, a critical security vulnerability was identified in shellExecutionService.ts where a loop explicitly copies unsanitized GIT_CONFIG_* variables from the source environment, completely bypassing the newly introduced value-first redaction. It is recommended to remove this restoration loop to ensure proper enforcement of the sanitization.
Note: Security Review is unavailable for this PR.
Remove raw GIT_CONFIG_* restoration after sanitization and cover the pass-through sandbox boundary.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. This PR will be closed in 7 days if it remains without that designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
|
This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding. |
Summary
Prevents sanitized
GIT_CONFIG_*environments from becoming unparsable by Git when redaction removes one half of a numbered key/value pair. It also ensuresShellExecutionServicedoes not restore sensitive Git configuration values after sanitization.Git treats incomplete numbered configuration as fatal:
Details
Root cause
sanitizeEnvironment()performs value-first secret detection. If a credential-bearingGIT_CONFIG_VALUE_nis removed whileGIT_CONFIG_KEY_nandGIT_CONFIG_COUNTremain, Git sees an incomplete slot and refuses to run.A second path in
ShellExecutionServiceparsed inheritedGIT_CONFIG_COUNTvalues without strict validation. A non-numeric value producedGIT_CONFIG_KEY_NaN,GIT_CONFIG_VALUE_NaN, andGIT_CONFIG_COUNT=NaN, which Git rejects as a bogus count.Finally,
ShellExecutionServicerestored rawGIT_CONFIG_*variables fromsourceEnvafter sanitization. Built-in sandbox managers sanitize again, but relying on that left theShellExecutionService -> SandboxManagerboundary unsafe for pass-through or custom managers.Fix
GIT_CONFIG_COUNT.GIT_CONFIG_GLOBAL,GIT_CONFIG_SYSTEM, andGIT_CONFIG_NOSYSTEMunchanged.Security impact
This strengthens the sanitization boundary. Credential-bearing values remain removed before any sandbox manager receives the environment, while safe surviving pairs remain usable and contiguous.
Related Issues
GIT_CONFIG_COUNTpath.cannot spawn : No such file or directorydue to emptydiff.externalconfiguration #28928, which has the same total Git outage symptom but a separatediff.externalroot cause addressed by fix(core): drop unsafediff.externaloverride (#28928) #28930.How to Validate
Additional checks:
Regression coverage includes:
Pre-Merge Checklist
Validated locally on Windows with the exact Vitest, Prettier, ESLint, and TypeScript commands above.