Skip to content

fix(permissions): hold a session network grant to the shared gate - #1351

Open
joei4cm wants to merge 1 commit into
EverMind-AI:mainfrom
joei4cm:fix/session_grant_shared_gate
Open

joei4cm wants to merge 1 commit into
EverMind-AI:mainfrom
joei4cm:fix/session_grant_shared_gate

Conversation

@joei4cm

@joei4cm joei4cm commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fix #1332: a SESSION network grant approved in a conversation's own sandbox reached the shared sandbox without passing the shared gate.

_prompt computed shared only from the refused executor (GRANTS.is_shared(executor)), so a session or always answer recorded under a conversation's own scope (GRANTS.grant(scope, grant)) reached the sandbox every conversation shares two ways: the executors_for(scope) sync and the union read in grants_for(None). There the conversation's looser mode spoke for everyone.

The prompt now marks the answer shared whenever it is keyed to a session scope (shared = bool(scope) or ...), so authorize_runtime(shared=True) holds it to the configured mode's floor, and the description carries a note saying what the answer reaches. The note was reworded across the Python constant, the gui.confirm.ev.net_shared en/zh entries, and the regenerated TUI catalogue.

Tests: three pinned tests reworded to the new behaviour, two added (a conversation sandbox prompt now states what a session answer opens; a refused sandbox registered under no scope still says so when there is nobody to ask).

Type

  • Fix

Verification

  • PYTHONUTF8=1 uv run --frozen --python 3.12 pytest tests/test_permissions_sandbox_network.py -q -> 59 passed

  • PYTHONUTF8=1 uv run --frozen --python 3.12 pytest tests/test_permissions_sandbox_network.py tests/test_permissions_gate.py tests/test_permissions_network_grants.py tests/test_permissions_session.py tests/test_permissions_judge.py -q -> 430 passed

  • uv run ruff format --check and uv run ruff check on the changed Python files -> clean

  • make check-source-language and make check-large-files -> exit 0

  • Relevant tests pass locally

  • Relevant lint / type checks pass locally

  • User-facing docs or screenshots are updated when needed

Risk

  • Security impact considered: this is the fix; a conversation's own looser mode no longer opens a target in the shared sandbox on everyone's behalf.

  • Backward compatibility considered: prompts whose grant was already shared keep the note; only a conversation-scoped prompt that previously omitted it now carries it, which is the intended disclosure.

  • Rollback path is clear for risky changes: revert the commit; no schema or persistence changes.

  • Security impact considered

  • Backward compatibility considered

  • Rollback path is clear for risky changes

Related Issues

Fixes #1332

@LivXue

LivXue commented Nov 18, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — 769ec5fd6d

Reviewed at head 769ec5fd6d44aec8149824b1e31855fc91b77917 (base ace780956f6b). Scope: the full base-to-head diff (raven/permissions/sandbox_network.py, i18n/messages.json, ui-tui/src/i18n/messages.generated.ts, tests/test_permissions_sandbox_network.py), read against the consumer in raven/permissions/gate.py::authorize_runtime and the grant writers in sandbox_network.py::_apply.

No Windows compatibility issue found.

  • The logic change is platform-neutral: shared = bool(scope) or (executor is not None and GRANTS.is_shared(executor)) feeds authorize_runtime(shared=…), whose only effect is mode = _no_looser_than(mode, configured) (gate.py:459-460), exactly the floor the description now states. No filesystem, subprocess, path, encoding, or permission-API surface is touched.
  • The i18n edit is UTF-8 text in a JSON catalogue plus the generated TUI file; the Chinese string survives both without escaping problems, and there is no stale copy of the old wording left anywhere in the head tree (checked by grep for both the en and zh strings).

Verification, native Windows host (tree pinned to the head commit):

  • python -S runner.py tests/test_permissions_sandbox_network.py -q → 59 passed
  • python -S runner.py tests/test_permissions_gate.py tests/test_permissions_network_grants.py tests/test_permissions_session.py tests/test_permissions_judge.py -q → 371 passed (430 together with the file above, matching the PR's stated count)
  • node ui-tui/scripts/gen-i18n.mjs --check → exit 0, i18n: generated catalogue is up to date (run with the portable node 22 in D:\tmp\node22; the system node on this box is unreliable)

Gaps and limitations: the head tree was obtained as GitHub's tarball of 769ec5fd (a direct git fetch from this host failed at the time), so the checkout is the commit's export rather than a git worktree. No live GUI/TUI prompt was driven — the wording is only checked through the description/refusal text the gate records. make check-source-language and check-large-files were not run here.

@joei4cm
joei4cm force-pushed the fix/session_grant_shared_gate branch from 769ec5f to a567e7c Compare November 18, 2026 09:08
@LivXue

LivXue commented Nov 18, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — a567e7cb

Reviewed at head a567e7cbba877812d7629b81b1cc5f6bb1b6f29e (base 20aaefd1161f). The PR's own diff is the same four files and is byte-identical to the revision reviewed at 769ec5fd (raven/permissions/sandbox_network.py blob e8f0e4e2ea..d855bc71ff in both); only the base moved, onto a newer main.

No Windows compatibility issue found. The change remains platform-neutral: shared = bool(scope) or … only feeds gate.authorize_runtime, where its single effect is mode = _no_looser_than(mode, configured), and the i18n edit is UTF-8 text in the JSON catalogue plus its generated TUI file.

Re-verified at this head on the native Windows host (GitHub tarball of a567e7cb, extracted under D:\tmp\rv1351b):

  • python -S runner.py tests/test_permissions_sandbox_network.py tests/test_permissions_gate.py tests/test_permissions_network_grants.py tests/test_permissions_session.py tests/test_permissions_judge.py -q → 430 passed
  • node ui-tui/scripts/gen-i18n.mjs --check → exit 0, i18n: generated catalogue is up to date (portable node 22 in D:\tmp\node22)

Gaps: the tree is the commit's export rather than a git worktree; no live GUI/TUI prompt was driven.

@joei4cm

joei4cm commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Hi @LivXue, your Windows compatibility review for this PR (posted at head a567e7cb) found no Windows compatibility issue, and CI on this head is green (22 pass / 1 skip). The merge gate still shows "review required" only because that conclusion arrived as an issue comment rather than a formal review. If you agree, could you submit the same conclusion with the Approve button? That is all this PR is waiting on.

@joei4cm
joei4cm force-pushed the fix/session_grant_shared_gate branch from a567e7c to cc086ab Compare November 18, 2026 15:36
@LivXue

LivXue commented Nov 18, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — cc086ab211

Reviewed at head cc086ab211d137587bf852687a397caf0a38c15b (base moved onto newer main). The PR's own diff is unchanged from the revision reviewed at a567e7cb: raven/permissions/sandbox_network.py still e8f0e4e2ea..d855bc71ff and tests/test_permissions_sandbox_network.py still 614d042f57..2b3c07d377, with the same 168-line patch (the i18n files' blob ids differ only because new main entries joined the catalogue).

No Windows compatibility issue found. Same reasoning as the earlier rounds: shared = bool(scope) or … only feeds gate.authorize_runtime, whose single effect is the configured-mode floor, and the wording change is UTF-8 text in the JSON catalogue plus its generated TUI file.

Re-verified at this head on the native Windows host (GitHub tarball of cc086ab211, extracted under D:\tmp\rv1351c):

  • python -S runner.py tests/test_permissions_sandbox_network.py tests/test_permissions_gate.py tests/test_permissions_network_grants.py tests/test_permissions_session.py tests/test_permissions_judge.py -q → 430 passed
  • node ui-tui/scripts/gen-i18n.mjs --check → exit 0, i18n: generated catalogue is up to date (portable node 22)

Gaps: the tree is the commit's export rather than a git worktree; no live GUI/TUI prompt was driven.

@joei4cm
joei4cm force-pushed the fix/session_grant_shared_gate branch from cc086ab to 29ddf28 Compare November 18, 2026 18:13
@LivXue

LivXue commented Nov 18, 2026

Copy link
Copy Markdown
Member

Windows compatibility review — 29ddf2892d

Reviewed at head 29ddf2892d0488e3b2f3194a2265ed249f7700e7 (rebased onto newer main). The PR's own diff is unchanged from the revision reviewed at cc086ab211: sandbox_network.py still e8f0e4e2ea..d855bc71ff, the tests still 614d042f57..2b3c07d377, same 168-line patch.

No Windows compatibility issue found. Same reasoning as the earlier rounds: shared = bool(scope) or … only feeds gate.authorize_runtime, whose single effect is the configured-mode floor, and the wording change is UTF-8 text in the JSON catalogue plus its generated TUI file.

Re-verified at this head on the native Windows host (GitHub tarball of 29ddf2892d, extracted under D:\tmp\rv1351d):

  • python -S runner.py tests/test_permissions_sandbox_network.py tests/test_permissions_gate.py tests/test_permissions_network_grants.py tests/test_permissions_session.py tests/test_permissions_judge.py -q → 430 passed
  • node ui-tui/scripts/gen-i18n.mjs --check → exit 0, i18n: generated catalogue is up to date (portable node 22)

Gaps: the tree is the commit's export rather than a git worktree; no live GUI/TUI prompt was driven.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security: a session network grant reaches the shared sandbox without the shared gate

2 participants