Repository navigation
Description
Problem
`crates/ripr/src/analysis/diff/path.rs:3-11` — `parse_new_path_marker`
strips the `b/` prefix and returns `PathBuf::from(rest)` with no
traversal check and no canonicalization:
```rust
pub(super) fn parse_new_path_marker(raw: &str) -> Option {
let marker = raw.strip_prefix("+++ ")?;
let path = parse_diff_path_token(marker)?;
if path == "/dev/null" {
return None;
}
let path = path.strip_prefix("b/").unwrap_or(&path);
Some(PathBuf::from(path))
}
```
The unvalidated result is joined verbatim to root at
`crates/ripr/src/analysis/probes/diff.rs:210`:
```rust
location: SourceLocation::new(context.root.join(&context.changed.path), new_line, 1),
```
A crafted diff containing `+++ b/../../../etc/passwd` yields a
`SourceLocation` whose `file` escapes the workspace. The path is then
embedded in SARIF / JSON output and used for snapshot/context lookups.
The LSP layer enforces canonicalize+starts_with confinement
(`crates/ripr/src/lsp/uri.rs:84-93, 129-150` with the symlink-escape
test at uri.rs:298-324), and the explicit-flag CLI validators do the same
(`crates/ripr/src/cli/commands_agent_support.rs:11-42, 99-131, 150-182`
for `--verify-json`, `--diff`, verify-snapshot, brief-diff). But the
contents of the diff bypass that — the parsed `changed.path` reaches
`root.join()` unconfined.
This is distinct from #1941 (which scoped only explicit CLI path flags
and the receipt/verify surface).
Risk
Depends on downstream consumers of `SourceLocation::file`:
- If any path reads the file (snapshot, context, repair packet), a crafted
diff can read arbitrary files the ripr process can access. - Even read-only, the escape leaks absolute paths into SARIF / JSON
output, which is then uploaded to GitHub / CI logs.
Fix
In `parse_new_path_marker` (or at the join site in `probes/diff.rs:210`),
reject or normalize any path containing `..` components or an absolute
prefix before returning. Mirror the canonicalize+`starts_with` helper the
LSP layer uses, applied to the parsed diff path against the workspace
root.
`security(analysis)` rather than `fix(analysis)` because the fix is a
defensive confinement, not a behavior change.
Evidence
- `crates/ripr/src/analysis/diff/path.rs:3-11` — no traversal check
- `crates/ripr/src/analysis/probes/diff.rs:210` — `root.join(&context.changed.path)` joins unvalidated
- `crates/ripr/src/lsp/uri.rs:84-93, 129-150` — the LSP confinement pattern to mirror
- `crates/ripr/src/cli/commands_agent_support.rs:11-42` — the explicit-flag confinement pattern
Non-goals
- Changing the LSP layer's confinement (already correct).
- Receipt/verify path binding (covered by security(agent): ripr agent receipt and verify accept fabricated input — no head binding, no signature, no re-execution #1941).
Activity
coderabbitai commentedon Jul 21, 2026
🔗 Related PRs
#1612 - fix(lsp): reject ambiguous workspace roots [merged]
#1671 - fix(lsp): retain full analysis input identity [merged]
#1714 - audit(goals): add fail-closed authority audit framework [merged]
#2037 - fix: 5 quick correctness fixes from deep audit (--no-ext-diff, JSON escape, push_missing trim, dirty-worktree warning, OUTPUT_SCHEMA) [merged]
#2050 - fix(analysis): close three diff-parser gaps — combined, binary, overflow (
#1884) [merged]📝 Issue Planner
Check the box below or use the
@coderabbitai plancommand to generate an implementation plan and prompts that you can use with your favorite coding assistant.🧪 Issue enrichment is currently in open beta.
You can configure auto-planning by selecting labels in the issue_enrichment configuration.
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:💬 Have feedback or questions? Drop into our discord!
EffortlessSteven commentedon Jul 21, 2026
Fixed in #2139.
parse_new_path_markernow lexically confines the parsed path: onlyComponent::Normalcomponents are kept, and any path with a parent-directory, root, or prefix component is rejected. Rejection returnsNone, which the parser treats like/dev/null— the file is never registered, so noSourceLocation, SARIF/JSON record, or snapshot lookup can escape the workspace root. Covered by 5 new tests inanalysis/diff/parse.rsincluding an end-to-end test that a traversal diff registers zero files.goldens checkexit 0 (no drift; no legitimate diff contains escaping paths).fix(analysis): treat rejected +++ markers as file-section boundaries (#…
EffortlessSteven commentedon Jul 21, 2026
Status: still open on current main
Verified
crates/ripr/src/analysis/diff/path.rs:3-11:parse_new_path_markerstill returns the unvalidated path. No traversal check, no canonicalization. The result is joined atcrates/ripr/src/analysis/probes/diff.rs:210viaroot.join(&context.changed.path)— a..in the path would escape the workspace root.Evidence
crates/ripr/src/analysis/diff/path.rs:3-11— no traversal guard.crates/ripr/src/analysis/probes/diff.rs:210—root.join(&context.changed.path)uses the unvalidated path.fix(analysis): gate is_new_path_marker on unquoted-path plausibility (#…
security(analysis): confine diff new-path markers to the workspace (#…
security(cli): confine agent brief --files paths to the workspace (#2100
fix(output): emit diff JSON changed-file paths with forward slashes (#…
security(diff): add confined old-path extractor symmetric with new-pa…
security(diff): add confined old-path extractor symmetric with new-pa…
security(diff): add confined old-path extractor symmetric with new-pa…