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 errors for undersize decode buffers and trailing whitespace #163

Merged

Conversation

tarcieri
Copy link
Collaborator

The length calculations we presently perform are dependent on whitespace-free inputs.

This adds an (unfortunately non-constant time) check that the last character is NOT whitespace. Ideally this would be replaced with a constant time "trim" function that can slice away leading/trailing
whitespace, but for now this gives a meaningful error.

It also adds checks that buffers are correctly sized to receive the resulting output, where otherwise it would've panicked for an undersize buffer. This is a potential DoS vector if subtle-encoding was used on untrusted inputs.

The length calculations we presently perform are dependent on
whitespace-free inputs.

This adds an (unfortunately non-constant time) check that the *last*
character is *NOT* whitespace. Ideally this would be replaced with a
constant time "trim" function that can slice away leading/trailing
whitespace, but for now this gives a meaningful error.

It also adds checks that buffers are correctly sized to receive the
resulting output, where otherwise it would've panicked for an undersize
buffer. This is a potential DoS vector if subtle-encoding was used on
untrusted inputs.
@tarcieri tarcieri merged commit c0a28f7 into master Mar 12, 2019
@tarcieri tarcieri deleted the subtle-encoding/length-and-whitespace-handling-fixes branch March 12, 2019 17:21
@tarcieri tarcieri mentioned this pull request Mar 12, 2019
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.

None yet

2 participants