Cloud: harden fs remove path checks
Merged
TE
6d ago+82+82+01234567890123456789-6-6-0123456789
Hardens the Cloud machine fs remove route's path checks (backend/apps/api/src/cloud-machine-guest.ts):
- The route refuses a remove of the root however it is spelled (
/,/.,/./), not only/and///. - The guest program normalizes trailing
.and/segments before it inspects the path, so a symlink is removed itself, and a path that resolves to/exits 47, which the route answers as 400vm_invalid_path.
cmux-platform: the same fix landed in cmux-platform's port of these routes (manaflow-ai/cmux-platform#237); this keeps cmux-api's copy in step until the routes move.
Tests:
test/cloud-machine-guest.test.ts(workerd): the new root spellings are refused before any guest call, and exit 47 answers 400.test-node/cloud-machine-guest-program.test.ts(new, Node): runs the real program with the local python3 on a temporary tree, withshutil.rmtreeandos.unlinkreplaced by prints, so no run can delete anything. It runs through a newvitest.node.config.ts(bun run test:node) and a new step inbackend.ymlafter the Worker tests; the Worker config now includes onlytest/.
Risk: low. Only removes that resolve to the root, or that name a symlink with a trailing / or /., change behavior.
Agent session: agent session
š¤ Generated with Claude Code