Phar unserialization
Archive_Tar's filename validation could be bypassed with a capitalised PHAR scheme or other stream wrappers, allowing an attacker to trigger Phar unserialization or overwrite local files. This could lead to object injection or, if the PHP process runs as a privileged user, overwriting sensitive files like /etc/passwd.
github.com
Published on github.com
I have submitted this to the PEAR bug tracker as well as the PEAR group mailing list, and I'm not sure if either has gone through, so opening an issue here with the hope that this is the right place for it.
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
The filename validation only blocks lowercase 'phar://' and path traversal sequences, but does not block other stream wrappers or case variations.
What the attacker needed
Ability to supply a crafted tar archive; phar.readonly disabled for Phar attack; PHP process with write permissions for file overwrite
The fix
The fix should change the filename check to reject any filename containing '://' instead of only 'phar://'.
How it was found
- Create a tar archive with a filename containing 'PHAR://malicious_file.phar'.
- Extract the archive using Archive_Tar, which triggers Phar unserialization.
- Alternatively, create a tar archive with a filename containing 'file://path/to/file'.
- Extract the archive to overwrite the specified file.
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.
A tar archive is a common file format for bundling files. The library checks filenames to block dangerous ones, but the check only looks for lowercase 'phar://' and misses uppercase 'PHAR://' or other schemes like 'file://'. An attacker can craft a tar file with such a filename to make the application run harmful code or overwrite files on the server.
What is File upload?
An upload feature accepts a file that the server or other users' browsers then treat as code or as something trusted.