Skip to content

A free, self-hostable news aggregator…

Log invalid challenge and ignore JSON error during login (#9278)

Inverle7b6ec0f8d65c
diff --git a/app/Models/FormAuth.php b/app/Models/FormAuth.php
index a6431aa8e..2c8f8afa8 100644
--- a/app/Models/FormAuth.php
+++ b/app/Models/FormAuth.php
@@ -11,6 +11,12 @@ class FreshRSS_FormAuth {
return false;
}
+ // Expecting bcrypt format, see: https://en.wikipedia.org/wiki/Bcrypt#Description
+ if (!preg_match('/^\$2[aby]\$(0[4-9]|10)\$[.\/0-9A-Za-z]{53}$/', $challenge)) {
+ Minz_Log::debug("Invalid challenge format: user={$username}, challenge={$challenge}, nonce={$nonce}");
+ return false;
+ }
+
return password_verify($hash . $nonce, $challenge);
}
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php
index f772014b8..bedb09440 100644
--- a/lib/Minz/Url.php
+++ b/lib/Minz/Url.php
@@ -140,7 +140,7 @@ class Minz_Url {
/** @return array{c?:string,a?:string,params?:array<string,mixed>} */
public static function unserialize(string $url = ''): array {
- $result = json_decode(base64_decode($url, true) ?: '', associative: true, flags: JSON_THROW_ON_ERROR) ?? [];
+ $result = json_decode(base64_decode($url, true) ?: '', associative: true) ?? [];
/** @var array{c?:string,a?:string,params?:array<string,mixed>} $result */
return $result;
}