Skip to content
This repository was archived by the owner on Sep 21, 2025. It is now read-only.
This repository was archived by the owner on Sep 21, 2025. It is now read-only.

Starts_with when fetching jku  #109

@snyff

Description

@snyff

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://[email protected] 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions