From ccf4aea37f6a655bc681c10358252130439f0eec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Ba=C4=8Do?= Date: Wed, 16 Sep 2026 22:47:49 +0200 Subject: [PATCH] fix(auth): default the breach service DSN to none A server that has not been told which breach service to ask should ask nobody, rather than call the public Have I Been Pwned API on its own: `_APP_PWNED_PASSWORDS_DSN` now defaults to `none://localhost`. The policy stays enabled by default per project, but it protects nothing until an operator points the DSN at a service, which the variable description now says first. Co-Authored-By: Claude Fable 5.1 --- app/config/variables.php | 4 ++-- app/init/resources/request.php | 3 ++- src/Appwrite/Auth/Validator/PasswordPwned/None.php | 9 +++++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/config/variables.php b/app/config/variables.php index 93940e508a..e813b22f12 100644 --- a/app/config/variables.php +++ b/app/config/variables.php @@ -486,9 +486,9 @@ return [ ], [ 'name' => '_APP_PWNED_PASSWORDS_DSN', - 'description' => "DSN of the service the password pwned project policy asks whether a password has been breached. The scheme picks the adapter.\n\nExamples:\n- Have I Been Pwned: `hibp://localhost` — the public range API, which only ever receives the first five characters of the password SHA-1 hash. No other detail is read from the DSN\n- [Appwrite Pwned](https://github.com/appwrite-labs/pwned): `appwrite://SECRET@appwrite-pwned/v1/detection` — a service you run yourself, which answers from its own copy of the Have I Been Pwned corpus, so nothing about the password leaves your network. It receives the whole password, authenticated with `SECRET` as a Bearer token, which must match the service's `APPWRITE_PWNED_SECRET`, so only point it at a service on your own network or behind TLS. The path defaults to `v1/detection` and the connection is plain HTTP unless you add `?tls=true`\n- None: `none://localhost` — reports every password as safe without asking anyone, for a server that must not or cannot reach a breach service. Projects can still enable the policy, but it protects nothing until you point the server at a real service\n- Testing: `mock://localhost` — reports a fixed list of passwords as breached without leaving the process. Refused on a production server, since it would report every real password as safe", + 'description' => "DSN of the service the password pwned project policy asks whether a password has been breached. The scheme picks the adapter. Nothing is asked until you set it: the default, `none://localhost`, reports every password as safe, so the policy protects nothing until this points at a service.\n\nOptions:\n- None: `none://localhost` — the default. Reports every password as safe without asking anyone, for a server that must not or cannot reach a breach service\n- Have I Been Pwned: `hibp://localhost` — the public range API, which only ever receives the first five characters of the password SHA-1 hash. No other detail is read from the DSN\n- [Appwrite Pwned](https://github.com/appwrite-labs/pwned): `appwrite://SECRET@appwrite-pwned/v1/detection` — a service you run yourself, which answers from its own copy of the Have I Been Pwned corpus, so nothing about the password leaves your network. It receives the whole password, authenticated with `SECRET` as a Bearer token, which must match the service's `APPWRITE_PWNED_SECRET`, so only point it at a service on your own network or behind TLS. The path defaults to `v1/detection` and the connection is plain HTTP unless you add `?tls=true`\n- Testing: `mock://localhost` — reports a fixed list of passwords as breached without leaving the process. Refused on a production server, since it would report every real password as safe", 'introduction' => 'TBD', - 'default' => 'hibp://localhost', + 'default' => 'none://localhost', 'required' => false, 'question' => '', 'filter' => '' diff --git a/app/init/resources/request.php b/app/init/resources/request.php index 2410ffc6f3..dfec05587c 100644 --- a/app/init/resources/request.php +++ b/app/init/resources/request.php @@ -679,7 +679,8 @@ return function (Container $context): void { }, ['user', 'store', 'proofForToken']); $context->set('pwnedPasswords', function (Cache $cache) { - $dsn = new DSN(System::getEnv('_APP_PWNED_PASSWORDS_DSN', 'hibp://localhost')); + // Nothing is asked until an operator points this at a service + $dsn = new DSN(System::getEnv('_APP_PWNED_PASSWORDS_DSN', 'none://localhost')); return match ($dsn->getScheme()) { 'hibp' => new PasswordPwnedHIBP($cache), diff --git a/src/Appwrite/Auth/Validator/PasswordPwned/None.php b/src/Appwrite/Auth/Validator/PasswordPwned/None.php index 2e5581b789..95f57d4c39 100644 --- a/src/Appwrite/Auth/Validator/PasswordPwned/None.php +++ b/src/Appwrite/Auth/Validator/PasswordPwned/None.php @@ -7,10 +7,11 @@ use Appwrite\Auth\Validator\PasswordPwned; /** * Reports every password as safe, without asking anyone. * - * For a server that must not, or cannot, reach a breach service, such as an - * air-gapped installation. Projects can still switch the policy on, but it - * protects nothing until the server is pointed at a real service, and every - * checked user reads as clean. + * The default until an operator points `_APP_PWNED_PASSWORDS_DSN` at a + * service, and the right choice for a server that must not, or cannot, reach + * one, such as an air-gapped installation. Projects can still switch the + * policy on, but it protects nothing until the server is pointed at a real + * service, and every checked user reads as clean. * * DSN: `none://localhost`, no details are read. */