cds-snc / platform-forms-client

NextJS application that serves the public-facing website for Forms
https://forms-staging.cdssandbox.xyz/
MIT License
28 stars 12 forks source link

Sanitize Cognito Errors #2284

Open bryan-robitaille opened 1 year ago

bryan-robitaille commented 1 year ago

Any call to Cognito should only return sanitized errors to the Browser.

Acceptable error messages back to the browser from @lib/auth/cognito/initiateSignIn can include:

Acceptable error messages back to the browser from @pages/api/account/confirmpassword can include:

Acceptable error messages back to the browser from @pages/api/account/forgotpassword can include:

Acceptable error messages back to the browser from @pages/api/account/register can include:

thiessenp-cds commented 1 year ago

For future reference here is a branch I did some initial work on: fix/sanitize-cognito-errors So far this is more of a proof of concept. The approach I took was to use a function that holds logic to sanitize cognito errors by replacing any sensitive error with a generic error. I also added some error enums and a response interface to help make consistency easier