Summary
TYPO3 CMS contains an unsafe deserialization issue in its mail-file spool handling, where spool files are deserialized when the mailer:spool:send command runs.
Local users with write access to the mail spool directory can craft malicious spool files that trigger arbitrary PHP code execution on the web server during mail processing.
Affected context
The vulnerability occurs in TYPO3 CMS instances configured to use file-based mail spooling, where outgoing emails are queued as serialized data on disk and later processed via the mailer:spool:send command.
It becomes relevant in environments where:
- The mail spool directory is writable by local users or other processes beyond the TYPO3 runtime user
- Spool files are treated as trusted and deserialized without strict validation or isolation
- Scheduled tasks, cron jobs, or maintenance workflows regularly execute the mailer spool send command through the TYPO3 CLI or automation tooling
Exploit preconditions
- Attack surface: Local to the host or container running TYPO3, specifically the file-based mail spool directory.
- Required access: Ability to create or modify files in the TYPO3 mail spool directory (e.g., same system user, shared hosting accounts, compromised local service).
- Trigger point: Execution of the
mailer:spool:sendcommand via CLI, cron, or task scheduler that processes spool files and deserializes their contents. - Why exploitation is possible: The mail spool implementation deserializes file contents assuming they are trusted, allowing attacker-controlled serialized PHP data to instantiate objects or invoke code paths that can be leveraged for arbitrary PHP code execution.
Why this happens
This vulnerability stems from using PHP's deserialization mechanisms on data stored in the file-based mail spool without treating that data as untrusted input.
The mailer logic assumes that spool files only contain legitimate serialized mail objects produced by TYPO3, and does not enforce integrity checks, strict typing, or isolation of the deserialization process.
This aligns with CWE-502: Deserialization of Untrusted Data, where serialized data from a potentially accessible storage location is deserialized into application objects, and the resulting object graph can trigger gadget chains or magic methods that lead to arbitrary code execution.
In abstract terms, the pattern is:
- Persist complex objects via serialization for deferred processing
- Store them in a location that can be influenced by other local actors
- Later deserialize with full trust and execution privileges, without verification of origin or structure
Potential impact
- Execution of arbitrary PHP code in the context of the web server or TYPO3 CLI user
- Complete compromise of the TYPO3 instance, including modification of content and configuration
- Access to database credentials and sensitive configuration secrets stored in TYPO3
- Lateral movement to other applications or services reachable from the compromised host
- Installation of web shells, backdoors, or persistent malware on the server
General mitigation guidance
Effective mitigation generally focuses on eliminating unsafe deserialization paths and hardening file-based queues:
- Prefer mail transport mechanisms that do not rely on generic serialization for spooling or queuing (e.g., database-backed queues or direct SMTP with retry mechanisms that do not deserialize complex objects).
- Restrict access to the mail spool directory so that only the dedicated TYPO3 runtime user and trusted system services can read or write files there.
- Introduce strong integrity or authenticity checks for queued mail data (for example, signing or checksumming) before deserialization to detect tampering.
- Limit the complexity of objects stored in the spool by using simple, well-defined data structures rather than arbitrary object graphs.
- Run the TYPO3 web and CLI processes with least-privilege OS accounts, and minimize their file system permissions to reduce blast radius if exploitation occurs.
- Consider isolating mail-processing commands in dedicated environments (containers, chroot jails, or separate hosts) so that a compromise of the mailer process does not automatically imply full system compromise.
How teams detect issues like this
Detection approaches can combine code-centric analysis with operational monitoring:
- Static analysis: Search for use of generic
unserialize()or equivalent deserialization APIs in mail or spool-related code paths, especially where input originates from the file system or other shared resources. - Code review signals: Flag patterns where serialized data is read from disk and directly deserialized without validation, integrity checks, or strict whitelisting of allowed object types.
- Configuration review: Regularly audit permissions on TYPO3-related directories, including the mail spool, ensuring only the expected service account has write access.
- Runtime monitoring: Monitor the spool directory for unexpected files, unusual ownership changes, or anomalous write patterns from non-TYPO3 processes.
- Process and log monitoring: Track invocations of
mailer:spool:sendand correlate with unusual application behavior, errors during deserialization, or unexpected outbound connections. - Automated SAST or code-scanning tools can be configured to flag deserialization usage in persistence or queueing layers to help catch these issues early in development.

