Skip to content

fix(server): workspace file writes refuse the server's own state files - #39529

Open
elias1218 wants to merge 2 commits into
pingdotgg:mainfrom
elias1218:fix/write-file-server-state
Open

elias1218 wants to merge 2 commits into
pingdotgg:mainfrom
elias1218:fix/write-file-server-state

Conversation

@elias1218

Copy link
Copy Markdown
Contributor

projects.writeFile did not refuse the server's own state files, though projects.readFile does. When a project's root contains the T3 state directory (a project at $HOME, or T3CODE_HOME/--base-dir inside a project), a client with only filesystem:write could overwrite files under secrets/ or truncate the live statev2.sqlite. A full-access client can already do this from a terminal, so only narrowly scoped clients gain anything here (SECURITY.md boundary 9).

WorkspaceFileSystem.writeFile now runs the same isServerInternalPath check as reads on the resolved target, before it creates directories or opens the file, and fails with WorkspacePathOutsideRootError like the read path. The existing state-files test now also covers writes: an existing database, an existing secret and a new file under secrets/ are refused and left unchanged.

Claude Opus 5.5 in Claude Code

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 2be480c and 784f6e2.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

WorkspaceFileSystem.writeFile now rejects resolved server-internal targets. Tests cover writes to the state database and secret files, and verify that existing files remain unchanged and new files are not created.

Changes: Server-internal write protection

Layer / File(s) Summary
Reject and test internal-path writes
apps/server/src/workspace/WorkspaceFileSystem.ts, apps/server/src/workspace/WorkspaceFileSystem.test.ts
writeFile returns WorkspacePathOutsideRootError for resolved server-internal targets. Tests cover the state database, an existing secret, and a new secret, then check that existing contents remain unchanged and the new secret is not created.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, minroz, macroscopeapp

Merge Risk: Minimal · previous review 2be48

Workspace file writes now refuse the server's own state files and secrets, which closes the gap for clients holding only write permission. The change is small, rejects before any file mutation, and has tests for the protected targets. No actionable merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: workspace file writes now refuse the server's own state files. It uses the conventional commit form and matches the objectives and the file-level summaries. It is 70 c…
Description check Passed The description covers the problem, the change, the scope, and the verification. The Problem section explains the write gap for clients with only filesystem:write and why it matters. The Change sectio…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: workspace file writes now refuse the server's own state files. It uses the conventional commit form and matches the objectives and the file-level summaries. It is 70 characters, which is within a typical length limit.

Full details: Description check

Explanation

The description covers the problem, the change, the scope, and the verification. The Problem section explains the write gap for clients with only filesystem:write and why it matters. The Change section explains the isServerInternalPath check on the resolved target before directory creation or file open. The Scope section cites SECURITY.md boundary 9 as the justification but does not link a bug issue or say why no issue is needed. The Verification section reports the extended state-files test and its observed results, which meets the template's bar that 'tests pass' alone is insufficient. The template's conventional-commit title guidance is followed. The author also named the model used, as the template asks for agent-driven work. The main gap is the missing issue link or justification for scope.

Resolution

Optionally link the issue that shows this bug, or state why a small fix needs no issue, as the Scope section asks.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c6ad9be and 2be480c.

Files selected for processing: 2

  • apps/server/src/workspace/WorkspaceFileSystem.test.ts
  • apps/server/src/workspace/WorkspaceFileSystem.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 20, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Create a fresh isolated T3 home, register it as a project, seed an existing secret marker, then issue authenticated WebSocket reads and writes against that marker and a nonexistent secret file. Inspect disk contents afterward. Both runs used the same driver against real Linux T3 servers.

Before After
be9176761c 784f6e29d0
Read refused; both writes succeeded. Existing marker became OVERWRITTEN via projects.writeFile; new secret file existed. Read and both writes refused. Existing marker remained original marker; new secret file did not exist.
Captured RPC and disk transcript Captured RPC and disk transcript

Reproduction driver

Not shown:

  • Protected database writes were not attempted to avoid corrupting the running proof servers; the existing and nonexistent secrets-file cases reproduce the reported defect.
  • The web client's project display was not captured; this proof exercises the server RPC behavior directly.

@juliusmarminge juliusmarminge added takeover:needs-julius Takeover done; route gate says Julius decides and removed takeover:in-progress A takeover lead is working on this PR labels Nov 20, 2026

This branch has not been deployed

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

Labels

size:XS 0-9 changed lines (additions + deletions). takeover:needs-julius Takeover done; route gate says Julius decides vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants