diff options
author | Matthew Miller <matthew@millerti.me> | 2021-08-22 14:06:33 -0700 |
---|---|---|
committer | Matthew Miller <matthew@millerti.me> | 2021-08-22 14:06:33 -0700 |
commit | 1a832c613d69d58fe0ee046976db60e1e5996fa6 (patch) | |
tree | 34799e5b052f9c325a260dd6eb1013606fb6a1b2 /packages/server/src/helpers/parseAuthenticatorData.ts | |
parent | f4dd26ffea847946c5a757133aa3d4dfb800b387 (diff) |
Fix parsing extension data in auth data
Diffstat (limited to 'packages/server/src/helpers/parseAuthenticatorData.ts')
-rw-r--r-- | packages/server/src/helpers/parseAuthenticatorData.ts | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/packages/server/src/helpers/parseAuthenticatorData.ts b/packages/server/src/helpers/parseAuthenticatorData.ts index 9b13195..911c9e0 100644 --- a/packages/server/src/helpers/parseAuthenticatorData.ts +++ b/packages/server/src/helpers/parseAuthenticatorData.ts @@ -45,17 +45,18 @@ export default function parseAuthenticatorData(authData: Buffer): ParsedAuthenti const firstDecoded = decodeCborFirst(authData.slice(pointer)); const firstEncoded = Buffer.from(cbor.encode(firstDecoded) as ArrayBuffer); credentialPublicKey = firstEncoded; - authData = authData.slice((pointer += firstEncoded.byteLength)); + pointer += firstEncoded.byteLength; } let extensionsDataBuffer: Buffer | undefined = undefined; if (flags.ed) { - const firstDecoded = decodeCborFirst(authData); + const firstDecoded = decodeCborFirst(authData.slice(pointer)); const firstEncoded = Buffer.from(cbor.encode(firstDecoded) as ArrayBuffer); extensionsDataBuffer = firstEncoded; - authData = authData.slice((pointer += firstEncoded.byteLength)); + pointer += firstEncoded.byteLength; } + // Pointer should be at the end of the authenticator data, otherwise too much data was sent if (authData.byteLength > pointer) { throw new Error('Leftover bytes detected while parsing authenticator data'); } |