Skip to content

fix(root): classify path traversal permission failures - #1044

Merged
steipete merged 2 commits into
mainfrom
fix/traversal-permission-errors-1027a
Oct 27, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/traversal-permission-errors-1027a

Conversation

@steipete

@steipete steipete commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Root path resolution currently labels an operating-system traversal denial as path-alias, even when no alias or confinement violation occurred. This causes misleading sandbox startup errors in openclaw/openclaw#184115.

Classify raw EACCES/EPERM failures at the existing Root resolution wrappers as additive operational permission-denied, retaining the original errno as the cause and the affected path in the message. The operation still fails closed; established policy errors and the default directory permissions keep their existing behavior. Thanks @LiuwqGit for the reproduction.

Evidence: all six mkdir/resolve/write regression cases fail against the base with path-alias and pass with the repair. Focused Root/error tests pass (71 tests); package build, generated public API snapshot, and installed-package checks pass. Full pnpm check passes: 14,361 tests pass across 761 test files (91 platform-gated files skipped), followed by installed-package declaration/runtime validation. Two existing tests that expected the former path-alias classification were updated; their focused rerun and separate independent review are clean. Independent autoreview at P0–P2 is scoped-clean. Error-code documentation and the Unreleased changelog are updated.

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 27, 2026 19:34
@steipete
steipete requested a review from a team as a code owner October 27, 2026 19:34
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T20:01:23.577348Z c76c747 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

This PR classifies raw Root traversal permission failures as operational permission-denied errors while retaining their cause and affected path.

Example: Root.mkdir("blocked/child") encounters EACCES while inspecting /workspace/blocked/child.

  • Before: The operation throws path-alias with category policy.
  • After: The operation throws permission-denied with category operational, names the affected path, and retains EACCES as its cause.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) Useful and focused classification repair with meaningful regression coverage, blocked by a concrete diagnostic-sanitization regression.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored exemption applies; available after-fix evidence exercises public Root operations with mocked lstat failures, and no authority-bearing value or authorization flow changes.
Patch quality 🦪 silver shellfish (2/6) Security review found an item that needs attention.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An ordinary filesystem permission denial is presented as a path-alias policy violation, sending callers toward the wrong diagnosis.
Reason: The supplied maintainer-authored direction supports this narrow public error-code addition, and the reproduction establishes concrete caller value without weakening filesystem checks.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep this PR open: it addresses a real error-classification defect still present on main, but its new diagnostic bypasses existing pathname escaping.

Priority: P2
Reviewed head: 2b2e61bc9e2dbea9788adc5142e94e8e5c6c02c9

Before merge

  • Escape denied pathnames before inserting them into diagnostics (P2) - On POSIX, a valid pathname can contain a newline or terminal escape. If traversal through a directory named "blocked\nFORGED" fails with EACCES, Node retains that raw name in error.path. sanitizeRootPathError escapes the underlying error's message, but it does not alter error.path, so this interpolation introduces raw control characters into the new top-level FsSafeError. That violates docs/errors.md's single-line diagnostic contract and permits log or terminal output spoofing. Apply the existing formatErrorDetail() helper to deniedPath and add a public-Root regression covering control characters while preserving the original cause.
  • Resolve security concern: Raw pathname permits diagnostic spoofing - The finding concerns display safety rather than filesystem authorization: the original errno cause can remain exact while the public pathname text is escaped.
  • Explain or restore the original intent of Path diagnostic escaping - fix: harden filesystem safety variants under stress #113: The merged hardening work explicitly promised sanitized path diagnostics, and current docs require control characters to remain escaped on one log line.

Findings

  • [P2] Escape denied pathnames before inserting them into diagnostics — src/root-errors.ts:26-27
  • [low] Raw pathname permits diagnostic spoofing — src/root-errors.ts:27

Provenance

  • Path diagnostic escaping changes intended behavior without addressing why it exists (fix: harden filesystem safety variants under stress #113: The merged hardening work explicitly promised sanitized path diagnostics, and current docs require control characters to remain escaped on one log line.)

Tests

  • Missing end-to-end proof: The supplied evidence contains no after-fix installed-package run under a real non-root traversal denial; base-fail/head-pass results are reported in the PR body.
Agent review details

How this fits together

Root operations pass untrusted paths through shared confinement and identity checks; resolution wrappers translate rejected filesystem operations into public FsSafeError diagnostics.

flowchart TD
  A[Caller pathname] --> B[Root operation]
  B --> C[Confinement and identity checks]
  C --> D[Filesystem traversal]
  D --> E[Resolution error wrapper]
  E --> F[FsSafeError returned to caller]
Loading

Technical review

Best possible solution:

Retain the shared classification repair and escape denied pathnames with formatErrorDetail before constructing the public diagnostic.

Do we have a high-confidence way to reproduce the issue?

Current-main wrappers and the supplied non-root failure trace establish the classification defect; this read-only review ran no target code or tests.

Is this the best way to solve the issue?

The existing wrappers and shared error owner are the smallest appropriate repair boundary, provided the new pathname text preserves the established escaping contract.

Full review comments:

  • [P2] Escape denied pathnames before inserting them into diagnostics — src/root-errors.ts:26-27
    On POSIX, a valid pathname can contain a newline or terminal escape. If traversal through a directory named "blocked\nFORGED" fails with EACCES, Node retains that raw name in error.path. sanitizeRootPathError escapes the underlying error's message, but it does not alter error.path, so this interpolation introduces raw control characters into the new top-level FsSafeError. That violates docs/errors.md's single-line diagnostic contract and permits log or terminal output spoofing. Apply the existing formatErrorDetail() helper to deniedPath and add a public-Root regression covering control characters while preserving the original cause.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f4af1002a2a0.

Provenance checked

Testing

Proof path: unit tests only.

Security

Needs attention: Filesystem rejection remains fail-closed, but the new diagnostic reintroduces attacker-controlled control characters into display text.

Evidence

Security concerns:

  • [low] Raw pathname permits diagnostic spoofing — src/root-errors.ts:27
    The finding concerns display safety rather than filesystem authorization: the original errno cause can remain exact while the public pathname text is escaped.
    Confidence: 0.99

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 3749731 adds src/root-context.ts:90 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 37497312750d; files: src/root-context.ts)

Labels

Label changes:

  • add P2: This is a bounded library diagnostic repair; filesystem rejection remains intact, but the introduced pathname-escaping defect needs correction.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P2: This is a bounded library diagnostic repair; filesystem rejection remains intact, but the introduced pathname-escaping defect needs correction.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 27, 2026, 3:57 PM ET / 19:57 UTC.

@steipete
steipete force-pushed the fix/traversal-permission-errors-1027a branch from 2b2e61b to c76c747 Compare October 27, 2026 20:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c76c747eda

ℹ️ About Codex in GitHub

Your team has set up Codex to 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 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/root-errors.ts
if (error instanceof FsSafeError) return error.code === "permission-denied" ? error : undefined;
if (!hasNodeErrorCode(error, "EACCES") && !hasNodeErrorCode(error, "EPERM")) return;
const deniedPath = isNodeError(error) && typeof error.path === "string" ? error.path : targetPath;
return new FsSafeError("permission-denied", `permission denied while resolving ${deniedPath}`, errorCauseOptions(error));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Escape the denied path before embedding it in the diagnostic

On POSIX, a denied path can contain newlines or terminal escape characters. Interpolating error.path (or the fallback path) directly into this message lets attacker-controlled names inject log lines or terminal formatting, violating the diagnostic escaping contract documented in docs/errors.md. sanitizeRootPathError() only sanitizes the original error's message, not its path property or this newly constructed message. Apply the shared formatErrorDetail() helper before interpolation and add a regression case containing control characters. This also follows the instruction in AGENTS.md to treat pathnames as attacker-controlled.

AGENTS.md reference: AGENTS.md:L30-L31

Useful? React with 👍 / 👎.

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

Labels

P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant