fix(patch): cherry-pick 32e777f to release/v0.31.0-preview.2-pr-20531 to patch version v0.31.0-preview.2 and create version 0.31.0-preview.3#20607
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 implements a critical fix by redirecting the storage of auto-saved policy files from a workspace-dependent location to a consistent user-specific directory. This change ensures that policy persistence functions reliably across different projects and environments, improving the overall stability and predictability of policy management. 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 cherry-picks a change that moves the auto-saved policy file from being workspace-specific to user-global. While this improves user experience by making "Always Allow" decisions global, the implementation introduces a critical security issue related to policy priority. A dynamically created "Always Allow" rule has a different (and lower) priority than the same rule when it's persisted and reloaded in a new session. This inconsistency allows workspace policies to be bypassed after the first session, which constitutes a privilege escalation. A security-review comment has been added with details on the issue and a suggested fix.
| this.getWorkspacePoliciesDir(), | ||
| AUTO_SAVED_POLICY_FILENAME, | ||
| ); | ||
| return path.join(Storage.getUserPoliciesDir(), AUTO_SAVED_POLICY_FILENAME); |
There was a problem hiding this comment.
This change moves auto-saved policies to the user-global directory, but it creates a critical inconsistency in policy priority between sessions.
- In the current session, a new "Always Allow" rule is added dynamically with
ALWAYS_ALLOW_PRIORITY, which is2.95(Workspace Tier). This can be overridden by a high-priority workspace policy. - In subsequent sessions, the rule is loaded from
~/.gemini/policies/auto-saved.toml. Since this is a user-level directory, the rule gets a priority in the User Tier (~3.1). At this point, it can no longer be overridden by any workspace policy.
This behavior represents a privilege escalation, as a workspace's security restrictions are bypassed after the first session. The priority should be consistent.
Recommendation:
To fix this, the dynamic priority should match the persisted priority's tier. In packages/core/src/policy/config.ts, ALWAYS_ALLOW_PRIORITY should be updated to be in the User Tier, for example:
export const ALWAYS_ALLOW_PRIORITY = USER_POLICY_TIER + 0.0; // e.g., 3.0The comment for this constant should also be updated to reflect that it creates user-level rules that override workspace policies.
References
- Security-sensitive settings, such as policy priorities, must ensure consistent behavior across different configuration scopes (e.g., workspace vs. user-global) to prevent privilege escalation or bypass of security restrictions. Inconsistent priority handling between dynamic and persisted states, especially when it allows a user-level setting to bypass workspace policies, violates the principle of maintaining proper trust boundaries and consistent override behavior.
|
Size Change: +195 B (0%) Total Size: 25.7 MB ℹ️ View Unchanged
|
8553c38
into
release/v0.31.0-preview.2-pr-20531
This PR automatically cherry-picks commit 32e777f to patch version v0.31.0-preview.2 in the preview release to create version 0.31.0-preview.3.