Mantis Bug Tracker <= 1.2.17 (ImportXml.php) PHP Code Injection Vulnerability
The Import/Export plugin passed user-controlled values from an uploaded XML file into a preg_replace call that used the deprecated e modifier, which evaluates the replacement as PHP code. An attacker able to import an XML file could therefore run arbitrary PHP code on the server.
karmainsecurity.com
Published on karmainsecurity.com
The vulnerable code is located in the /plugins/XmlImportExport/ImportXml.php script:
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the use of the preg_replace e modifier, which evaluates the replacement string as PHP, combined with unsanitised user input from the imported XML.
What the attacker needed
Ability to import an XML file; access to the Import/Export plugin
The fix
The e modifier should be removed and the replacement handled with a callback such as preg_replace_callback so user input is never evaluated as code.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This bug tracker lets users import issues from an XML file. One part of the import code built a search-and-replace pattern and told PHP to treat the replacement text as code to run. Because the file's contents ended up in that replacement, someone uploading a crafted file could make the server execute their own code.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.