Part-DB: Authenticated RCE via .phar attachment upload served from public/media
- Published
- Last modified
- Status
- published
- Known exploitation
- Not listed in CISA KEV
- Fix
- Fixed in 2.12.1
- Public exploit
- None on Exploit-DB
Summary
Part-DB, an open source electronic component inventory system, is affected before version 2.12.1. An authenticated user can upload a ".phar" file as a part attachment, which is stored in a publicly served directory and executed as PHP, allowing arbitrary code execution as the web server user.
Summarized by anthropic/claude-haiku-5.5. Verify details against the original sources.
Read the original description
Part-DB is an open source inventory management system for electronic components. Prior to version 2.12.1, the part attachment upload handler stores uploaded files under the web-served media directory using the client-supplied file extension, and its extension blocklist does not include phar. AttachmentSubmitHandler::renameBlacklistedExtensions() rewrites dangerous extensions (php, phtml, sh, cgi, py, js, html, htaccess, ...) to .txt, but phar is absent from the list, so a .phar file keeps its extension. Public attachments (the default) are written into public/media/, which is the Apache document root. The shipped Apache configuration routes .phar to PHP-FPM, so the stored file is executed as PHP on request. The per-attachment-type extension filter is empty by default and is not consulted by the upload handler in a way that blocks this, and a non-admin user in the default users group can create an attachment type with no filter and attach files to parts. Any authenticated user in the default users group uploads a .phar attachment to a part and fetches it under /media/, executing arbitrary PHP as the www-data web user. Ability to exploit depends on the webserver config, docker image contained the vulnerability by default. This issue has been patched in version 2.12.1.
Affected versions
- Part-DB Part-DB-server
fixed in 2.12.1