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

fix(router) properly escape uri captures #8139

Closed
wants to merge 1 commit into from

Conversation

bungle
Copy link
Member

@bungle bungle commented Dec 2, 2021

Summary

When we added normalization kong.tools.uri.normalize, that function does percent-decoding on everything, except for the reserved characters.

That means that we basically percent-decode more than just the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E).

Which is fine for matching (as we run both inputs through it). Though calling it normalize is wrong, but that is another issue.

Because of doing excessive percent-decoding, we endup things leaking from there. One of the leakeage is uri captures that now contain the captures based on our raw normalization.

This commit adds escaping to uri captures, and should fix the leak.

Alternative to this is to not percent-decode the chars outside the ones specified above.

Issues resolved

Fix #7913, FTI-2904

Alternative and Better Implementation

See #8140

### Summary

When we added normalization `kong.tools.uri.normalize`, that function
does percent-decoding on everything, except for the reserved characters.

That means that we basically percent-decode more than just the ranges of
ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E),
underscore (%5F), or tilde (%7E).

Which is fine for matching (as we run both inputs through it). Though
calling it `normalize` is wrong, but that is another issue.

Because of doing excessive percent-decoding, we endup things leaking from
there. One of the leakeage is uri captures that now contain the captures
based on our raw normalization.

This commit adds escaping to uri captures, and should fix the leak.
@bungle bungle added the pr/discussion This PR is being debated. Probably just a few details. label Dec 2, 2021
@bungle bungle requested a review from dndx December 2, 2021 11:06
@bungle
Copy link
Member Author

bungle commented Dec 2, 2021

I personally like #8140 better.

bungle added a commit that referenced this pull request Dec 2, 2021
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
bungle added a commit that referenced this pull request Dec 7, 2021
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
@bungle bungle closed this Dec 7, 2021
bungle added a commit that referenced this pull request Dec 20, 2021
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
bungle added a commit that referenced this pull request Jan 3, 2022
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
bungle added a commit that referenced this pull request Jan 18, 2022
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
dndx pushed a commit that referenced this pull request Jan 24, 2022
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
bungle added a commit that referenced this pull request Feb 1, 2022
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
bungle added a commit that referenced this pull request May 9, 2022
### Summary

This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
StarlightIbuki pushed a commit that referenced this pull request Jun 27, 2022
This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
StarlightIbuki pushed a commit that referenced this pull request Jul 14, 2022
This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
StarlightIbuki pushed a commit that referenced this pull request Jul 18, 2022
This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
StarlightIbuki pushed a commit that referenced this pull request Jul 22, 2022
This is alternative to PR #8139 where we actually fix the normalization
function to not do excessive percent-decoding on normalization.
fffonion pushed a commit that referenced this pull request Jul 26, 2022
We decide to let `normalize` function to decode URL-encoded string as much as possible.

**PLEASE REFERER TO**: #8140 (comment)

### Issues resolved

Fix #7913, FTI-2904

Outdated discussion:

----------------------

This is alternative to PR #8139 where we actually fix the normalization function to not do excessive percent-decoding on normalization.

When we added normalization kong.tools.uri.normalize, that function does percent-decoding on everything, except for the reserved characters.

That means that we basically percent-decode more than just the ranges of ALPHA (%41–%5A and %61–%7A), DIGIT (%30–%39), hyphen (%2D), period (%2E), underscore (%5F), or tilde (%7E). (so called Unreserved Characters)

Alternative Implementation: See #8139
@bungle bungle deleted the fix/router-uri-captures-escaping branch September 14, 2022 08:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr/discussion This PR is being debated. Probably just a few details.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uri_captures are url decoded
1 participant