Skip to content

Fix URL prefix matching to require path boundaries#19154

Open
charliermarsh wants to merge 1 commit intomainfrom
charlie/path-prefix
Open

Fix URL prefix matching to require path boundaries#19154
charliermarsh wants to merge 1 commit intomainfrom
charlie/path-prefix

Conversation

@charliermarsh
Copy link
Copy Markdown
Member

Summary

We're using url.path().starts_with(self.root_url.path()) and similar logic in a few places, which treats https://example.com/foobar as a subpath of https://example.com/foo, when these should really be at path boundaries.

///
/// The URL must be in the same realm, or a subdomain of the endpoint realm, and must be under the
/// endpoint path using complete path-segment prefix matching.
fn is_endpoint_url(url: &Url, endpoint_url: &Url) -> bool {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The main fix looks good, but this part should go into another PR.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Why is that?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Isn't this the same fix -- just taking the existing check and also requiring that it's a path prefix?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I see, can you update the PR description to say something about realm vs. URL too? The S3_ENDPOINT_REALM -> S3_ENDPOINT_URL change wasn't clear to me on reading through it, as it didn't do prefix matching in the old version.

@charliermarsh charliermarsh marked this pull request as ready for review April 26, 2026 02:12
@charliermarsh charliermarsh added the bug Something isn't working label Apr 26, 2026
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

Successfully merging this pull request may close these issues.

2 participants