Page MenuHomePhabricator

On postgresql $wgDBssl should make sslmode be 'verify-full' not 'required'
Open, MediumPublicBUG REPORT

Description

Postgresql has a number of sslmodes. Currently if the user sets $wgDBssl = true; this sets the mode to 'required'. Confusingly, this means force a TLS connection but do not do any certificate validation. This is pretty useless from a security perspective (Can be defeated by an active attacker), and has essentially the same security properties as "prefer" which is what you get with $wgDBssl = false;

I think its safe to assume that anyone setting $wgDBssl = true; wants actual validated SSL connection. I think we should make sslmode be 'verify-full' if $wgDBssl = true;. verify-full essentially means follow normal TLS rules for certificates. This may be a breaking change for those relying on the old behaviour.

See https://www.postgresql.org/docs/current/libpq-ssl.html#LIBPQ-SSL-SSLMODE-STATEMENTS for what all the values mean.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Actually, i just read:

For backwards compatibility with earlier versions of PostgreSQL, if a root CA file exists, the behavior of sslmode=require will be the same as that of verify-ca, meaning the server certificate is validated against the CA. Relying on this behavior is discouraged, and applications that need certificate validation should always use verify-ca or verify-full.

So i guess 'require' isn't as crazy as it sounds. Still seems weird, and only validating the root CA is correct sounds like a recipe for subtle security issues.

Krinkle triaged this task as Medium priority.May 1 2023, 7:17 PM
Krinkle moved this task from Untriaged to Rdbms: Non-MySQL support on the MediaWiki-libs-Rdbms board.
Krinkle removed a project: Performance-Team.
Krinkle subscribed.

Seems reasonable in principle and I don't think it would be a burden or increase maintenance complexity. Patch welcome, but probably also need to find a reviewer willing to test/review it.