Skip to content

sec: path traversal in applescript-transport registerSurface() #3

@Ridgeio

Description

@Ridgeio

Summary

registerSurface(name) in src/applescript-transport.ts writes \${SURFACES_DIR}/\${agentName}.json with no basename or character validation. A name containing ../ can write/remove .json files outside ~/.swarm/surfaces.

Evidence

  • src/applescript-transport.ts:119path.join(SURFACES_DIR, \${agentName}.json`)` on unvalidated input.
  • Entry path: swarm join <name> (headless) → registerSurface(name) via src/index.ts:89.

Impact

Arbitrary-path file write/overwrite scoped to files ending in .json. In combination with the filename being partially operator-controlled, enables clobbering of config or state files the user has write access to.

Fix sketch

Validate name at registration (same ^[A-Za-z0-9_-]{1,64}$ shared with issue #1), and defense-in-depth: assert the resolved path is still under SURFACES_DIR before writing.

Context

Surfaced by codex challenge during review of PR #1 (lazy-reap). Out of scope for that PR — filing here per Lead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High prioritysecuritySecurity vulnerability or hardening

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions