Skip to content

Commit

Permalink
webauthn: ensure allowCredentials[].id is an ArrayBuffer
Browse files Browse the repository at this point in the history
closes gh-16439

Signed-off-by: Daniel Garnier-Moiroux <[email protected]>
  • Loading branch information
Kehrlann committed Jan 17, 2025
1 parent 60dbeba commit 5bf42bb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
8 changes: 8 additions & 0 deletions javascript/lib/webauthn-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ async function authenticate(headers, contextPath, useConditionalMediation) {
}

// FIXME: Use https://www.w3.org/TR/webauthn-3/#sctn-parseRequestOptionsFromJSON
const decodedAllowCredentials = !options.allowCredentials
? []
: options.allowCredentials.map((cred) => ({
...cred,
id: base64url.decode(cred.id),
}));

const decodedOptions = {
...options,
allowCredentials: decodedAllowCredentials,
challenge: base64url.decode(options.challenge),
};

Expand Down
16 changes: 14 additions & 2 deletions javascript/test/webauthn-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,13 @@ describe("webauthn-core", () => {
challenge: "nRbOrtNKTfJ1JaxfUDKs8j3B-JFqyGQw8DO4u6eV3JA",
timeout: 300000,
rpId: "localhost",
allowCredentials: [],
allowCredentials: [
{
id: "nOsjw8eaaqSwVdTBBYE1FqfGdHs",
type: "public-key",
transports: [],
},
],
userVerification: "preferred",
extensions: {},
};
Expand Down Expand Up @@ -172,7 +178,13 @@ describe("webauthn-core", () => {
challenge: base64url.decode("nRbOrtNKTfJ1JaxfUDKs8j3B-JFqyGQw8DO4u6eV3JA"),
timeout: 300000,
rpId: "localhost",
allowCredentials: [],
allowCredentials: [
{
id: base64url.decode("nOsjw8eaaqSwVdTBBYE1FqfGdHs"),
type: "public-key",
transports: [],
},
],
userVerification: "preferred",
extensions: {},
},
Expand Down

0 comments on commit 5bf42bb

Please sign in to comment.