-
-
Notifications
You must be signed in to change notification settings - Fork 227
Fixes passkeys validation errors #2916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -662,7 +662,7 @@ keepass.passkeysGet = async function(tab, args = []) { | |
| const nonce = keepassClient.getNonce(); | ||
| const [ publicKey, origin ] = args; | ||
| const passkeyPublicKey = JSON.parse(JSON.stringify(publicKey)); | ||
| const relatedOrigins = await keepass.getPasskeysRelatedOrigins(passkeyPublicKey?.rp?.id); | ||
| const relatedOrigins = await keepass.getPasskeysRelatedOrigins(passkeyPublicKey?.rpId); | ||
|
|
||
| const messageData = { | ||
| action: kpAction, | ||
|
|
@@ -920,11 +920,30 @@ keepass.getPasskeysRelatedOrigins = async function(rpId) { | |
| } | ||
|
|
||
| try { | ||
| let hostname; | ||
| try { | ||
| hostname = new URL(`https://${rpId}`).hostname; | ||
| } catch { } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should return already in here?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So there should be code duplication? try {
if (new URL(`https://${rpId}`).hostname !== rpId) {
logError(`getRelatedOrigins error: "${rpId}" is wrong rpId`);
return [];
}
} catch {
logError(`getRelatedOrigins error: "${rpId}" is wrong rpId`);
return [];
}
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Of course we want to handle the exception. |
||
|
|
||
| if (hostname !== rpId) { | ||
| logError(`getRelatedOrigins error: "${rpId}" is wrong rpId`); | ||
| return []; | ||
| } | ||
|
droidmonkey marked this conversation as resolved.
|
||
|
|
||
| const response = await fetch(`https://${rpId}/.well-known/webauthn`, { | ||
| signal: AbortSignal.timeout(DEFAULT_FETCH_TIMEOUT), | ||
| cache: 'no-store', | ||
| credentials: 'omit', | ||
| referrerPolicy: 'no-referrer', | ||
| }); | ||
|
|
||
| // Basic reply validation, see: https://www.w3.org/TR/webauthn-3/#sctn-validating-relation-origin | ||
|
|
||
| if (response.status !== 200) { | ||
| logError(`getRelatedOrigins error: HTTP status code is ${response.status}`); | ||
| return []; | ||
| } | ||
|
|
||
| const isJson = response?.headers?.get('content-type')?.includes('application/json'); | ||
| if (!isJson) { | ||
| logError('getRelatedOrigins error: Content-Type is not JSON'); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,7 +23,7 @@ const checkErrors = function(pkOptions, sameOriginWithAncestors) { | |
| throw new DOMException('Cross-origin register or authentication is not allowed.', DOMException.NotAllowedError); | ||
| } | ||
|
|
||
| if (pkOptions.challenge.length < 16) { | ||
| if (!Number.isSafeInteger(pkOptions.challenge?.byteLength) || pkOptions.challenge.byteLength < 16) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I want to make sure
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does your silence mean that I should refuse this additional check anyway?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My silence means I haven't answered you yet. |
||
| throw new TypeError('challenge is shorter than required minimum length.'); | ||
| } | ||
| }; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.