CVE-2021-35940
📋 TL;DR
CVE-2021-35940 is an out-of-bounds read vulnerability in Apache Portable Runtime (APR) 1.7.x branch that allows reading memory beyond allocated array boundaries. This affects systems using APR 1.7.0 specifically, as the fix from APR 1.6.3 was not properly carried forward. The vulnerability could lead to information disclosure or application crashes.
💻 Affected Systems
- Apache Portable Runtime (APR)
📦 What is this software?
⚠️ Risk & Real-World Impact
Worst Case
Information disclosure leading to memory content leakage, potentially exposing sensitive data or cryptographic keys, followed by application crash causing denial of service.
Likely Case
Application instability or crashes when processing malformed time data, leading to denial of service conditions.
If Mitigated
Limited impact if proper input validation and memory protection mechanisms are in place, potentially just causing application errors.
🎯 Exploit Status
Exploitation requires crafting specific time data to trigger the out-of-bounds read. No public exploit code has been identified.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: APR 1.7.0 with patch applied or upgrade to APR 1.7.x versions after the fix
Vendor Advisory: http://mail-archives.apache.org/mod_mbox/www-announce/201710.mbox/%3CCACsi251B8UaLvM-rrH9fv57-zWi0zhyF3275_jPg1a9VEVVoxw%40mail.gmail.com%3E
Restart Required: Yes
Instructions:
1. Apply the official patch from https://dist.apache.org/repos/dist/release/apr/patches/apr-1.7.0-CVE-2021-35940.patch
2. Recompile and reinstall APR
3. Restart all services using APR
4. Alternatively, upgrade to a fixed APR version
🔧 Temporary Workarounds
Input validation wrapper
allImplement input validation for time data before passing to APR functions
🧯 If You Can't Patch
- Implement strict input validation for all time-related data passed to APR functions
- Monitor application logs for crashes or abnormal behavior related to time processing
🔍 How to Verify
Check if Vulnerable:
Check APR version: apr-1-config --version. If output shows 1.7.0, check if patch has been applied by examining source code or checking patch status.
Check Version:
apr-1-config --version
Verify Fix Applied:
Verify APR version is not 1.7.0 or confirm patch has been applied. Test with known malformed time inputs to ensure no crashes occur.
📡 Detection & Monitoring
Log Indicators:
- Application crashes with segmentation faults
- Error messages related to apr_time_exp functions
- Unexpected memory access errors
Network Indicators:
- Unusual patterns of time-related requests to services using APR
SIEM Query:
Search for application crashes containing 'apr_time_exp' or 'segmentation fault' in logs from systems running APR 1.7.0
🔗 References
- http://mail-archives.apache.org/mod_mbox/www-announce/201710.mbox/%3CCACsi251B8UaLvM-rrH9fv57-zWi0zhyF3275_jPg1a9VEVVoxw%40mail.gmail.com%3E
- http://svn.apache.org/viewvc?view=revision&revision=1891198
- http://www.openwall.com/lists/oss-security/2021/08/23/1
- https://dist.apache.org/repos/dist/release/apr/patches/apr-1.7.0-CVE-2021-35940.patch
- https://lists.apache.org/thread.html/r1c788464a25fbc046a72aff451bc8186386315d92a2dd0349903fa4f%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r317c398ee5736e627f7887b06607e5c58b45a696d352ba8c14615f55%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r54c755c74b9e3846cfd84039b1967d37d2870750a02d7c603983f6ed%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r72479f4dcffaa8a4732d5a0e87fecc4bace4932e28fc26f7d400e2b3%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r72a069753b9363c29732e59ad8f0d22a633fb6a699980407511ac961%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r7bb4a6ed88fc48152174e664aae30ea9a8b058eb5b44cf08cb9beb4b%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r7bb4a6ed88fc48152174e664aae30ea9a8b058eb5b44cf08cb9beb4b%40%3Cdev.httpd.apache.org%3E
- https://lists.apache.org/thread.html/ra2868b53339a6af65577146ad87016368c138388b09bff9d2860f50e%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/ra2868b53339a6af65577146ad87016368c138388b09bff9d2860f50e%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/ra38094406cc38a05218ebd1158187feda021b0c3a1df400bbf296af8%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/rafe54755850e93de287c36540972457b2dd86332106aa7817c7c27fb%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/rb1f3c85f50fbd924a0051675118d1609e57957a02ece7facb723155b%40%3Cannounce.apache.org%3E
- https://www.oracle.com/security-alerts/cpujul2022.html
- http://mail-archives.apache.org/mod_mbox/www-announce/201710.mbox/%3CCACsi251B8UaLvM-rrH9fv57-zWi0zhyF3275_jPg1a9VEVVoxw%40mail.gmail.com%3E
- http://svn.apache.org/viewvc?view=revision&revision=1891198
- http://www.openwall.com/lists/oss-security/2021/08/23/1
- https://dist.apache.org/repos/dist/release/apr/patches/apr-1.7.0-CVE-2021-35940.patch
- https://lists.apache.org/thread.html/r1c788464a25fbc046a72aff451bc8186386315d92a2dd0349903fa4f%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r317c398ee5736e627f7887b06607e5c58b45a696d352ba8c14615f55%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r54c755c74b9e3846cfd84039b1967d37d2870750a02d7c603983f6ed%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r72479f4dcffaa8a4732d5a0e87fecc4bace4932e28fc26f7d400e2b3%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/r72a069753b9363c29732e59ad8f0d22a633fb6a699980407511ac961%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r7bb4a6ed88fc48152174e664aae30ea9a8b058eb5b44cf08cb9beb4b%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/r7bb4a6ed88fc48152174e664aae30ea9a8b058eb5b44cf08cb9beb4b%40%3Cdev.httpd.apache.org%3E
- https://lists.apache.org/thread.html/ra2868b53339a6af65577146ad87016368c138388b09bff9d2860f50e%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/ra2868b53339a6af65577146ad87016368c138388b09bff9d2860f50e%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/ra38094406cc38a05218ebd1158187feda021b0c3a1df400bbf296af8%40%3Cdev.apr.apache.org%3E
- https://lists.apache.org/thread.html/rafe54755850e93de287c36540972457b2dd86332106aa7817c7c27fb%40%3Cdev.tomcat.apache.org%3E
- https://lists.apache.org/thread.html/rb1f3c85f50fbd924a0051675118d1609e57957a02ece7facb723155b%40%3Cannounce.apache.org%3E
- https://www.oracle.com/security-alerts/cpujul2022.html