fix(cosh-ng): block path traversal in readonly - #2708
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2f5d3c168e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
PR number: #2708 Findings
结构评审确认项(无 blocking 组织问题)
剩余风险
未跑验证(以 CI 实测为准)
|
2f5d3c1 to
0ae466c
Compare
|
Both findings addressed in 0ae466c (single commit, force-pushed): P1 (relative traversal) — fixed fail-closed and cwd-independently: after lexical normalization, a leading P2 (CI vs body) — the fast-checks failure was the test-inventory overlap ratchet: the three new tests had landed in |
|
PR number: #2708 Findings
结构评审确认项(无 blocking 组织问题)未发现 blocking package/module/public API 组织问题:
剩余风险
未跑验证(以 CI 实测为准)
|
is_blocked_special_path matched /proc, /dev and /sys by raw prefix only, so spellings like /../proc/version bypassed the blocklist. Normalize lexically (no filesystem access) before matching, keep the raw-prefix pass first (fail-closed), and block relative ..-prefixed spellings into proc/dev/sys cwd-independently. $-quoting forms stay intercepted upstream by the exec layer. Traversal tests moved to a lib-only module (overlap ratchet). Closes #2184 Assisted-by: Qoder Signed-off-by: Jiangtian Feng <jiangtianf97@163.com>
0ae466c to
eb1cb67
Compare
|
Thanks for the follow-up monitor pass. The
On the |
Why
is_blocked_special_pathmatched/proc,/devand/sysby raw prefix only, so spellings like/../proc/versionbypassed the blocklist and were allowed through the readonly auto-execution chain — a real bypass of the readonly safety check.What changed
$-quoting forms remain intercepted upstream by the exec layer; noted in a code comment.Related issue
closes #2184
User / Agent impact
Commands whose path arguments lexically resolve into
/proc,/devor/sys— previously executed via the readonly chain — are now blocked. Legitimate paths are unaffected.Risk and compatibility
Security tightening: the newly intercepted set is exactly the spellings that lexically resolve into
/proc,/devor/sys, all of which were genuine bypasses before the fix. An anti-false-positive matrix pins legitimate paths that must keep passing.Validation
cargo fmtandclippyclean with zero warnings.Documentation and rollback
Single commit — revert it directly to restore the previous matching behavior if ever needed.