Summary
Dolibarr EmailCollector may use attacker-controlled MIME attachment names as filesystem paths without reducing them to safe basenames. If an attacker can send mail to a monitored mailbox, they may write attachment content outside the intended object directory, potentially affecting documents or reaching web-executable locations where the installation permits it.
Affected context
The vulnerability occurs in Dolibarr EmailCollector workflows that automatically save inbound email attachments. It becomes risky when attachment names are derived from MIME metadata and passed to filesystem-write operations without canonicalization, basename enforcement, or equivalent path containment checks. The ultimate impact depends on filesystem permissions, whether the documents tree is writable, and whether web-served directories are writable and executable.
Exploit preconditions
- Attack surface: An EmailCollector-monitored mailbox and its attachment-processing workflows
- Required access: Ability to send an email accepted by the monitored mailbox; a Dolibarr account may not be required
- Trigger point: Automatic processing of an inbound attachment during record, ticket, or project operations
- Why exploitation is possible: The attachment-provided filename can retain path components and influence the destination supplied to a file-writing function
Why this happens
The underlying bug is insufficient validation of externally supplied filenames before they are combined with filesystem directories. Rather than treating the MIME filename as untrusted metadata that must be reduced to a safe basename and constrained to an intended directory, the application uses it as part of the output path. This behavior maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, because attacker-controlled path elements can escape the expected storage boundary.
Potential impact
- Attacker-controlled content may be written outside the intended attachment directory
- Other Dolibarr documents or stored objects could be overwritten, corrupted, or forged
- Application integrity and document authenticity may be reduced
- A writable web-executable location could enable server-side code execution
- The incident could support further application or host compromise
General mitigation guidance
Mitigation generally focuses on treating all inbound attachment names as untrusted and enforcing a strict storage boundary.
Common defensive patterns include:
- Reduce filenames to safe basenames and remove or reject path separators and traversal components
- Generate server-controlled storage names rather than preserving external filenames as paths
- Canonicalize candidate paths and verify that they remain beneath an approved attachment directory
- Apply strict allowlists for filename characters and enforce length limits
- Keep document storage outside web-executable locations where practical
- Use read-only application code paths and least-privilege filesystem permissions
- Fail closed when filename validation, canonicalization, or containment checks do not succeed
How teams detect issues like this
Organizations can look for:
- Static-analysis findings where email, MIME, or request-derived filename values reach file-write APIs
- Code-review signals involving direct concatenation of filenames with directories
- Missing basename, canonicalization, containment, or generated-name checks
- Runtime logs showing attachment writes containing path separators, parent-directory components, or unexpected absolute-path patterns
- Policy enforcement that prevents application identities from writing to web-executable directories
- Automated security scanning and code-review tools configured to identify path traversal and arbitrary-file-write patterns

