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

HashWithOptions regex matches invalid attributes #2441

Closed
rtkdpalozzi opened this issue Nov 16, 2023 · 2 comments
Closed

HashWithOptions regex matches invalid attributes #2441

rtkdpalozzi opened this issue Nov 16, 2023 · 2 comments
Labels
bug Something isn't working

Comments

@rtkdpalozzi
Copy link

Bug Description

it looks like the regex at https://github.com/nodejs/undici/blob/main/lib/fetch/util.js#L604 (/((?<algo>sha256|sha384|sha512)-(?<hash>[A-z0-9+/]{1}.*={0,2}))( +[\x21-\x7e]?)?/i) is incorrect in a few different ways. A-z will also match [\]^_ which are invalid base64 characters, and the range [A-z0-9+/] is only matched once anyways - the second character and all others until any padding are matched via .*. i didn't fully read the spec but i believe the latter half, ( +[\x21-\x7e]?)?, is also incorrect and won't accurately match the option-expression

Reproducible By

N/A

Expected Behavior

The regex should only match valid integrity attributes and no other values.

Logs & Screenshots

N/A

Environment

N/A

Additional context

@rtkdpalozzi rtkdpalozzi added the bug Something isn't working label Nov 16, 2023
@KhafraDev
Copy link
Member

Would you like to send in a PR? Remember to add tests.

@Uzlopak
Copy link
Contributor

Uzlopak commented Jan 27, 2024

@nodejs/undici

The PR got merged, so this issue is solved ;)

@anonrig anonrig closed this as completed Jan 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants