Summary
SWE-agent's trajectory inspector contains a path traversal vulnerability that can allow unauthenticated clients to read files outside the intended trajectory directory. The issue becomes risky when the HTTP server is network-reachable and exposed files contain trajectory-shaped JSON with repository data, command output, or secrets.
Affected context
The vulnerability occurs in the trajectory inspector's HTTP /trajectory/ handler when request paths are joined with the configured trajectory directory without reliably rejecting parent-directory references. Risk is increased when the server binds to all interfaces, permits wildcard CORS requests, and is operated without authentication. Disclosure through the affected read path is constrained to files that can be parsed as trajectory-compatible JSON.
Exploit preconditions
- Attack surface: HTTP requests to the trajectory inspector's
/trajectory/
endpoint
- Required access: Network reachability; authentication is not required - Trigger point: A request path containing parent-directory traversal
references
- Enabling condition: The handler joins attacker-controlled path components
with the trajectory directory without complete canonicalization and
containment checks
- Exposure factor: Binding to
0.0.0.0and wildcard CORS may make requests
possible from broader network locations or malicious web pages
- Disclosure constraint: The targeted file must be accepted by the
trajectory JSON parsing path
Why this happens
The underlying bug is insufficient path validation before filesystem access. The handler treats request-derived path components as safe after incomplete sanitization, allowing parent-directory references to escape the intended directory when paths are joined. This behavior maps to CWE-22, Improper Limitation of a Pathname to a Restricted Directory, because the application does not enforce that the resolved target remains within its approved filesystem root.
Potential impact
- An unauthenticated attacker may read trajectory-compatible JSON files outside the intended directory.
- Disclosed files could contain repository contents or command output.
- Secrets, API keys, or other sensitive values may be exposed.
- A malicious web page could potentially initiate cross-origin requests where browser and CORS conditions permit.
- The incident could enable follow-on compromise of connected services if disclosed credentials remain valid.
General mitigation guidance
Mitigation generally focuses on enforcing a strict filesystem containment boundary and reducing unnecessary network exposure. Secure-by-default patterns include resolving requested paths canonically and accepting them only when they remain beneath the configured root, rejecting traversal encodings before filesystem operations, and serving only an explicit allowlist of files or identifiers rather than arbitrary path fragments. Authentication and narrowly scoped CORS policies can reduce unauthorized access, while binding administrative tools to a restricted interface, applying least-privilege filesystem permissions, and excluding secrets from trajectory data reduce impact. Responses should also avoid exposing more content than the endpoint requires.
How teams detect issues like this
Detection can include static analysis for filesystem joins that combine request parameters with directory roots without canonical containment checks, along with code review for direct use of URL paths in file reads. Dynamic testing can exercise encoded and repeated parent-directory references, alternate separators, and normalization edge cases while verifying that resolved paths cannot escape the approved root. Runtime monitoring may alert on traversal-like requests, unexpected access to sensitive directories, broad CORS behavior, and unauthenticated exposure of administrative HTTP services. Automated security review tools and policy checks can help enforce approved path-handling and network-exposure patterns.

