GitHub Security Advisory: GHSA-p864-fqgv-92q4
Package: devcode-it/openstamanager (COMPOSER)
Severity: HIGH (CVSS 0.0)
CWE: CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection')
Vulnerable versions: <= 2.9.8
Patched in: unpatched

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](https://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:

```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