fix(guard): close allow_test_bootstrap and basename entrypoint bypasses (#695)
Remove the public allow_test_bootstrap production seam so caller-controlled flags cannot forge native mutation provenance. Bind provenance to the resolved canonical entrypoint path plus a live stdio transport bind; basename-only mcp_server.py stack frames and import-only launch no longer authorize mutations. Test-mode install_test_native_runtime is pytest-only and cannot reach production Gitea mutation endpoints. Add AC9 regressions for both reviewer-found bypasses and related spoof vectors. Refs: PR #696 REQUEST_CHANGES at 253269c; issue #695 comments 11002/11005.
This commit is contained in:
@@ -9,22 +9,36 @@ formal reviews then looked identical to native approvals.
|
||||
|
||||
## Rule
|
||||
|
||||
Mutation auth, keychain fill, and controller quarantine require a **native MCP
|
||||
transport runtime** established only by the official entrypoint.
|
||||
Mutation auth, keychain fill, and controller quarantine require a **production
|
||||
native MCP transport runtime** established only by:
|
||||
|
||||
1. the **resolved absolute path** of the canonical entrypoint
|
||||
(`mcp_server.py` / `gitea_mcp_server.py` next to `mcp_daemon_guard.py`), and
|
||||
2. a live **transport bind** (`bind_native_mcp_transport(transport="stdio")`)
|
||||
immediately before `mcp.run`.
|
||||
|
||||
Basename-only trust (a renamed file called `mcp_server.py`), caller-controlled
|
||||
flags (there is **no** `allow_test_bootstrap`), environment variables, stack
|
||||
frame spoofing, or import-only launch are insufficient.
|
||||
|
||||
| Context | Allowed |
|
||||
|---------|---------|
|
||||
| Official MCP entrypoint (`mcp_server.py` / `gitea_mcp_server` `__main__`) calls `mark_sanctioned_daemon()` and holds a process-local runtime token | yes |
|
||||
| pytest (hermetic unit tests) | yes |
|
||||
| Official IDE-native MCP: resolved canonical entrypoint marks + binds stdio, holds process-local runtime token | yes |
|
||||
| pytest (hermetic unit tests) via `is_pytest_runtime()` | yes for unit gates |
|
||||
| `install_test_native_runtime()` under pytest (test-mode record) | unit-test transport gates only — **never** production Gitea mutations |
|
||||
| `allow_test_bootstrap=True` (removed; must not exist) | **no** |
|
||||
| Renamed runner basename `mcp_server.py` outside package root | **no** |
|
||||
| Import/launch of real entrypoint without transport bind | **no** |
|
||||
| `GITEA_MCP_SANCTIONED_DAEMON=1` alone (no process-local native runtime) | **no** (#695) |
|
||||
| `GITEA_ALLOW_DIRECT_MCP_IMPORT=1` in LLM sessions | **no** — never set in agent sessions |
|
||||
| `GITEA_ALLOW_KEYCHAIN_CLI=1` in LLM sessions | **no** — human operator only |
|
||||
| bare `python -c 'import gitea_mcp_server; …'` or offline runners | **no** |
|
||||
| keychain fill outside native/pytest | **no** |
|
||||
|
||||
Native runtime is **process-local**: a random token bound to the daemon PID.
|
||||
It is never reconstructed from environment variables, session-state files, or
|
||||
importing internals in a fresh Python process.
|
||||
Native runtime is **process-local**: a random token bound to the daemon PID and
|
||||
transport phase. It is never reconstructed from environment variables,
|
||||
session-state files, caller-controlled flags, or importing internals in a
|
||||
fresh Python process.
|
||||
|
||||
## Contaminated review quarantine (#695 AC8)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user