Summary
Portabase had a path traversal flaw in its TUS upload webhook handler that could let an unauthenticated attacker overwrite files in the private data directory. Depending on the files affected, this could compromise sensitive key material or disrupt backup and restore operations.
Affected context
The issue affects Portabase versions before 1.21.2, in the TUS upload webhook handler at app/api/tus/hooks/route.ts. It becomes risky when the handler processes upload paths without reliably confining file writes to the intended destination; the private data directory includes the AES-256-GCM master key file.
Exploit preconditions
- Attack surface: The TUS upload webhook handler must be reachable by the attacker.
- Required access: The described vulnerability does not require authentication.
- Trigger point: A request processed by the upload webhook causes a file write.
- Why exploitation is possible: Path handling permits a write to escape the intended upload location and reach files under the private data directory.
Why this happens
The underlying issue is insufficient validation and confinement of paths used for file writes. When a handler derives a destination from attacker-influenced path information without ensuring the resolved destination stays within an authorized directory, traversal can enable unintended file overwrites. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory. The lack of an authentication requirement is also relevant to CWE-306: Missing Authentication for Critical Function.
Potential impact
- An attacker may overwrite files in the private data directory.
- Sensitive key material, including the master key, could be affected.
- Backup or restore operations could be disrupted.
- Data confidentiality or integrity may be affected if dependent files or keys are compromised.
General mitigation guidance
Defensive patterns focus on confining writes and reducing trust in client-supplied path information:
- Resolve and canonicalize destination paths, then verify they remain within an explicitly allowed directory.
- Prefer server-generated filenames and fixed storage locations over paths derived from request data.
- Apply strict validation to upload metadata and reject unexpected path components.
- Require appropriate authentication and authorization for sensitive upload operations where feasible.
- Run the service with least privilege and limit write access to only the directories it needs.
- Keep sensitive key material separate from upload-writable locations and protect it with narrowly scoped access controls.
How teams detect issues like this
- Use static analysis to identify file-write operations that consume request-controlled paths or filenames.
- Review upload handlers for canonicalization and explicit checks that resolved paths remain within an approved directory.
- Monitor for unexpected writes to private data directories and changes to key-material files.
- Enforce code review or CI policies requiring path confinement, authorization checks, and least-privilege storage access for upload features.
- Automated security review tools may help identify risky path-handling patterns.

