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

Switch to forked httprouter and enable UseRawPath option #11068

Merged
merged 15 commits into from
Apr 19, 2022

Conversation

Tener
Copy link
Contributor

@Tener Tener commented Mar 11, 2022

The httprouter package mishandles the URL-encoded / present in request paths. Despite requests and available PRs, this hasn't been fixed:

We are affected by this issue in many ways, e.g.:

This PR fixes the problem by switching to our fork of httprouter: https://github.com/gravitational/httprouter, which has one of the proposed patches applied. The fork's main branch is teleport, which is based on tag 1.3.0v we were using.

The fork adds UseRawPath option to the router, which is false by default to maintain backward compatibility.

Here we enable that option for all our usages of the router. To verify the fix to our routing, a single test is added (taken from #11011).

Fixes TEL-Q122-7.

@Tener Tener changed the title Use patched httprouter and enable UseRawPath option Switch to forked httprouter and enable UseRawPath option Apr 8, 2022
@Tener Tener marked this pull request as ready for review April 8, 2022 08:37
@Tener Tener requested review from zmb3 and probakowski April 8, 2022 08:37
@zmb3
Copy link
Collaborator

zmb3 commented Apr 8, 2022

I see that this will indeed fix the problem, but I can't help but ask if we should really be using httprouter at all? It's clearly no longer maintained, and each new fork we pull in creates additional burden on us.

I'm fine with merging this, but I wonder if we should also evaluate using a different router that is actively maintained.

@Tener
Copy link
Contributor Author

Tener commented Apr 11, 2022

I see that this will indeed fix the problem, but I can't help but ask if we should really be using httprouter at all? It's clearly no longer maintained, and each new fork we pull in creates additional burden on us.

I'm fine with merging this, but I wonder if we should also evaluate using a different router that is actively maintained.

Indeed the httprouter doesn't look active right now: after 1.3.0 there was ~1 year of commits, but now it is 2 years of silence. Strangely, the PRs I linked were from 2015 and 2017 when the library was in active development. Ignoring these PRs is an argument in favor of moving away from httprouter.

Having said that, I'm worried about the potential costs of the switch. There may be hard-to-find compatibility issues lurking, while the benefits are seemingly few or none?

Copy link
Contributor

@codingllama codingllama left a comment

Choose a reason for hiding this comment

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

Looks reasonable to me, although I didn't go all the way digging on httprouter or UseRawPath.

lib/web/apiserver_test.go Outdated Show resolved Hide resolved
@codingllama
Copy link
Contributor

Having said that, I'm worried about the potential costs of the switch. There may be hard-to-find compatibility issues lurking, while the benefits are seemingly few or none?

That's true, it's a scary change to make. I think the lesson is to be very careful about the dependencies we pull in, specially far reaching ones like httprouter.

My 2c is that best way to "fix" this is to kill all REST APIs in favor of gRPC. One can dream. :)

@zmb3

@Tener
Copy link
Contributor Author

Tener commented Apr 11, 2022

My 2c is that best way to "fix" this is to kill all REST APIs in favor of gRPC. One can dream. :)

There are at least two of us dreaming the same dream 😄

@zmb3
Copy link
Collaborator

zmb3 commented Apr 12, 2022

There are at least two three of us dreaming the same dream

@Tener Tener enabled auto-merge (squash) April 13, 2022 08:38
@Tener Tener merged commit 66a676e into master Apr 19, 2022
@Tener Tener deleted the tener/delete-mfa-slashes branch April 19, 2022 07:16
Tener added a commit that referenced this pull request Apr 19, 2022
* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
Tener added a commit that referenced this pull request Apr 19, 2022
* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
Tener added a commit that referenced this pull request Apr 20, 2022
…#12080)

* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
Tener added a commit that referenced this pull request Apr 20, 2022
…#12081)

* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
Tener added a commit that referenced this pull request Apr 20, 2022
* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
Tener added a commit that referenced this pull request Apr 21, 2022
…#12109)

* Use forked httprouter with RawPath fix: gravitational/httprouter

* Enable UseRawPath everywhere.

* Test: allow MFA devices with `/` in names to be deleted

Co-authored-by: Przemko Robakowski <przemko.robakowski@goteleport.com>
@webvictim webvictim mentioned this pull request Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants