CVE-2021-32101
📋 TL;DR
CVE-2021-32101 is an incorrect access control vulnerability in OpenEMR's Patient Portal that allows unauthenticated attackers to register accounts and bypass permission checks. This enables attackers to read and manipulate data of all registered patients. Healthcare organizations using OpenEMR 5.0.2.1 Patient Portal are affected.
💻 Affected Systems
- OpenEMR
📦 What is this software?
Openemr by Open Emr
⚠️ Risk & Real-World Impact
Worst Case
Complete compromise of all patient health records, including sensitive medical data, personal information, and potential manipulation of medical records leading to incorrect treatment.
Likely Case
Unauthorized access to patient health records, exposure of sensitive personal health information (PHI), and potential data manipulation affecting multiple patients.
If Mitigated
Limited impact with proper network segmentation, strong authentication controls, and monitoring in place to detect unauthorized access attempts.
🎯 Exploit Status
Exploitation requires no authentication and involves simple API calls. Public technical details and proof-of-concept information are available.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: OpenEMR 5.0.2 Patch 5
Vendor Advisory: https://community.open-emr.org/t/openemr-5-0-2-patch-5-has-been-released/15431
Restart Required: Yes
Instructions:
1. Backup your OpenEMR installation and database. 2. Download OpenEMR 5.0.2 Patch 5 from the official repository. 3. Apply the patch following OpenEMR's patch application procedures. 4. Restart the web server and verify the fix.
🔧 Temporary Workarounds
Disable Patient Portal
linuxTemporarily disable the vulnerable Patient Portal component until patching can be completed.
# Remove or rename the portal directory
mv /path/to/openemr/portal /path/to/openemr/portal_disabled
Restrict Network Access
linuxImplement network access controls to limit Patient Portal access to authorized networks only.
# Example iptables rule to restrict access
# iptables -A INPUT -p tcp --dport 443 -s 192.168.1.0/24 -j ACCEPT
# iptables -A INPUT -p tcp --dport 443 -j DROP
🧯 If You Can't Patch
- Implement strict network segmentation to isolate the Patient Portal from untrusted networks
- Deploy a web application firewall (WAF) with rules to detect and block unauthorized API calls to portal/patient/_machine_config.php
🔍 How to Verify
Check if Vulnerable:
Check if portal/patient/_machine_config.php exists and examine its access control logic. Test if unauthenticated users can register accounts and access patient data.
Check Version:
Check OpenEMR version in the interface or examine version.php file: cat /path/to/openemr/interface/globals.php | grep 'openemr_version'
Verify Fix Applied:
Verify that portal/patient/_machine_config.php has been updated in the patch. Test that unauthenticated users cannot bypass permission checks or access patient data.
📡 Detection & Monitoring
Log Indicators:
- Multiple failed authentication attempts followed by successful registration
- Unauthorized API calls to portal/patient/_machine_config.php
- Unusual data access patterns from newly registered accounts
Network Indicators:
- Unusual traffic to Patient Portal registration endpoints
- API calls to patient data endpoints from unauthenticated sources
SIEM Query:
source="openemr_logs" AND (uri="/portal/patient/_machine_config.php" OR message="unauthorized access" OR message="registration attempt")
🔗 References
- https://blog.sonarsource.com/openemr-5-0-2-1-command-injection-vulnerability
- https://community.open-emr.org/t/openemr-5-0-2-patch-5-has-been-released/15431
- https://community.sonarsource.com/t/openemr-5-0-2-1-command-injection-vulnerability-puts-health-records-at-risk/33592
- https://portswigger.net/daily-swig/healthcare-security-openemr-fixes-serious-flaws-that-lead-to-command-execution-in-patient-portal
- https://blog.sonarsource.com/openemr-5-0-2-1-command-injection-vulnerability
- https://community.open-emr.org/t/openemr-5-0-2-patch-5-has-been-released/15431
- https://community.sonarsource.com/t/openemr-5-0-2-1-command-injection-vulnerability-puts-health-records-at-risk/33592
- https://portswigger.net/daily-swig/healthcare-security-openemr-fixes-serious-flaws-that-lead-to-command-execution-in-patient-portal