Re:MySQL Remote Root Code Execution/Privilege Escalation Exp...
by ptaipale on Monday September 12, 2016 @09:57AM
(#12479683)
Hint: try it as a text after a blank line with two spaces preceding it.
https://news.ycombinator.com/formatdoc
Then you can write
GRANT FILE ON *.* TO
(How to find out? Google.)
My reading of this is that it requires either mysql root or `GRANT FILE ON . TO ...` privileges? AFAICT this requires an explicit `GRANT FILE ON . TO ...`; just plain `GRANT ALL ON db.* TO ...` does NOT grant any FILE privileges. I assume an install that doesn't give any users FILE privileges is safe?
mysql> SELECT host, user, File_priv FROM mysql.user WHERE File_priv='Y';
AFAICT exploit chain:
* `GRANT FILE ON . TO ...`
* `SELECT unhex("%s") INTO DUMPFILE '%s'`
* ... clever tricks ...
* mysql root
* ... clever tricks ...
* service mysql restart
* system root
The mysql security model for FILE privileges described here seems ridiculous. Your security model relies on creating dumpfiles with `chmod 666` permissions, and rejecting config files that are world-writeable? "I fixed the security issue with world-writable dump files" "You just broken our security model!"
Never grant FILE privileges on a production mysql server?