Path Traversal that leads to Remote Code Execution via PHP file upload in ericferon/glpi-archimap

Valid

Reported on

Nov 15th 2022


📜 Description

A path traversal attack (also known as directory traversal) aims to access files and directories that are stored outside the web root folder. By manipulating variables that reference files with “dot-dot-slash (../)” sequences and its variations or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system including application source code or configuration and critical system files.

A classic example of path traversal attack to retrieve system files is : https://insecure-website.com/loadImage?filename=../../../etc/passwd.

In your application, path traversal occurs in the extension GET parameter of the ajax/putfile.php file.

🕵️ Proof of Concept

Abuse path traversal vulnerability to upload PHP file into the base root of GLPI

The base64 content of PD9waHAgc3lzdGVtKCRfUkVRVUVTVFsnY21kJ10pOyA/Pg== is equals to <?php system($_REQUEST['cmd']); ?>.

Get remote code execution

🔐 Mitigations

In PHP, you can use the basename function to extracts the last element of a path.

Add a whitelist to the extension parameter to disable PHP file upload.

📚 References

Impact

🚧 Impacts

An attacker could perform actions not intended by application like read, update or delete arbitrary files and directories stored on file system including application source code or configuration and critical system files. For example, an attacker can upload PHP file and obtain remote code execution on the system.

References

We are processing your report and will contact the ericferon/glpi-archimap team within 24 hours. 14 days ago
We have contacted a member of the ericferon/glpi-archimap team and are waiting to hear back 13 days ago
ericferon validated this vulnerability 12 days ago
xanhacks has been awarded the disclosure bounty
The fix bounty is now up for grabs
The researcher's credibility has increased: +7
ericferon marked this as fixed in v3.2.16 with commit 2a1cde 9 days ago
The fix bounty has been dropped
This vulnerability will not receive a CVE
putfile.php#L53 has been validated
ericferon published this vulnerability 9 days ago
to join this conversation