mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #5787] [MERGED] fix(mari): close the verification guard's bash and symlink sibling paths #6931
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#6931
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/5787
Author: @kolacheee
Created: 9/2/2026
Status: ✅ Merged
Merged: 9/2/2026
Merged by: @kolacheee
Base:
staging← Head:fix/5776-5778-guard-sibling-paths📝 Commits (4)
96c26fcfix(mari): close the guard's bash and symlink sibling paths (#5776-#5778)84c9df4fix(mari): harden the sibling-path fixes per the adversarial reviewfcb75edfix(mari): left-anchor the sensitive-path pattern (CodeRabbit)2c7c0a6fix(mari): root-scope launcher names in the sensitive-path gate (CodeRabbit)📊 Changes
4 files changed (+509 additions, -49 deletions)
View changed files
📝
CHANGELOG.md(+1 -0)📝
packages/server/src/services/professor-mari/workspace-agent.service.ts(+164 -49)📝
packages/server/src/services/professor-mari/workspace-change-review.service.ts(+55 -0)➕
scripts/regressions/mari-guard-sibling-paths.regression.ts(+289 -0)📄 Description
Linked issue
Closes #5776
Closes #5777
Closes #5778
Why this change
What changed
mari db insert …(or any mari mutation) without--applyis a dry-run that persists nothing but exits successfully.commandMariDirectnow emits an engine sentinel at position zero of the output for dry-run results, andisAppliedWorkspaceMutationexcludes bash results that start with it. Position zero is trustworthy because a sandboxed script's output always begins with the engine-writtenCommand:header — script stdout, or sentinel text embedded in the command string, can never occupy it (same anchoring principle as #5775's staging marker).deny file-write*on macOS), so an error-tolerant compound command likesed -i … package.json; echo doneexits 0 and looked like a successful mutation.commandBashnow refuses the common write shapes targeting sensitive names (cp/mv/rm/touch/truncate/tee, in-placesed/perl, redirection) before execution, with guidance to the write/edit staging flow. It's a best-effort heuristic by design — the sandbox stays the hard floor; the gate turns the common silent failures into loud, actionable ones. It runs after direct-mari routing, so mari CLI commands whose content mentions these names are unaffected.write/editdecided whether to stage from the requested path only, solink.json → package.jsonclassified "normal" and the write followed the link into the sensitive file with no approval. Path resolution (extracted toworkspaceMutationTargetForPath, exported for the lane) now chases the leaf's symlink chain — dangling links included, which previously skipped canonicalization entirely — enforces the workspace-escape and forbidden checks on the effective target, and returns the sensitive target for staging. Bonus hardening: a dangling symlink pointing outside the workspace is now refused instead of silently followed bywriteFile.> "package.json"— the shape LLMs actually write) plus interpreter one-liners,dd of=, andgit checkout/restoreof sensitive files; the symlink chase now fails closed at its hop cap and re-canonicalizes every hop through existing ancestors, so deep chains and dangling leaves routed through symlinked directories can't evade the policy checks; and a mari CLI mutation embedded in a compound command is refused up front (the sandbox denies the network the CLI needs, so those always failed silently while counting as applied — refusing has no false-positive case). One review finding is a pre-existing sandbox-layer gap out of this PR's scope, filed as #5786: the write-deny list only covers sensitive files that exist at spawn, so the heuristic gate here is the primary guard for newly created sensitive files — the doc comment says so honestly now.mari-guard-sibling-pathsregression lane: functional dry-run/forgery cases, a blocked/allowed command matrix for the sensitive-path gate, real-filesystem symlink cases (auto-skipped where symlink creation needs elevation, e.g. Windows without Developer Mode — they run on Linux CI), and source pins on the sentinel emission, refusal ordering, and staging call sites.Validation
pnpm checkpasses locallyCONTRIBUTING.mdManual verification notes
node ./scripts/run-regressions.mjs --filter mari-guard-sibling-paths(new lane), plus theprompt,mari-polish,mari-understood-request, andmari-ask-latchlanes;pnpm --filter @marinara-engine/server lint;pnpm build.mariCLI command in the terminal without--applyand confirm she reports it as a preview rather than a saved change.Docs and release impact
docs-i18nbranch updated to match, or a[docs-i18n]follow-up issue opened (see CONTRIBUTING.md § Translated documentation)UI evidence (if applicable)
Not applicable — server-side guard behavior only.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.