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

Return a UserError if aead.Open() fails to align with documentation #10914

Merged
merged 2 commits into from
Nov 17, 2021

Conversation

crozzy
Copy link
Contributor

@crozzy crozzy commented Feb 12, 2021

As mentioned in this issue: #10842 the API documentation states that:

500 - Internal server error. An internal error has occurred, try again later. If the error persists, report a bug.
400 - Invalid request, missing or invalid data.

This change means that failures in key decryption at the aead.Open() step will result in a 400 status code being returned as opposed to a 500 as the problem probably originates from incorrect user data entry (there are other possibilites I imagine).

@hashicorp-cla
Copy link

hashicorp-cla commented Feb 12, 2021

CLA assistant check
All committers have signed the CLA.

@vercel vercel bot temporarily deployed to Preview – vault-storybook February 12, 2021 19:24 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 12, 2021 19:24 Inactive
@crozzy crozzy force-pushed the user-error-for-failed-decryption branch from c53bd7a to 2fa1338 Compare February 12, 2021 20:55
@vercel vercel bot temporarily deployed to Preview – vault February 12, 2021 20:55 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 12, 2021 20:55 Inactive
@crozzy crozzy force-pushed the user-error-for-failed-decryption branch from 2fa1338 to f05c449 Compare February 12, 2021 20:57
@vercel vercel bot temporarily deployed to Preview – vault-storybook February 12, 2021 20:58 Inactive
@vercel vercel bot temporarily deployed to Preview – vault February 12, 2021 20:58 Inactive
@crozzy crozzy marked this pull request as ready for review February 12, 2021 21:09
@washtubs
Copy link

Note the 400 message before was pretty generic : invalid ciphertext: unable to decrypt

Currently the 500 message also tells you what algorithm is used which seems like revealing unnecessary (albeit benign) details. Like if it's a poly1305-chacha20 keyring it will say that in the error message.

@crozzy
Copy link
Contributor Author

crozzy commented Mar 1, 2021

It's an interesting one, traditionally you'd want neither the 500 nor the 400 revealing anything internal but it's also possible to go too far (IMO) at the expense of user experience/debugging. It's also 100% possible that someone changes some code causing aead.Open to always error and instead of 500ing it's masked by a 400.

Probably worth someone working on Vault full-time reviewing it who is aware of those internal decisions.

@victorr
Copy link
Contributor

victorr commented Nov 16, 2021

HI @crozzy, even though issue #10842 was closed, your fix is still relevant. If you want to rebase your PR I'll be happy to review it.

@victorr victorr self-assigned this Nov 16, 2021
@victorr victorr self-requested a review November 16, 2021 21:20
@crozzy crozzy force-pushed the user-error-for-failed-decryption branch from f05c449 to 9c7f107 Compare November 16, 2021 21:29
@vercel vercel bot temporarily deployed to Preview – vault-storybook November 16, 2021 21:29 Inactive
@vercel vercel bot temporarily deployed to Preview – vault November 16, 2021 21:29 Inactive
…e is a problem with the user input for said decryption
@crozzy crozzy force-pushed the user-error-for-failed-decryption branch from 9c7f107 to 660c9e3 Compare November 16, 2021 22:11
@vercel vercel bot temporarily deployed to Preview – vault November 16, 2021 22:11 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook November 16, 2021 22:11 Inactive
@crozzy
Copy link
Contributor Author

crozzy commented Nov 16, 2021

HI @crozzy, even though issue #10842 was closed, your fix is still relevant. If you want to rebase your PR I'll be happy to review it.

Looks like you changed the go.mod set up and the name of master/main since this PR, was pretty confused there for a second 😆

Copy link
Contributor

@victorr victorr left a comment

Choose a reason for hiding this comment

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

👍

@vercel vercel bot temporarily deployed to Preview – vault-storybook November 17, 2021 16:06 Inactive
@vercel vercel bot temporarily deployed to Preview – vault November 17, 2021 16:06 Inactive
@victorr victorr merged commit 580b8bc into hashicorp:main Nov 17, 2021
@victorr
Copy link
Contributor

victorr commented Nov 17, 2021

Thank you for the fix @crozzy, it is very much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants