fix(server): Antigravity file writes cannot escape the workspace through a linked ancestor#26184

merged1
main
t3/fix-antigravity-symlink-escape
opened20d agobyJJulius Marminge
View on GitHubTwo-way sync enabledPR last imported 20d ago

Antigravity's client file handler checked workspace containment by realpath-ing only the target's immediate parent. When both the file and its parent were missing, it fell back to the lexical path, so a write to ws/link/a/b/file.txt (with ws/link -> /outside) passed the check. The recursive makeDirectory and the write then followed the symlink outside the workspace, even though the approved path looked like it was inside it.

The fix walks up to the deepest existing ancestor, realpaths it, and appends the missing segments before the containment check. This is the same approach as acpCanonicalPathForContainment in provider-acp, written against Effect FileSystem because that helper uses sync node:fs. Dangling or unreadable links along the way are still rejected. The existing containment test in AntigravityAdapterV2.test.ts gains a nested write through an escaping directory link. That case fails on main and passes with this change.

Opus 5.5 via Claude Code (T3 Code).

🤖 Generated with Claude Code

Checks

24 successful · 13 skipped
All checks passed
1c48615

Added 1 commit

  • fix(server): Antigravity file writes cannot escape the workspace through a linked ancestor1c48615
Synced from GitHub

Approvability

Verdict: Approved at 1c48615

Macroscope's review found this PR approvable — The resolver now checks the deepest existing ancestor so linked directories cannot redirect new file writes outside the allowed roots. Existing containment restrictions remain in place, with no change to product defaults or granted access.

You can add or adjust custom eligibility rules. Learn more.

Synced from GitHub

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful main measurement shown below.

ProviderMetricMain baselineThis PRImpactPR ceiling
CodexTotal thread wire5.0 KiB5.0 KiB+6 B (+0.1%)6.8 KiB✅
CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
CodexLive turn WebSocket wire1.2 KiB1.3 KiB+6 B (+0.5%)2.0 KiB✅
CodexLive turn WebSocket decoded21.6 KiB21.6 KiB0 B (0.0%)24.4 KiB✅
CodexLive turn messages220 (0.0%)8✅
ClaudeTotal thread wire5.1 KiB5.0 KiB−6 B (−0.1%)6.8 KiB✅
ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
ClaudeLive turn WebSocket wire1.3 KiB1.3 KiB−6 B (−0.5%)2.0 KiB✅
ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
ClaudeLive turn messages220 (0.0%)8✅

Baseline: dde3fdb · PR result: 1c48615 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

Synced from GitHub

Review in Change Stack →

No actionable comments were generated in the recent review.

External image Recent review info
External image Run configuration
External image Commits

Reviewing files that changed from the base of the PR and between cb7e3814d71c8fcdc5b803c660c29b7d7e39be96 and 1c4861557d7117a3800d225b2339109ce91ac9a1.

External image Files selected for processing: 2
  • apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
  • apps/server/src/provider/acp/AntigravityClientFiles.ts

Limit details: You’ve used all 10 included reviews currently available.

Walkthrough

The client file resolver now finds the deepest existing canonical ancestor of a requested path before checking containment. The containment test adds a nested write through an escaping directory symlink and verifies that the write fails without creating the outside directory.

Changes: Client file containment

Layer / File(s)Summary
Canonical ancestor containment
apps/server/src/provider/acp/AntigravityClientFiles.ts, apps/server/src/orchestration-v2/Adapters/AntigravityAdapterV2.test.ts
The resolver reattaches missing path components to the deepest existing canonical ancestor before checking allowed roots. The test verifies that a nested write through an escaping directory symlink fails and does not create the outside directory.

Priority: External image Not assessed

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

Change: Bug fix

Suggested reviewers: maria-rcks

Merge Risk: External image Minimal · up to 1c486

This change prevents Antigravity file writes from escaping the workspace through a symlinked ancestor when the target directories do not yet exist. No remaining merge-blocking risk was found.

Pre-merge checks: Passed 3 · Failed 1

Failed Failed checks: 1 warning

Check nameStatusExplanationResolution
Description checkWarningThe description clearly explains the problem, fix, affected test, and reported verification result. It does not include the required Scope and approval information, such as a linked issue, maintainer …Add a Scope and approval section. Include the triaged issue or maintainer approval with its discussion link, or explain why this focused and obvious bug fix qualifies for the no-prior-approval exception. Add the exact focused test command a…
Passed Passed checks: 3 passed
Check nameStatusExplanation
Title checkPassedThe title clearly identifies the server fix that prevents Antigravity file writes from escaping the workspace through a linked ancestor.
Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description clearly explains the problem, fix, affected test, and reported verification result. It does not include the required Scope and approval information, such as a linked issue, maintainer approval, or an explanation for why this focused obvious-bug fix qualifies without prior approval.

Resolution

Add a Scope and approval section. Include the triaged issue or maintainer approval with its discussion link, or explain why this focused and obvious bug fix qualifies for the no-prior-approval exception. Add the exact focused test command and observed result if available.

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Usage-based review receipt

Note

This review was completed with usage-based billing: files reviewed beyond your plan's included limits are billed at $0.25/file. View usage-based billing.

Comment @coderabbitai help to get the list of available commands.