CVE-2022-25852

7.5 HIGH

📋 TL;DR

CVE-2022-25852 is a Denial of Service vulnerability in pg-native and libpq packages where non-array arguments cause casting failures that crash the application. This affects all versions of both packages, impacting Node.js applications using PostgreSQL database connections. The vulnerability is triggered when specific function calls receive incorrect argument types.

💻 Affected Systems

Products:
  • pg-native
  • libpq
Versions: All versions
Operating Systems: All platforms running Node.js
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications using the vulnerable function calls with non-array arguments. Both packages are affected as pg-native depends on libpq.

📦 What is this software?

⚠️ Manual Verification Required

This CVE does not have specific version information in our database, so automatic vulnerability detection cannot determine if your system is affected.

Why? The CVE database entry doesn't specify which versions are vulnerable (no version ranges provided by the vendor/NVD).

🔒 Custom verification scripts are available for registered users. Sign up free to download automated test scripts.

Recommended Actions:
  1. Review the CVE details at NVD
  2. Check vendor security advisories for your specific version
  3. Test if the vulnerability is exploitable in your environment
  4. Consider updating to the latest version as a precaution

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service outage where the PostgreSQL client process crashes, disrupting database connectivity and application functionality.

🟠

Likely Case

Application instability and intermittent crashes when malformed data or incorrect API calls trigger the vulnerability.

🟢

If Mitigated

Minimal impact with proper input validation and error handling preventing the vulnerable code paths from being reached.

🌐 Internet-Facing: MEDIUM - Exploitation requires specific API calls but could be triggered through application inputs.
🏢 Internal Only: MEDIUM - Internal applications could be affected by malformed data or development errors.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Exploitation requires triggering specific function calls with incorrect argument types, which may require application-specific knowledge.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Update to latest versions of pg-native and libpq (check npm for current patched versions)

Vendor Advisory: https://snyk.io/vuln/SNYK-JS-LIBPQ-2392366

Restart Required: Yes

Instructions:

1. Update package.json to use latest versions of pg-native and libpq. 2. Run 'npm update pg-native libpq'. 3. Restart your Node.js application. 4. Test database connectivity.

🔧 Temporary Workarounds

Input validation wrapper

all

Add validation to ensure second arguments to affected functions are arrays before passing to pg-native/libpq

// JavaScript example: function safeCall(arg1, arg2) { if (!Array.isArray(arg2)) throw new Error('Argument must be array'); return originalFunction(arg1, arg2); }

🧯 If You Can't Patch

  • Implement strict input validation for all database function calls
  • Add error handling and process monitoring to restart crashed services automatically

🔍 How to Verify

Check if Vulnerable:

Check package.json or run 'npm list pg-native libpq' to see installed versions. All current installations are vulnerable.

Check Version:

npm list pg-native libpq

Verify Fix Applied:

After update, verify with 'npm list pg-native libpq' showing latest versions, then test database operations.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with casting errors
  • PostgreSQL connection failures
  • TypeError exceptions in logs

Network Indicators:

  • Sudden drop in database connections
  • Increased connection timeouts

SIEM Query:

source="application.logs" AND ("TypeError" OR "casting" OR "pg-native" OR "libpq") AND ("crash" OR "error")

🔗 References

📤 Share & Export