Summary
A command injection flaw in the FreePBX recordings module allows attacker-controlled data, when used with the ElevenLabs Text-to-Speech (TTS) engine, to be incorporated into system command execution.
Under specific configurations where untrusted input reaches the TTS invocation, this can enable remote attackers to execute arbitrary commands with the privileges of the FreePBX process.
Affected context
This vulnerability affects FreePBX deployments that:
- Run versions 16.0.17.2 to before 16.0.20 or 17.0.2.4 to before 17.0.5, and
- Have the recordings module enabled and configured to use the ElevenLabs Text-to-Speech (TTS) engine, and
- Accept user-supplied or otherwise modifiable data that influences the TTS operation (for example, recording names, text content, or parameters).
The risk is most pronounced in multi-tenant or externally exposed PBX setups where web interfaces, APIs, or automated workflows can be influenced by untrusted users.
Exploit preconditions
- Attack surface: The FreePBX web interface and any associated API or workflow that triggers the ElevenLabs TTS functionality in the recordings module.
- Required access: Ability to supply or influence the data used by the TTS engine (e.g., via authenticated user roles, misconfigured portals, or exposed automation endpoints).
- Trigger point: Invocation of the TTS recording generation within FreePBX, where the backend constructs and executes a system command incorporating attacker-controlled input.
- Why exploitation is possible: User-controlled values are concatenated or interpolated into a command string executed by the operating system shell, without proper escaping, validation, or use of safe command-building APIs, enabling arbitrary command fragments to be injected.
Why this happens
The underlying issue is improper construction of OS command lines in the ElevenLabs TTS integration within the recordings module.
Instead of treating user-provided data as opaque values, it is combined directly into a shell command, allowing shell metacharacters or additional arguments to alter the command's behavior.
This corresponds to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), where applications fail to neutralize or segregate untrusted input from executable shell syntax.
The bug class is conceptual rather than specific to FreePBX: any feature that invokes system utilities or scripts using raw string concatenation is vulnerable when untrusted input is embedded without strict validation and safe APIs.
Potential impact
- Execution of arbitrary OS commands with the privileges of the FreePBX service account.
- Reading, modifying, or deleting PBX configuration and call data accessible to the compromised process.
- Pivoting within the telephony environment, including interception or manipulation of calls, voicemails, or recordings.
- Deployment of persistence mechanisms or additional malware on the PBX host.
- Use of the PBX server as a foothold for lateral movement within the internal network.
General mitigation guidance
Effective mitigation focuses on eliminating direct shell command construction from untrusted input and constraining the execution environment:
- Replace shell-based invocations with parameterized APIs or language-native libraries for interacting with the TTS engine wherever possible.
- When external commands are unavoidable, use safe process execution functions that pass arguments as structured lists rather than shell-joined strings, explicitly disabling shell interpretation.
- Apply strict allowlists and validation on all inputs that influence command parameters, limiting them to expected characters and values (e.g., numeric IDs, fixed option sets).
- Run FreePBX and related services under minimally privileged accounts and apply OS-level confinement (such as chroot, containers, or mandatory access controls) to reduce blast radius if compromise occurs.
- Limit exposure of the recordings and TTS functionality to only those user roles and interfaces that truly require it, reducing the pool of potential attackers.
How teams detect issues like this
Detection generally combines code-centric review with runtime monitoring:
- Use static analysis or manual code review to identify any points where user-supplied data is concatenated into command strings, especially in modules integrating with external services like TTS engines.
- Implement secure coding policies that prohibit raw shell command construction; enforce these in CI using linters or custom rules targeting functions known to spawn shells.
- Add logging around TTS invocation paths, capturing parameters and execution outcomes, and monitor for unusual or malformed arguments that may indicate injection attempts.
- Deploy runtime security monitoring or host intrusion detection on PBX servers to alert on anomalous process trees, unexpected shell spawns, or network connections originating from the FreePBX process.

