Skip to content
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

fix(api): mask db related errors #4967

Merged

Conversation

alicelovescake
Copy link
Contributor

tldr;
This PR fixes the issue where errors caused by serverless functions can leak sensitive information

Changes made

  • Created a generic error with message: "unknown error occurred" in packages/api/src/functions/dbAuth/errors.ts
  • Added try catch blocks around all database calls within the file packages/api/src/functions/dbAuth/DbAuthHandler.ts in case of invalid client
  • Catches error and console log actual error but throws the generic error
  • Added additional tests to confirm expected behavior

Open to lots of feedback! Happy to iterate on the approach or verbiage of the generic error we want to show to user


closes #4679

@netlify
Copy link

netlify bot commented Mar 30, 2022

Deploy Preview for redwoodjs-docs canceled.

Name Link
🔨 Latest commit 294be0e
🔍 Latest deploy log https://app.netlify.com/sites/redwoodjs-docs/deploys/6253e331e5307a0008af4506

@alicelovescake alicelovescake force-pushed the mask-errors-by-serverless-functions branch from 44606a5 to fc8145a Compare March 30, 2022 08:07
@dthyresson
Copy link
Contributor

Thanks @alicelovescake - this appears to cover one of the cases described in #4679 where an dbAuth db error info can get leaked.

@dthyresson
Copy link
Contributor

@alicelovescake Oh, I just realized that this is the framework and the app -- I realized that, too, when I wrote up that issue but forgot. You're right. Console is the only way to go. Sorry about that.

@alicelovescake
Copy link
Contributor Author

@alicelovescake Oh, I just realized that this is the framework and the app -- I realized that, too, when I wrote up that issue but forgot. You're right. Console is the only way to go. Sorry about that.

no worries! You are probably juggling a million tickets and issues. Appreciate you taking a look at this one. Let me know anything else you recommend I should do get get this PR ready to merge!

@dthyresson
Copy link
Contributor

Let me know anything else you recommend I should do get get this PR ready to merge!

Should we consider different naming for GenericError -- @dac09 thoughts?

Are there other dbauth-related errors?

@dthyresson dthyresson requested a review from dac09 April 5, 2022 13:46
Copy link
Collaborator

@dac09 dac09 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an amazing PR and description (as always) @alicelovescake

I like the GenericError name too @dthyresson!

I assume there's already a test case for what it displays with GenericError on the frontend?

@dac09 dac09 added the release:fix This PR is a fix label Apr 7, 2022
@alicelovescake
Copy link
Contributor Author

alicelovescake commented Apr 8, 2022

This is an amazing PR and description (as always) @alicelovescake

I like the GenericError name too @dthyresson!

I assume there's already a test case for what it displays with GenericError on the frontend?

Thanks for the feedback @dac09! I added 3 tests in the /dbAuth/__tests__/DbAuthHandler.test.js that checks for this generic error if the dbAccessor is undefined (aka invalid client). Does this fit what you are looking for or is there another test you think I should write?

I know you already approved but I just want to resolve any questions before I merge!

@dac09
Copy link
Collaborator

dac09 commented Apr 8, 2022

Does this fit what you are looking for or is there another test you think I should write?

I think your tests are fine @alicelovescake - I was just checking if we had additional tests for custom login or signup error messages - and we do!

I've also manually verified on Gitpod that the messages do come through!

@jtoar
Copy link
Contributor

jtoar commented Apr 10, 2022

Looks like the smoke test is failing consistently (nothing you did @alicelovescake!); and it seems to be the same as this issue that was just reported: #5104.

@dac09 dac09 enabled auto-merge (squash) April 11, 2022 08:13
@dac09 dac09 merged commit 4c7860b into redwoodjs:main Apr 11, 2022
@jtoar jtoar added this to the next-release milestone Apr 11, 2022
thedavidprice pushed a commit that referenced this pull request Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix This PR is a fix
Projects
No open projects
Status: Archived
Development

Successfully merging this pull request may close these issues.

Serverless function errors can leak sensitive info and are not masked like GraphQL Errors
5 participants