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

Starts_with when fetching jku #109

Open
snyff opened this issue Mar 12, 2019 · 0 comments
Open

Starts_with when fetching jku #109

snyff opened this issue Mar 12, 2019 · 0 comments

Comments

@snyff
Copy link

snyff commented Mar 12, 2019

Hi,

I was looking at the code and it seems like starts_with may not be the ideal method here (or maybe some level of canonicalisation would be good):

key_prefixes.any? { |acceptable| key_url.starts_with?(acceptable) }

Example:
http://trusted.com/.well-known/../bad/another_file.json starts_with? http://trusted.com/.well-known/
http://trusted.com/.well-known/../bad/another_bug starts_with? http://trusted.com/.well-known/
http://trusted.com@example.org starts_with? http://trusted.com

One good thing is that your http client configuration doesn't follow redirect so it makes exploitation a lot harder.

It may also be good to enforce the scheme to https in

json = http_request.get(mapped_url(key_url)).body
for people using your library and to follow the RFC.

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

No branches or pull requests

1 participant