There are a bunch of practical problems with this approach if you implement it securely, and the only way to avoid those is to implement it insecurely, which is likely how people would end up implementing it.
First, in order to securely store a password, you need random salt. That means that a function like PASSWORD('password1')
is not deterministic, and a database lookup like SELECT id, user, password WHERE user = ? AND password = PASSWORD(?)
is going to require a lot of custom logic to implement correctly and it's going to be inefficient to look up, which leads to the possibility of DoS attacks on the database. Of course, if you're using an insecure password function that's deterministic like MySQL's PASSWORD
, then this problem goes away, but you have an insecure solution.
Second, there is no agreement on the single right password hashing approach. Argon2 and scrypt are memory hard and are preferred these days, and bcrypt is still a robust choice, but for FIPS-certified software, only PBKDF2 can be used. It would be irresponsible to use PBKDF2 when there are more robust alternatives that are more resistant to attack, but also people want to be able to sell software to governments. Thus, the choice that will probably be implemented is the one that works everywhere, and will be worse for security as a result.
Third, there is no agreement on the right parameters for all environments. Even assuming we got everyone to agree on something like Argon2, the amount of memory and CPU to use when you're hosting a small site on shared hosting versus when you run a top 100 site on your own machines is going to differ. The latter site is going to have much more memory and CPU available to it and will be able to achieve a better level of security than the former. However, if we use one parameter set everywhere, we'll decrease security for large sites, which are a bigger target, when we don't have to.
Fourth, I would suspect most users do not have encryption set up on their databases, and as a result you're shoveling plaintext passwords over the network when you could not do that. By not sending passwords to the database, we avoid the situation where someone breaks into our network and siphons up plaintext passwords.
Fifth, we know full well that database developers are not well versed in cryptography. PostgreSQL for a long time used MD5 for passwords, and it currently uses SCRAM-SHA-256, which uses PBKDF2, when as mentioned we have better alternatives. MySQL and MariaDB, last I checked, both use unsalted schemes which are not suitable for non-pseudorandomly generated passwords. Thus, it is unlikely that we will get good quality, secure implementations representing the state of the art in cryptography.
Sixth, if passwords are hashed securely, then there can be no good reason for practical limitations on the set of password characters. Any reasonably sized normalized UTF-8 string should be acceptable. However, since we know developers are bad at passing strings securely to the database, we're likely to end up with either SQL attacks from passwords, or overly cautious developers who aggressively restrict password characters, both of which are bad for security. If we hash in our application, then we never have to worry about that.
So while these are mostly practical problems, they end up intersecting with the security problems in unpleasant ways, and as a consequence, you're likely to end up with insecure solutions that happen to be convenient to implement.