Skip to content

Commit 2b37368

Browse files
authored
Fix email header base64 padding (#6961)
Newer versions of the Bitwarden client use Base64 with padding. Since this is not a streaming string, but a defined length, we can just strip the `=` chars. Fixes #6960 Signed-off-by: BlackDex <black.dex@gmail.com>
1 parent 9c7df64 commit 2b37368

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/api/core/accounts.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,6 +1328,11 @@ impl<'r> FromRequest<'r> for KnownDevice {
13281328

13291329
async fn from_request(req: &'r Request<'_>) -> Outcome<Self, Self::Error> {
13301330
let email = if let Some(email_b64) = req.headers().get_one("X-Request-Email") {
1331+
// Bitwarden seems to send padded Base64 strings since 2026.2.1
1332+
// Since these values are not streamed and Headers are always split by newlines
1333+
// we can safely ignore padding here and remove any '=' appended.
1334+
let email_b64 = email_b64.trim_end_matches('=');
1335+
13311336
let Ok(email_bytes) = data_encoding::BASE64URL_NOPAD.decode(email_b64.as_bytes()) else {
13321337
return Outcome::Error((Status::BadRequest, "X-Request-Email value failed to decode as base64url"));
13331338
};

0 commit comments

Comments
 (0)