Skip to main content
Vulnerability Database/CVE-2022-51023

CVE-2022-51023: PHPOK SQL Injection Vulnerability

CVE-2022-51023 is an SQL injection flaw in PHPOK that allows unauthenticated attackers to manipulate ORDER BY clauses and extract database information. This post explains its technical details, affected versions, and mitigation steps.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2022-51023 Overview

CVE-2022-51023 is a SQL injection vulnerability [CWE-89] affecting PHPOK versions 4.5.000 through 5.4.080. The flaw resides in the sort parameter processed by /api.php?c=project&f=index. Unauthenticated attackers can manipulate ORDER BY clauses and extract database contents through error-based payloads using the extractvalue function. Exploitation evidence was first observed by the Shadowserver Foundation on 2023-10-14. The vulnerability enables remote data disclosure without authentication or user interaction.

Critical Impact

Unauthenticated remote attackers can extract sensitive database contents, including credentials and configuration data, from vulnerable PHPOK installations through crafted GET requests.

Affected Products

  • PHPOK 4.5.000 through 5.4.080
  • PHPOK api.php endpoint with c=project&f=index
  • PHPOK installations exposing the project API without network restrictions

Discovery Timeline

  • 2023-10-14 - Exploitation evidence first observed by the Shadowserver Foundation
  • 2026-10-22 - CVE-2022-51023 published to NVD
  • 2026-10-22 - Last updated in NVD database

Technical Details for CVE-2022-51023

Vulnerability Analysis

The vulnerability exists in PHPOK's project API handler, which accepts a sort parameter from unauthenticated HTTP GET requests. The application concatenates the sort value directly into the ORDER BY clause of a SQL query without validating that the input matches an allowed column name or sort direction. This permits attackers to inject arbitrary SQL expressions. Because ORDER BY clauses do not support parameter binding, developers often rely on allowlists; PHPOK omitted that control. Attackers exploit the flaw with error-based techniques, specifically MySQL's extractvalue function, to coerce the database into returning extracted data inside error messages.

Root Cause

The root cause is improper neutralization of special elements used in a SQL command [CWE-89]. The sort request parameter is interpolated into a dynamic query without sanitization, type-casting, or allowlist validation. The ORDER BY context makes exploitation reliable because injected XPath functions execute during query evaluation.

Attack Vector

Exploitation requires only network access to the PHPOK web interface. An attacker sends a GET request to /api.php?c=project&f=index and supplies an extractvalue-based payload in the sort parameter. The database returns the extracted substring inside an XPath syntax error, which the application reflects to the attacker. No credentials, cookies, or user interaction are needed.

// Example request pattern (sanitized)
GET /api.php?c=project&f=index&sort=<extractvalue payload> HTTP/1.1
Host: <target>

Source: VulnCheck Security Advisory and the Nuclei detection template describe the full exploitation pattern.

Detection Methods for CVE-2022-51023

Indicators of Compromise

  • GET requests to /api.php?c=project&f=index containing sort= values with SQL keywords such as extractvalue, updatexml, concat, or select.
  • HTTP responses containing MySQL XPath syntax errors referencing extractvalue or XPATH syntax error.
  • Unusual query strings on PHPOK endpoints originating from scanning infrastructure or Tor exit nodes.

Detection Strategies

  • Deploy the projectdiscovery/nuclei-templates phpok-sqli.yaml template to identify vulnerable instances during authorized scans.
  • Configure web application firewall rules to flag ORDER BY injection patterns and extractvalue( payloads in query parameters.
  • Review database error logs for XPATH syntax error entries correlated with web requests to api.php.

Monitoring Recommendations

  • Enable verbose access logging on all PHPOK front-end web servers and forward logs to a centralized analytics platform.
  • Alert on HTTP 500 responses from /api.php paired with database error signatures.
  • Monitor outbound data volumes from the PHPOK database host for anomalies consistent with bulk extraction.

How to Mitigate CVE-2022-51023

Immediate Actions Required

  • Upgrade PHPOK to version 5.4.081 or later, which contains the fix referenced in commit d70c396f.
  • Restrict public access to /api.php using network ACLs or reverse-proxy rules until patching is complete.
  • Audit database accounts used by PHPOK and rotate credentials if exploitation is suspected.

Patch Information

The vendor addressed the flaw in PHPOK 5.4.081. Administrators should apply the official upgrade published by the maintainer; refer to the GitHub commit and the VulnCheck advisory for upgrade guidance.

Workarounds

  • Deploy a WAF signature that blocks requests to /api.php containing SQL metacharacters or extractvalue( in the sort parameter.
  • Enforce an allowlist of valid sort values at a reverse proxy if direct patching is delayed.
  • Disable or remove the project API endpoint if the functionality is unused in the deployment.
bash
# Example NGINX rule to block known exploitation patterns
location /api.php {
    if ($args ~* "sort=.*(extractvalue|updatexml|select|concat)\(") {
        return 403;
    }
}

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.