CVE-2025-40617

9.8 CRITICAL

📋 TL;DR

A critical SQL injection vulnerability in Bookgy allows attackers to manipulate database operations through unvalidated HTTP parameters. Attackers can execute arbitrary SQL commands to retrieve, modify, or delete sensitive data. All Bookgy installations using the vulnerable endpoint are affected.

💻 Affected Systems

Products:
  • Bookgy
Versions: All versions prior to patch
Operating Systems: All platforms running Bookgy
Default Config Vulnerable: ⚠️ Yes
Notes: The vulnerability affects the /bkg_seleccionar_hora_ajax.php endpoint with IDTIPO, IDPISTA, and IDSOCIO parameters.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete database compromise including data theft, data destruction, and potential remote code execution through database functions.

🟠

Likely Case

Data exfiltration of sensitive information (user credentials, personal data, financial records) and unauthorized data manipulation.

🟢

If Mitigated

Limited impact if proper input validation and WAF rules are in place, though risk remains until patched.

🌐 Internet-Facing: HIGH - The vulnerable endpoint is accessible via HTTP requests, making internet-facing instances immediately exploitable.
🏢 Internal Only: HIGH - Even internal instances are vulnerable to insider threats or compromised internal systems.

🎯 Exploit Status

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

SQL injection vulnerabilities are commonly weaponized. The CVSS 9.8 score indicates trivial exploitation with high impact.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: Check vendor advisory for specific patched version

Vendor Advisory: https://www.incibe.es/en/incibe-cert/notices/aviso/multiple-vulnerabilities-bookgy

Restart Required: Yes

Instructions:

1. Review vendor advisory for patch details. 2. Apply the official patch from Bookgy vendor. 3. Restart the Bookgy application/service. 4. Verify the fix is applied.

🔧 Temporary Workarounds

WAF Rule Implementation

all

Deploy web application firewall rules to block SQL injection patterns in the vulnerable parameters

# WAF configuration depends on your specific WAF solution
# Example ModSecurity rule: SecRule ARGS "(?i:(union|select|insert|update|delete|drop|create).*?)" "id:1001,phase:2,deny"

Input Validation Filter

linux

Implement server-side input validation to sanitize IDTIPO, IDPISTA, and IDSOCIO parameters

# PHP example for parameter sanitization:
$id = filter_var($_GET['IDTIPO'], FILTER_VALIDATE_INT);
if ($id === false) { die('Invalid input'); }

🧯 If You Can't Patch

  • Block access to /bkg_seleccionar_hora_ajax.php endpoint at network perimeter or application firewall
  • Implement strict parameter validation and prepared statements in the vulnerable PHP file

🔍 How to Verify

Check if Vulnerable:

Test the endpoint with SQL injection payloads in IDTIPO, IDPISTA, or IDSOCIO parameters (e.g., ' OR '1'='1)

Check Version:

Check Bookgy version in application interface or configuration files

Verify Fix Applied:

Attempt SQL injection tests after patch; successful attacks should be blocked and return error messages

📡 Detection & Monitoring

Log Indicators:

  • Unusual SQL error messages in application logs
  • Multiple requests with SQL keywords in parameters
  • Requests to /bkg_seleccionar_hora_ajax.php with suspicious parameter values

Network Indicators:

  • HTTP requests containing SQL injection patterns in URL parameters
  • Unusual database query patterns from application server

SIEM Query:

source="*bookgy*" AND (url="*bkg_seleccionar_hora_ajax.php*" AND (param="*union*" OR param="*select*" OR param="*insert*" OR param="*update*" OR param="*delete*"))

🔗 References

📤 Share & Export