Kamailio’s exec module considered harmful
Kamailio's exec module, when used with user-controlled pseudo-variables in commands, allows OS command injection via crafted SIP messages. An attacker can execute arbitrary commands on the server by sending a malicious SIP request.
Published on rtcsec.com
Sandro Gauci, Enable Security
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The exec module passes user-controlled pseudo-variables directly into shell commands without adequate sanitisation, and the documentation encourages this unsafe pattern.
Impact
An attacker could execute arbitrary OS commands on the Kamailio server, leading to remote code execution.
What the attacker needed
Kamailio with exec module and user-controlled…; Attacker can send SIP messages to the server
The fix
The exec module should be avoided or, if used, user-controlled input must be strictly validated with an allow list using regular expressions.
How it was found
- Start the Kamailio Docker instance with the vulnerable configuration.
- Start monitoring the /tmp directory.
- Send the PoC using netcat.
- Observe the result in the directory listing.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Kamailio is a SIP server that can run external commands. If those commands include user input without proper checks, an attacker can sneak in their own commands. This is called command injection and can let an attacker run any program on the server.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.