Skip to main content

CVE-2022-31031: CWE-120: Buffer Copy without Checking Size of Input ('Classic Buffer Overflow') in pjsip pjproject

Medium
Published: Tue Jun 07 2022 (06/07/2022, 00:00:00 UTC)
Source: CVE
Vendor/Project: pjsip
Product: pjproject

Description

PJSIP is a free and open source multimedia communication library written in C language implementing standard based protocols such as SIP, SDP, RTP, STUN, TURN, and ICE. In versions prior to and including 2.12.1 a stack buffer overflow vulnerability affects PJSIP users that use STUN in their applications, either by: setting a STUN server in their account/media config in PJSUA/PJSUA2 level, or directly using `pjlib-util/stun_simple` API. A patch is available in commit 450baca which should be included in the next release. There are no known workarounds for this issue.

AI-Powered Analysis

AILast updated: 06/23/2025, 05:34:41 UTC

Technical Analysis

CVE-2022-31031 is a stack-based buffer overflow vulnerability identified in the PJSIP pjproject multimedia communication library, specifically affecting versions up to and including 2.12.1. PJSIP is widely used for implementing standard communication protocols such as SIP, SDP, RTP, STUN, TURN, and ICE, primarily in VoIP and real-time communication applications. The vulnerability arises from improper handling of input sizes when processing STUN (Session Traversal Utilities for NAT) messages. Specifically, when an application using PJSIP sets a STUN server in its account or media configuration at the PJSUA/PJSUA2 level or directly uses the pjlib-util/stun_simple API, the library performs a buffer copy operation without verifying that the input size fits within the allocated stack buffer. This classic buffer overflow (CWE-120) can lead to memory corruption, potentially allowing an attacker to execute arbitrary code, crash the application, or cause denial of service. The flaw is rooted in unsafe coding practices in the handling of STUN protocol data, which is critical for NAT traversal in VoIP communications. Although no known exploits have been reported in the wild, the vulnerability is significant due to the widespread use of PJSIP in telephony systems, softphones, and embedded communication devices. A patch addressing this issue was committed (commit 450baca) and is expected to be included in subsequent releases. No workarounds are currently available, making timely patching essential for affected users.

Potential Impact

For European organizations, the impact of this vulnerability can be substantial, especially for entities relying on VoIP infrastructure, unified communications, and real-time multimedia applications that incorporate PJSIP. Exploitation could lead to unauthorized code execution, enabling attackers to intercept calls, manipulate communications, or disrupt services. This is particularly critical for sectors such as telecommunications providers, financial institutions, government agencies, and healthcare organizations where secure and reliable communication is paramount. The vulnerability could also be leveraged as a pivot point for lateral movement within networks if exploited successfully. Given the lack of known exploits, the immediate risk is moderate; however, the potential for future exploitation remains, especially as threat actors often target communication libraries to compromise confidentiality and availability. The absence of workarounds means that vulnerable systems remain exposed until patched, increasing the window of opportunity for attackers. Additionally, the vulnerability could affect embedded devices and IoT systems using PJSIP, which may have limited patching capabilities, further exacerbating risk.

Mitigation Recommendations

To mitigate this vulnerability effectively, European organizations should: 1) Prioritize upgrading to the latest patched version of pjproject that includes the fix from commit 450baca. 2) Conduct an inventory of all applications and devices using PJSIP, focusing on those utilizing STUN functionality, to identify vulnerable instances. 3) For embedded or legacy systems where immediate patching is not feasible, implement network-level controls such as strict filtering of STUN traffic and limiting exposure of STUN servers to trusted networks only. 4) Employ runtime protections such as stack canaries, address space layout randomization (ASLR), and control flow integrity (CFI) where possible to reduce exploitation likelihood. 5) Monitor network traffic and application logs for anomalous STUN messages or crashes indicative of attempted exploitation. 6) Engage with vendors and suppliers to ensure timely updates and support for affected products. 7) Incorporate this vulnerability into incident response and vulnerability management workflows to ensure rapid detection and remediation.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-05-18T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9843c4522896dcbf33dc

Added to database: 5/21/2025, 9:09:23 AM

Last enriched: 6/23/2025, 5:34:41 AM

Last updated: 7/25/2025, 9:41:44 PM

Views: 11

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats