Summary
Finsys Dockhand has a path traversal vulnerability in stack environment-file handling that can let users with stacks:edit permission access files outside the intended directory. If an attacker can supply an unvalidated envPath, requests to the raw environment-file API may read or overwrite arbitrary files accessible to the service.
Affected context
The vulnerability occurs in Finsys Dockhand's stack source handling when an envPath value is accepted without adequate validation or confinement to an intended directory. It becomes risky when a user with stacks:edit permission can control this value and the raw environment-file API uses it for file access.
Exploit preconditions
- Attack surface: Stack environment-file handling through the
/api/stacks/[name]/env/rawAPI - Required access: Permission to edit stacks
- Trigger point: A GET or PUT request that uses the stack's
envPath - Why exploitation is possible: The path is not adequately validated or confined, allowing file operations beyond the intended location
Why this happens
The underlying issue is improper limitation of a pathname to a restricted directory, corresponding to CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'). The application uses a user-controllable path for file access without sufficiently validating it and ensuring the resolved path remains within an authorized directory.
Potential impact
- An attacker may read sensitive files accessible to the Dockhand service, potentially including credentials or SSH keys.
- An attacker could overwrite files accessible to the service, which may disrupt applications or alter their configuration.
- Exposure or modification of files may enable further compromise, depending on the service's privileges and deployment environment.
General mitigation guidance
Common defensive patterns include:
- Resolve requested paths and verify they remain within a designated, restricted directory.
- Prefer server-generated identifiers or allowlisted file references over accepting arbitrary paths.
- Apply strict validation to path inputs and reject unexpected absolute paths or traversal components.
- Limit the service account's filesystem permissions and isolate writable data from sensitive system files.
- Restrict stack-edit permissions to trusted users and enforce authorization for each file operation.
How teams detect issues like this
Review code paths that accept envPath or other user-controlled filenames, especially where they reach file read or write APIs. Static analysis can flag path construction from untrusted input and file access that lacks canonicalization and directory-boundary checks. Code reviews and policy checks can verify that authorization, path confinement, and least-privilege controls apply to both read and write operations; logs can also be monitored for unusual access to environment files or paths outside expected locations.

