Symlink vulnerability when using adminer.version
Database management in a single PHP file
Brought to you by:
jakubvrana
Adminer creates a file called adminer.version in the temporary directory. First, this is a symlink traversal vulnerability: adminer.version could be a symlink planted by an attacker, leading to overwrite of an arbitrary file writable by the user running Adminer. Second, when multiple instances of Adminer run on the same machine under different UIDs, they fail with a permission denied error if the file was created by a different instance.
Would deleting the file first solve both issues?
No, because between deleting the file and creating it again, another process could create its own version.
I've added an
is_linkcheck. However, the same handling is also used for invalid logins. It's more complicated there. Creating anadminer.invalidsymlink by an attacker would disable invalid logins check. In that case, I createadminer.invalidplus some random suffix.I also delete
adminer.versionnow. The race condition is not critical. Note that Adminer prefersupload_tmp_dirfor temporary dir which could be user specific.