CVE-2023-50472
📋 TL;DR
CVE-2023-50472 is a NULL pointer dereference vulnerability in cJSON v1.7.16 that can cause segmentation faults when the cJSON_SetValuestring function is called with invalid parameters. This affects any application using the vulnerable cJSON library version for JSON parsing. Attackers can potentially crash applications or achieve denial of service.
💻 Affected Systems
- cJSON library
- Applications embedding cJSON v1.7.16
📦 What is this software?
Cjson by Davegamble
⚠️ Risk & Real-World Impact
Worst Case
Application crash leading to denial of service, potentially disrupting critical services or enabling further exploitation through crash analysis.
Likely Case
Application segmentation fault causing service interruption and potential data loss in affected processes.
If Mitigated
Controlled application termination with proper error handling and logging, minimizing service impact.
🎯 Exploit Status
Exploitation requires the attacker to control input to cJSON_SetValuestring. The GitHub issue contains demonstration code showing how to trigger the segmentation fault.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: cJSON v1.7.17 and later
Vendor Advisory: https://github.com/DaveGamble/cJSON/issues/803
Restart Required: Yes
Instructions:
1. Update cJSON to version 1.7.17 or later. 2. Recompile any applications using cJSON. 3. Restart affected services. 4. For embedded systems, rebuild firmware with updated library.
🔧 Temporary Workarounds
Input validation wrapper
allAdd parameter validation before calling cJSON_SetValuestring to ensure pointers are valid
// Example C code wrapper:
int safe_cJSON_SetValuestring(cJSON *item, const char *valuestring) {
if (item == NULL || valuestring == NULL) return 0;
return cJSON_SetValuestring(item, valuestring);
}
🧯 If You Can't Patch
- Implement strict input validation for all cJSON_SetValuestring calls
- Use application-level monitoring to detect and restart crashed processes
🔍 How to Verify
Check if Vulnerable:
Check cJSON version in source code or compiled binaries: grep -r 'cJSON_VERSION' . or check library headers for version 1.7.16
Check Version:
grep '#define CJSON_VERSION_MAJOR\|CJSON_VERSION_MINOR\|CJSON_VERSION_PATCH' cJSON.h
Verify Fix Applied:
Verify cJSON version is 1.7.17 or later and test with the proof-of-concept from GitHub issue #803
📡 Detection & Monitoring
Log Indicators:
- Segmentation fault (core dumped) messages
- Application crash logs mentioning cJSON
- Unexpected process termination
Network Indicators:
- Sudden service unavailability on ports using cJSON
- Increased error responses from affected services
SIEM Query:
process.name:cjson AND event.type:crash OR error.message:"segmentation fault"