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

Added verification of X-HTTP-Method-Override before use #1556

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

KilledKenny
Copy link

Verify that the method in X-HTTP-Method-Override is a valid method
before use using it. Validation is performed using the same logic
as net/http dose. This prevents a routing confusion vulnerability
that allowed an attacker to control the entire internal revel routing
path (used to find a controller) via the override header. This issue can
be problematic in instances where authentication is based on the path
for example in a revel.Filter or if the revel app is behind a reverse
proxy.

Verify that the method in X-HTTP-Method-Override is a valid method
before use using it. Validation is performed using the same logic
as net/http dose. This prevents a routing confusion vulnerability
that allowed an attacker to control the entire internal revel routing
path (used to find a controller) via the override header. This issue can
be problematic in instances where authentication is based on the path
for example in a revel.Filter or if the revel app is behind a reverse
proxy.
@KilledKenny
Copy link
Author

this fix is almost identical to #1555. The functional difference is that my fix ignores the header when its invalid while movitz-s fix will return nil if the header is invalid.

@notzippy notzippy changed the base branch from master to develop June 7, 2022 01:18
@notzippy
Copy link
Collaborator

notzippy commented Jun 7, 2022

This looks good to me - @brendensoares thoughts?

@@ -169,7 +180,7 @@ type Router struct {

func (router *Router) Route(req *Request) (routeMatch *RouteMatch) {
// Override method if set in header
if method := req.GetHttpHeader("X-HTTP-Method-Override"); method != "" && req.Method == "POST" {
if method := req.GetHttpHeader("X-HTTP-Method-Override"); method != "" && req.Method == "POST" && validMethod(method) {
Copy link
Member

Choose a reason for hiding this comment

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

It would be valuable to add a comment here for the context of why this line is necessary. Context for our future coders and our future selves.

Copy link
Author

Choose a reason for hiding this comment

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

Improved the comment

Copy link
Member

Choose a reason for hiding this comment

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

I mean we should note that this is required to negate the vulnerability. For example, you described to me privately this way:

We found that it was possible to control the http req path via the header X-HTTP-Method-Override. This issue can be problematic in instances where authentication is based on the path for example in a revel.Filter or if the revel app is behind a reverse proxy.

Copy link
Author

Choose a reason for hiding this comment

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

added more meat to the comment

router.go Show resolved Hide resolved
router.go Show resolved Hide resolved
@brendensoares
Copy link
Member

I appreciate the unit tests you included, but could you also provide steps to reproduce the vulnerability so we can verify this correctly addresses it?

Thank you for contributing to Revel and OSS!

router.go Outdated Show resolved Hide resolved
router.go Outdated Show resolved Hide resolved
@@ -169,7 +180,7 @@ type Router struct {

func (router *Router) Route(req *Request) (routeMatch *RouteMatch) {
// Override method if set in header
if method := req.GetHttpHeader("X-HTTP-Method-Override"); method != "" && req.Method == "POST" {
if method := req.GetHttpHeader("X-HTTP-Method-Override"); method != "" && req.Method == "POST" && validMethod(method) {
Copy link
Member

Choose a reason for hiding this comment

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

I mean we should note that this is required to negate the vulnerability. For example, you described to me privately this way:

We found that it was possible to control the http req path via the header X-HTTP-Method-Override. This issue can be problematic in instances where authentication is based on the path for example in a revel.Filter or if the revel app is behind a reverse proxy.

@brendensoares
Copy link
Member

Added new code review comments.

Also, I got your proof of concept code to test for this vulnerability in gitter. Thank you.

.. why it's inportant that validMethod is called on repalce method
wiselike pushed a commit to wiselike/revel that referenced this pull request Apr 5, 2024
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

Successfully merging this pull request may close these issues.

None yet

3 participants