CVE-2023-40945

9.8 CRITICAL

📋 TL;DR

CVE-2023-40945 is a critical SQL injection vulnerability in Sourcecodester Doctor Appointment System 1.0 that allows attackers to execute arbitrary SQL commands through the $userid parameter in doctors/myDetails.php. This affects all installations of the vulnerable software version. Attackers can potentially access, modify, or delete database content.

💻 Affected Systems

Products:
  • Sourcecodester Doctor Appointment System
Versions: 1.0
Operating Systems: Any OS running PHP
Default Config Vulnerable: ⚠️ Yes
Notes: All default installations of version 1.0 are vulnerable. The vulnerability exists in the core application code.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise leading to patient data theft, appointment manipulation, credential harvesting, and potential server takeover via SQL injection to RCE chaining.

🟠

Likely Case

Unauthorized access to sensitive medical records, appointment data manipulation, and potential privilege escalation within the application.

🟢

If Mitigated

Limited impact with proper input validation and database permissions, potentially only allowing data viewing without modification.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

Exploitation requires authentication as a doctor user. The vulnerability is in a parameter that should be properly sanitized.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Unknown

Vendor Advisory: Not available

Restart Required: No

Instructions:

1. Review the vulnerable file doctors/myDetails.php
2. Implement parameterized queries or proper input validation for $userid
3. Test the fix thoroughly before deployment

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Add input validation to ensure $userid contains only expected values

Modify doctors/myDetails.php to validate $userid as integer using is_numeric() or filter_var()

Web Application Firewall (WAF)

all

Deploy WAF rules to block SQL injection patterns

Configure WAF to detect and block SQL injection attempts in POST/GET parameters

🧯 If You Can't Patch

  • Isolate the application behind a reverse proxy with strict input filtering
  • Implement network segmentation to limit database access from application servers

🔍 How to Verify

Check if Vulnerable:

Test the doctors/myDetails.php endpoint with SQL injection payloads in the userid parameter

Check Version:

Check application version in admin panel or configuration files

Verify Fix Applied:

Attempt SQL injection after implementing fixes and verify no database errors or unexpected behavior

📡 Detection & Monitoring

Log Indicators:

  • SQL syntax errors in application logs
  • Unusual database queries from application user
  • Multiple failed login attempts followed by successful doctor login

Network Indicators:

  • SQL keywords in HTTP requests to doctors/myDetails.php
  • Unusual database port traffic from web server

SIEM Query:

source="web_logs" AND uri="*myDetails.php*" AND (query="*UNION*" OR query="*SELECT*" OR query="*INSERT*" OR query="*DELETE*")

🔗 References

📤 Share & Export