Summary
Gotenberg can preserve Windows-style parent-directory components in uploaded or downloaded filenames when creating multi-output ZIP archives. If a returned archive is extracted by a Windows user or process, an attacker may cause files to be written outside the intended extraction directory.
Affected context
The issue occurs in Gotenberg routes that generate multi-file PDF, LibreOffice, or conversion archives. On Linux, filename sanitization based on filepath.Base does not treat backslashes as path separators, allowing Windows-style traversal components to remain in ZIP entry names. Risk depends on a downstream Windows extractor processing the returned archive and honoring those names.
Exploit preconditions
- Attack surface: Gotenberg upload and upstream-download endpoints that produce multi-output archives
- Required access: Ability to submit a file with a controlled filename or influence an upstream
Content-Dispositionfilename - Trigger point: Archive creation followed by extraction on a Windows system
- Why exploitation is possible: Backslash-based parent-directory components can survive Linux-side sanitization and become archive entry paths interpreted by Windows extractors
Why this happens
The underlying bug is incomplete path-component normalization before user-controlled filenames are placed into archive entries. The implementation relies on platform-specific basename behavior, so a Linux process does not remove traversal segments expressed with Windows separators. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because attacker-controlled archive names can escape the directory intended for extraction.
Potential impact
- A Windows extraction process may write files outside the intended destination directory
- Sensitive files could be overwritten if the extractor has sufficient permissions
- Applications or scripts in a targeted location could be modified
- Users or downstream systems may experience data integrity or operational impacts
- A broader compromise could occur if overwritten files are later executed or loaded
General mitigation guidance
Mitigation generally focuses on treating every archive entry name as untrusted and enforcing a platform-independent safe-name policy.
Common defensive patterns include:
- Normalize both forward-slash and backslash separators before validation
- Reject absolute paths, drive-qualified paths, parent-directory components, and ambiguous separator forms
- Ensure each resolved extraction target remains within the intended destination directory
- Generate archive entry names from controlled identifiers rather than original client filenames where practical
- Use archive libraries and extraction policies that prevent traversal by default
- Apply least privilege to processes that create or extract archives
- Keep downstream extraction isolated from sensitive directories and executable locations
How teams detect issues like this
Organizations can identify this class of issue through:
- Static analysis and code review checks for archive creation from user-controlled filenames
- Searches for platform-specific basename or path normalization used before ZIP or TAR entry creation
- Tests containing mixed separator styles, absolute paths, drive prefixes, and parent-directory components
- Runtime policies that reject unsafe archive entry names and log normalization failures
- Validation that resolved extraction paths remain under an approved destination
- Automated security review tools configured to flag archive path traversal and uncontrolled filename flows

