CVE-2025-31121

5.4 MEDIUM

📋 TL;DR

OpenEMR versions before 7.0.3.1 contain a cross-site scripting vulnerability in the Patient Image feature. Attackers can inject malicious scripts via EXIF title metadata in uploaded images, which then execute when viewed by other users. This affects all OpenEMR installations using vulnerable versions.

💻 Affected Systems

Products:
  • OpenEMR
Versions: All versions prior to 7.0.3.1
Operating Systems: All platforms running OpenEMR
Default Config Vulnerable: ⚠️ Yes
Notes: Requires the Patient Image feature to be enabled and accessible to users who can upload images.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Attackers could steal healthcare provider credentials, access sensitive patient health records, or perform administrative actions on behalf of authenticated users.

🟠

Likely Case

Attackers could hijack user sessions, steal authentication cookies, or redirect users to malicious sites.

🟢

If Mitigated

With proper input validation and output encoding, the malicious scripts would be rendered harmless as text rather than executed.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires an attacker to upload a malicious image with crafted EXIF metadata and have a victim view the image. Some level of access to upload images is needed.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 7.0.3.1

Vendor Advisory: https://github.com/openemr/openemr/security/advisories/GHSA-2w94-qmj6-3qxx

Restart Required: Yes

Instructions:

1. Backup your OpenEMR installation and database. 2. Download OpenEMR 7.0.3.1 from the official repository. 3. Replace the existing installation with the patched version. 4. Restart the web server service. 5. Verify the update was successful.

🔧 Temporary Workarounds

Disable Patient Image Upload

all

Temporarily disable the Patient Image feature to prevent exploitation while planning an upgrade.

Modify OpenEMR configuration to disable image upload functionality

Implement WAF Rules

all

Configure web application firewall to block malicious script patterns in image metadata.

Add XSS detection rules to your WAF configuration

🧯 If You Can't Patch

  • Implement strict content security policies (CSP) to prevent script execution from untrusted sources
  • Apply input validation and output encoding at the application layer for all user-supplied image metadata

🔍 How to Verify

Check if Vulnerable:

Check OpenEMR version via admin interface or by examining the source code version files. If version is below 7.0.3.1, the system is vulnerable.

Check Version:

Check the version.php file or use the OpenEMR admin dashboard to view current version

Verify Fix Applied:

After upgrading to 7.0.3.1, test by uploading an image with script tags in EXIF title and verify they are properly sanitized when displayed.

📡 Detection & Monitoring

Log Indicators:

  • Unusual image upload patterns
  • Multiple failed upload attempts with special characters in filenames
  • User sessions terminating unexpectedly after viewing images

Network Indicators:

  • HTTP requests containing script tags in image metadata parameters
  • Outbound connections to suspicious domains following image views

SIEM Query:

source="openemr_logs" AND ("image upload" OR "patient_image") AND ("<script>" OR "javascript:" OR "onerror=" OR "onload=")

🔗 References

📤 Share & Export