CVE-2020-27507
📋 TL;DR
CVE-2020-27507 is a critical buffer overflow vulnerability in Kamailio SIP servers before version 5.5.0. Attackers can crash the server or potentially execute arbitrary code by sending specially crafted INVITE requests with duplicated fields and overlength tags. This affects all organizations running vulnerable Kamailio versions as SIP proxies or PBX systems.
💻 Affected Systems
- Kamailio SIP Server
📦 What is this software?
Kamailio by Kamailio
⚠️ Risk & Real-World Impact
Worst Case
Remote code execution leading to complete system compromise, data exfiltration, or use as a pivot point in the network.
Likely Case
Denial of service through server crashes, disrupting SIP communications and voice services.
If Mitigated
Limited to denial of service if exploit attempts are blocked by network controls or the server is patched.
🎯 Exploit Status
The vulnerability requires sending malformed SIP packets but doesn't require authentication. Public proof-of-concept code exists in GitHub issues.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: 5.5.0 and later
Vendor Advisory: https://github.com/kamailio/kamailio/commit/ada3701d22b1fd579f06b4f54fa695fa988e685f
Restart Required: Yes
Instructions:
1. Backup current configuration. 2. Stop Kamailio service. 3. Upgrade to Kamailio 5.5.0 or later using package manager or source compilation. 4. Verify configuration compatibility. 5. Restart Kamailio service.
🔧 Temporary Workarounds
SIP Message Filtering
allUse Kamailio configuration to reject INVITE requests with duplicated fields or overlength tags before processing.
# Add to kamailio.cfg:
if (is_method("INVITE") && msg:len > MAX_ALLOWED_SIZE) {
sl_send_reply("400", "Bad Request");
exit;
}
Network Filtering
linuxUse network firewalls or IPS to block malformed SIP packets containing duplicated fields.
# Example Suricata rule:
alert sip any any -> any any (msg:"CVE-2020-27507 Kamailio buffer overflow attempt"; content:"INVITE"; pcre:"/^(?:[^\r\n]+\r\n)*([^\r\n]+)\r\n(?:[^\r\n]+\r\n)*\1\r\n/m"; sid:1000001; rev:1;)
🧯 If You Can't Patch
- Implement strict network segmentation to isolate SIP servers from untrusted networks.
- Deploy intrusion prevention systems (IPS) with rules to detect and block exploit attempts.
🔍 How to Verify
Check if Vulnerable:
Check Kamailio version: kamailio -V | grep version. If version is below 5.5.0, the system is vulnerable.
Check Version:
kamailio -V 2>&1 | grep 'version:'
Verify Fix Applied:
After patching, verify version is 5.5.0 or higher and test with legitimate SIP traffic to ensure functionality.
📡 Detection & Monitoring
Log Indicators:
- Kamailio crash logs
- SIP parser errors
- Abnormal INVITE request patterns in SIP logs
Network Indicators:
- Multiple malformed INVITE requests from single source
- SIP packets with duplicated header fields
- Oversized SIP tags in INVITE messages
SIEM Query:
source="kamailio.log" AND ("segmentation fault" OR "buffer overflow" OR "parser error") AND "INVITE"
🔗 References
- https://github.com/kamailio/kamailio/commit/ada3701d22b1fd579f06b4f54fa695fa988e685f
- https://github.com/kamailio/kamailio/issues/2503
- https://lists.debian.org/debian-lts-announce/2023/05/msg00030.html
- https://github.com/kamailio/kamailio/commit/ada3701d22b1fd579f06b4f54fa695fa988e685f
- https://github.com/kamailio/kamailio/issues/2503
- https://lists.debian.org/debian-lts-announce/2023/05/msg00030.html