Summary
Docmost v0.21.0 contains a path traversal vulnerability in avatar attachment handling that may allow unauthenticated attackers to read local files.
The issue becomes risky when a public avatar-related endpoint accepts attacker-controlled file paths without sufficiently restricting them to the intended attachment directory.
Affected context
The vulnerability occurs in Docmost v0.21.0 when avatar attachments are processed through a publicly accessible URL. If user-controlled path information is not constrained to the designated attachment storage location, a remote unauthenticated actor may cause the application to access files outside that directory.
Exploit preconditions
- Attack surface: Public avatar attachment functionality and its associated POST request
- Required access: No authentication may be required when the public URL is reachable
- Trigger point: Processing an attacker-influenced attachment path or filename
- Why exploitation is possible: Insufficient path normalization and directory confinement may allow references to resolve outside the intended storage directory
Why this happens
The underlying bug is improper restriction of user-controlled filesystem paths. When an application combines or resolves an input path without canonicalizing it and verifying that the resulting location remains within an approved directory, traversal sequences or equivalent path representations may escape the expected boundary.
This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly known as path traversal.
Potential impact
- An unauthenticated attacker may disclose sensitive local files
- Application configuration or credential material could be exposed
- Internal source code or operational data may be retrieved
- Disclosed information could support follow-on attacks against the application or host
General mitigation guidance
Mitigation generally focuses on removing filesystem path trust from public request parameters and enforcing strong directory boundaries.
Common defensive patterns include:
- Resolve requested paths to canonical form before access
- Verify that resolved paths remain within an approved attachment directory
- Prefer opaque server-generated file identifiers over client-supplied paths
- Apply strict allowlists for attachment names and supported file types
- Keep sensitive files outside web-accessible and attachment directories
- Run the application with the minimum filesystem permissions required
- Return uniform errors that do not reveal filesystem structure
How teams detect issues like this
Organizations can identify path traversal risks through:
- Static analysis rules for filesystem APIs receiving request-derived values
- Code review checks for path joining without canonicalization and containment validation
- Tests covering encoded, normalized, and alternate path representations
- Web application firewall or gateway policies that flag traversal indicators
- Access-log monitoring for unusual requests to public attachment endpoints
- Automated security review tools that correlate user input with file access operations

