Path Traversal Vulnerability in @openhop/server
The @openhop/server package is vulnerable to unauthenticated path traversal, allowing remote attackers to read or delete arbitrary YAML files via unsanitized route parameters in the Flow ID endpoint.
The @openhop/server package (0.3.5 and potentially surrounding versions) is affected by a path traversal vulnerability (CWE-22) originating from the unsafe construction of filesystem paths in FlowStore.filePath(). The application concatenates unsanitized HTTP route parameters directly into a path.join call without validation. Because the Fastify router (find-my-way) automatically decodes URL-encoded characters, an attacker can supply sequences such as ..%2F to escape the intended OPENHOP_DATA_DIR directory.
This vulnerability impacts both the read (GET) and delete (DELETE) operations of the /api/flows/:id endpoint. Furthermore, the application registers CORS with origin: true, making local instances exploitable via malicious browser-based requests. Default Docker deployments binding to 0.0.0.0 allow direct unauthenticated network access, significantly increasing the risk of data exfiltration and file destruction for exposed instances.
Attack Chain
- Attacker sends a crafted HTTP GET or DELETE request to the
/api/flows/:idendpoint using a traversal payload (e.g.,..%2Ffilename). - The Fastify
find-my-wayrouter decodes the URL-encoded%2Fcharacter into a literal/, resulting in anidparameter value of../filename. - The
FlowStore.filePath()method receives the maliciousidstring. - The method executes
path.join(this.dir, '../filename.yaml'), which normalizes to a path outside the designated data directory. - The application performs a file system operation (
readFilefor GET orunlinkfor DELETE) on the resulting path. - The server confirms the action by returning the contents of the target file or a success status for the file deletion.
- The attacker succeeds in either exfiltrating sensitive YAML-serialized information or permanently deleting application-critical files.
Impact
The vulnerability allows unauthenticated attackers to read or delete any .yaml file accessible to the user running the OpenHop process. Successful exploitation can lead to the exposure of sensitive application secrets or configuration data (Confidentiality) and the permanent loss of flow configurations (Integrity/Availability). Deployment environments with default Docker settings (HOST=0.0.0.0) are reachable directly from the internet, while local instances are vulnerable via cross-origin browser-based exploitation.
Recommendation
- Patch immediately by implementing an allowlist validation for the
idparameter inpackages/server/src/store.tsusing a regex pattern (e.g.,/^[A-Za-z0-9_-]+$/). - If an immediate update is not possible, restrict access to the
/api/flows/endpoint via network-level firewalls or reverse proxy access control lists to prevent unauthenticated access. - Reconfigure the OpenHop deployment to bind to
127.0.0.1rather than0.0.0.0if remote access is not required for the management API. - Disable
origin: truein the CORS configuration withinpackages/server/src/index.tsand replace it with a restrictive allowlist of trusted origins.
Immediate actions
Restrict network access to /api/flows/ to trusted IP ranges.
Mitigations
Implement regex-based sanitization for flow ID parameters.
CWE-22 Path Traversal
Detection coverage 1
Detect Path Traversal Attempt in OpenHop Flow API
highDetects path traversal attempts against the OpenHop Flow API by identifying double-dot and encoded forward slash sequences in the URI.
Detection queries are available on the platform. Get full rules →