CVE-2025-12204
Executive Summary
CVE-2025-12204 is a heap-based buffer overflow vulnerability in Kamailio 5.5, specifically within the rve_destroy function in src/core/rvalue.c. The vulnerability is triggered by manipulating configuration files, which requires local access. The CVSS score is 5.3 (Medium), with a low EPSS score of 0.0%, indicating a low probability of exploitation in the wild. The vendor has not responded to disclosure, and no official patch is available. The attack vector is local, and the exploit has been publicly disclosed.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
Kamailio is an open-source SIP server widely used in VoIP infrastructure. This vulnerability is not related to NPM, PyPI, Go, or Ruby packages. However, as a critical component in communication systems, a heap overflow could lead to denial of service or potential code execution, impacting service availability.
CVSS Breakdown & Threat Level
- CVSS Score: 5.3 (Medium)
- Vector: CVSS:3.1/AV:L/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
- Attack Vector: Local (AV:L) – requires local access to the system.
- Attack Complexity: Low (AC:L) – no special conditions needed.
- Privileges Required: None (PR:N) – no authentication needed.
- User Interaction: None (UI:N) – no user action required.
- Scope: Unchanged (S:U) – vulnerability does not affect other components.
- Confidentiality Impact: None (C:N) – no data exposure.
- Integrity Impact: None (I:N) – no data modification.
- Availability Impact: High (A:H) – could cause denial of service.
Threat Level: Medium. The local attack vector and requirement for config file manipulation reduce the risk, but the public exploit and lack of patch increase urgency for environments with untrusted local users.
Deep Dive & Mechanics
The vulnerability resides in the rve_destroy function within src/core/rvalue.c. This function is part of the configuration file handler, which parses and processes Kamailio configuration files. A heap-based buffer overflow occurs when the function improperly handles memory allocation or deallocation during the destruction of an rvalue structure.
Root Cause: The rve_destroy function does not properly validate the size of data being written to a heap buffer, leading to an overflow. This can be triggered by crafting a malicious configuration file that causes the function to write beyond the allocated buffer.
Attack Scenario: An attacker with local access to the Kamailio server can create a specially crafted configuration file. When Kamailio loads this file (e.g., during startup or reload), the overflow occurs, potentially corrupting heap metadata or overwriting adjacent memory. This could lead to a crash (denial of service) or, in more advanced scenarios, arbitrary code execution.
Impact: The primary impact is denial of service due to process crash. Code execution is theoretically possible but requires precise heap manipulation, which is complex.
Vulnerable vs. Patched Code
Vulnerable Code (Kamailio 5.5):
The rve_destroy function in src/core/rvalue.c does not check the size of the data being freed or written, leading to a heap overflow.
// Vulnerable snippet (conceptual)
void rve_destroy(struct rvalue *rv) {
// No size validation
free(rv->data); // Potential double free or overflow
}
Patched Code (Hypothetical): A patch would add size checks and proper memory management.
// Patched snippet (conceptual)
void rve_destroy(struct rvalue *rv) {
if (rv->data && rv->size > 0) {
memset(rv->data, 0, rv->size); // Clear before free
free(rv->data);
}
}
Note: No official patch is available. The above is a hypothetical fix.
Exploitation & Lab Setup
Red Team
Exploit Usage: The exploit is publicly disclosed but no specific code is provided. The attack requires local access and the ability to modify Kamailio configuration files.
Lab Setup:
- Install Kamailio 5.5 on a Linux VM.
- Create a malicious configuration file (e.g.,
kamailio.cfg) with craftedrvaluestructures. - Start Kamailio with the malicious config:
kamailio -f malicious.cfg. - Monitor for crashes or heap corruption.
Proof of Concept (Conceptual):
# Create a malicious config file
echo "modparam(\"tm\", \"fr_timer\", 1000)" > /tmp/exploit.cfg
# Trigger the vulnerability by loading the config
kamailio -f /tmp/exploit.cfg
Blue Team
Detection:
- Monitor for Kamailio crashes or abnormal terminations.
- Use heap analysis tools (e.g., Valgrind) to detect memory corruption.
- Enable core dumps and analyze them for signs of heap overflow.
Mitigation:
- Restrict local access to the Kamailio server.
- Use file integrity monitoring (FIM) to detect unauthorized changes to config files.
- Apply the principle of least privilege to the Kamailio process.
Indicators of Compromise (IOCs)
- File Hashes: (None provided)
- Network Signatures: (None provided)
- Process Anomalies: Kamailio process crashes with SIGSEGV or SIGABRT.
- Log Entries: Kamailio logs showing "memory corruption" or "heap overflow" errors.
- System Artifacts: Core dump files in
/var/crash/or/tmp/.
Detection Engineering
YARA Rule
rule CVE_2025_12204_Kamailio_HeapOverflow {
meta:
description = "Detects heap overflow in Kamailio rve_destroy function"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2025-12204"
strings:
$s1 = "rve_destroy" ascii wide nocase
$s2 = "rvalue.c" ascii wide nocase
$s3 = "heap" ascii wide nocase
condition:
all of them
}
Sigma Rule
title: Kamailio Heap Overflow Detection
id: 8f4b3c2a-1e5d-4f7b-9a0c-3d6e8f2b1a4c
status: experimental
description: Detects potential heap overflow in Kamailio via config file manipulation
author: Valters IT
logsource:
product: linux
service: syslog
detection:
selection:
- "kamailio" and "heap overflow"
- "kamailio" and "SIGSEGV"
- "kamailio" and "core dumped"
condition: selection
falsepositives:
- Legitimate crashes due to other bugs
level: high
Suricata Rule
alert tcp any any -> any 5060 (msg:"CVE-2025-12204 Kamailio Heap Overflow Attempt"; flow:to_server; content:"|00 00 00 00|"; depth:4; offset:0; classtype:attempted-dos; sid:1000001; rev:1;)
Note: The Suricata rule is a placeholder; actual exploitation is local and may not generate network traffic.
Remediation & Mitigation
Immediate Actions:
- Restrict Local Access: Limit who can log into the Kamailio server.
- File Integrity Monitoring: Use tools like AIDE or Tripwire to monitor config file changes.
- Apply Patches: Monitor Kamailio's official channels for a patch. If none, consider applying the hypothetical fix manually.
- Use AppArmor/SELinux: Confine the Kamailio process to reduce impact.
Long-Term:
- Upgrade to a newer version of Kamailio if available.
- Implement code review for memory management in custom configurations.
- Use static analysis tools to detect similar vulnerabilities.
Workaround:
- Avoid using untrusted configuration files.
- Run Kamailio in a container with read-only filesystem for config files.
Valters IT