Summary
A code injection flaw in Frogman before version 1.6.2 allows crafted template parameters to be written directly into Asterisk dialplan configuration without adequate sanitization.
Under these conditions, an attacker with write permissions to the dialplan apply mechanism can inject arbitrary Asterisk directives, potentially achieving remote command execution on the PBX host.
Affected context
This vulnerability exists in Frogman deployments that expose the MCP or HTTP API endpoint fm_dialplan_apply and allow callers to supply template parameters such as greeting, dest, url, extension, code, or file.
The issue manifests when Dialplan/Templates.php renders these parameters into extensions_custom.conf, while only context names are sanitized in Dialplan/TemplateBase.php.
Environments where untrusted or semi‑trusted users or automation can trigger dialplan updates are particularly exposed, especially if confirm:true is used to commit changes.
Exploit preconditions
- Attack surface: MCP and HTTP API providing access to fm_dialplan_apply.
- Required access: Ability to invoke dialplan apply operations with PERM_WRITE or equivalent privileges.
- Trigger point: Submission of crafted template parameters (e.g., dest, url, extension, code, file) with confirm:true so that generated dialplan content is written into extensions_custom.conf.
- Why exploitation is possible: Input fields other than the dialplan context name are embedded into Asterisk configuration without comprehensive sanitization or encoding, allowing injection of arbitrary Asterisk directives such as System(), Set(SHELL(...)), Goto, and Macro.
Why this happens
The root cause is incomplete input validation and context‑aware output handling when generating dialplan configuration from user‑controlled parameters.
While contextName() is sanitized, other templated values are treated as trusted and interpolated directly into extensions_custom.conf by Dialplan/Templates.php.
This aligns with CWE-94: Improper Control of Generation of Code ('Code Injection'), because user input is incorporated into a configuration language that supports executable constructs (Asterisk applications and functions), effectively allowing attackers to supply code-like directives that will be interpreted by the PBX.
Potential impact
- Execution of arbitrary OS commands via Asterisk System() or Set(SHELL(...)) directives.
- Complete compromise of the PBX host operating system and telephony services.
- Call interception, call redirection, or unauthorized call routing via Goto or Macro injection.
- Fraudulent call generation leading to toll fraud and financial loss.
- Tampering with call recording, voicemail, or logging behaviors within Asterisk.
General mitigation guidance
Effective mitigation focuses on limiting how untrusted data reaches dialplan code and constraining what the dialplan is allowed to execute.
Pattern-based approaches include:
- Applying strict, context‑sensitive validation for all template parameters that can reach Asterisk configuration, using whitelists or structured types rather than free‑form strings.
- Separating data fields (e.g., phone numbers, URIs, filenames) from executable dialplan snippets, and prohibiting user-supplied content from being interpreted as Asterisk applications or functions.
- Generating dialplan content through a constrained template engine that escapes or encodes special characters and disallows control constructs where user input appears.
- Reducing PBX runtime privileges so that even if dialplan injection occurs, the process has minimal access to the underlying system and shell.
- Restricting which internal actors can perform dialplan apply operations and requiring stronger authentication and authorization around PERM_WRITE actions.
How teams detect issues like this
Detection typically combines code, configuration, and runtime monitoring:
- Static analysis or secure code review focusing on template rendering paths that write to extensions_custom.conf, flagging any concatenation of user-controlled parameters into Asterisk directives.
- Pattern-based searches for locations where Asterisk functions like System(), SHELL, Goto, or Macro appear near unsanitized variables inside templates.
- Configuration auditing to detect unexpected or anomalous dialplan entries, especially those invoking shell commands or unusual call routing logic.
- Runtime monitoring and alerting for suspicious outbound calls, abnormal call volumes, or unexpected usage of System()/SHELL from the PBX process.
- Integration of automated SAST/IAST tools into CI pipelines to enforce rules around configuration generation and template safety.

