CVE-2019-16224

9.8 CRITICAL

📋 TL;DR

CVE-2019-16224 is a critical memory corruption vulnerability in py-lmdb 0.97 that allows attackers to execute arbitrary code or cause denial of service by supplying a malicious data.mdb file. The vulnerability stems from improper memory handling in the mdb_node_add function when processing certain md_flags values. Any application using the vulnerable py-lmdb library to process untrusted LMDB database files is affected.

💻 Affected Systems

Products:
  • py-lmdb
Versions: Version 0.97 specifically
Operating Systems: All operating systems where py-lmdb is installed
Default Config Vulnerable: ⚠️ Yes
Notes: Only vulnerable when processing LMDB database files. Applications must use the library's file parsing functionality to be exploitable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Remote code execution with the privileges of the application processing the malicious LMDB file, potentially leading to complete system compromise.

🟠

Likely Case

Application crash and denial of service, with potential for information disclosure or limited code execution depending on memory layout.

🟢

If Mitigated

Denial of service only if memory protections prevent code execution, but application availability is still impacted.

🌐 Internet-Facing: HIGH - Applications accepting LMDB files from untrusted sources over the internet are directly vulnerable to remote exploitation.
🏢 Internal Only: MEDIUM - Internal systems processing LMDB files from potentially compromised internal sources remain at risk.

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Public proof-of-concept demonstrates exploitation. Attack requires supplying a malicious data.mdb file to the vulnerable application.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: py-lmdb 0.98 and later

Vendor Advisory: https://github.com/jnwatson/py-lmdb/issues/167

Restart Required: Yes

Instructions:

1. Identify applications using py-lmdb. 2. Update py-lmdb to version 0.98 or later using pip: 'pip install --upgrade lmdb'. 3. Restart all applications using the library.

🔧 Temporary Workarounds

Input validation for LMDB files

all

Implement strict validation of LMDB files before processing, rejecting files from untrusted sources.

Application sandboxing

all

Run applications using py-lmdb in restricted environments with limited privileges.

🧯 If You Can't Patch

  • Implement network segmentation to isolate systems using vulnerable py-lmdb versions
  • Deploy application allowlisting to prevent execution of unauthorized code

🔍 How to Verify

Check if Vulnerable:

Check py-lmdb version with: 'python -c "import lmdb; print(lmdb.__version__)"' - if output is '0.97', system is vulnerable.

Check Version:

python -c "import lmdb; print(lmdb.__version__)"

Verify Fix Applied:

After update, verify version is 0.98 or higher using same command.

📡 Detection & Monitoring

Log Indicators:

  • Application crashes with memory access violations
  • Unexpected termination of processes using py-lmdb

Network Indicators:

  • Unexpected LMDB file transfers to vulnerable systems

SIEM Query:

source="application_logs" AND ("segmentation fault" OR "memory corruption" OR "invalid write") AND process="*lmdb*"

🔗 References

📤 Share & Export