Skip to content

LG-10457: Track unexpected WebAuthn errors#8859

Merged
aduth merged 2 commits intomainfrom
aduth-lg-10457-track-unexpected-errors
Jul 27, 2023
Merged

LG-10457: Track unexpected WebAuthn errors#8859
aduth merged 2 commits intomainfrom
aduth-lg-10457-track-unexpected-errors

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Jul 25, 2023

🎫 Ticket

LG-10457

🛠 Summary of changes

Adds error tracking for "unexpected" errors that occur during WebAuthn enrollment or authentication. An unexpected error is one not occurring as an outcome of the WebAuthn API ceremony, but rather may point to errors in our own code.

See Slack discussion: https://gsa-tts.slack.com/archives/C01710KMYUB/p1690308232479249

📜 Testing Plan

Test expected errors:

Add a breakpoint to trackError:

diff --git a/app/javascript/packages/analytics/index.ts b/app/javascript/packages/analytics/index.ts
index 1f0f43d4c..ee31274f3 100644
--- a/app/javascript/packages/analytics/index.ts
+++ b/app/javascript/packages/analytics/index.ts
@@ -33,2 +33,3 @@ export function trackEvent(event: string, payload?: object) {
 export function trackError(error: Error) {
+  debugger;
   (globalThis as typeof globalThis & NewRelicGlobals).newrelic?.noticeError(error);

Create or sign in to an account with Face or Touch Unlock, cancel the ceremony, and observe that the breakpoint is not triggered.

Test unexpected errors:

Keep the above breakpoint, and add some artificial errors:

diff --git a/app/javascript/packages/webauthn/enroll-webauthn-device.ts b/app/javascript/packages/webauthn/enroll-webauthn-device.ts
index 4d4c19e19..2eb4f53eb 100644
--- a/app/javascript/packages/webauthn/enroll-webauthn-device.ts
+++ b/app/javascript/packages/webauthn/enroll-webauthn-device.ts
@@ -30,2 +30,3 @@ async function enrollWebauthnDevice({
 }: EnrollOptions): Promise<EnrollResult> {
+  throw new Error();
   const credential = (await navigator.credentials.create({
diff --git a/app/javascript/packages/webauthn/verify-webauthn-device.ts b/app/javascript/packages/webauthn/verify-webauthn-device.ts
index ee39c2016..c2fa3d501 100644
--- a/app/javascript/packages/webauthn/verify-webauthn-device.ts
+++ b/app/javascript/packages/webauthn/verify-webauthn-device.ts
@@ -36,2 +36,3 @@ async function verifyWebauthnDevice({
 }: VerifyOptions): Promise<VerifyResult> {
+  throw new Error();
   const credential = (await navigator.credentials.get({

Create or sign in to an account with Face or Touch Unlock, and observe that the breakpoint is triggered when initiating the WebAuthn ceremony.

changelog: Upcoming Features, Face or Touch Unlock, Log unexpected errors during WebAuthn enrollment or authentication
@aduth aduth requested a review from a team July 25, 2023 18:38
@aduth
Copy link
Contributor Author

aduth commented Jul 27, 2023

I revised the implementation slightly based on the issue reported in #8877 to ensure that the error being thrown there would have been noticed by the error tracking introduced here. The error in Firefox is an UnknownError DOMException. Rather than ignore all DOMException, d044abf changes it so that we just ignore the specific user DOMException that are uninteresting (user declined permission or timeout due to inactivity).

This might still end up being too noisy, but we can follow-up to filter out more error types based on what we see in the error tracker.

@aduth aduth merged commit 7ae572c into main Jul 27, 2023
@aduth aduth deleted the aduth-lg-10457-track-unexpected-errors branch July 27, 2023 13:45
@amirbey amirbey mentioned this pull request Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants