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

RSE-1052: fix IP disclosure when request doesnt have Host header #9110

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

Conversation

carlosrfranco
Copy link
Contributor

@carlosrfranco carlosrfranco commented May 7, 2024

Is this a bugfix, or an enhancement? Please describe.
When performing a request to Rundeck with no Host header, the internal IP is revealed on the response

Describe the solution you've implemented
This PR add a customizer that is enabled by the config rundeck.feature.setServerUrlOnNoHostHeader.enabled that will force the serverUrl and serverPort in the response if there is no Host header on request

Describe alternatives you've considered

Additional context

@carlosrfranco carlosrfranco self-assigned this May 7, 2024
@mrdubr
Copy link
Contributor

mrdubr commented May 16, 2024

Testing the solution feasibility:

GET http://127.0.0.1:4440 HTTP/1.1
Accept: application/vnd.pagerduty+json;version=2
Content-Type: application/json

HTTP/1.1 302 Found
Connection: close
Date: Thu, 16 May 2024 19:20:23 GMT
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
Location: http://127.0.0.1:4440/user/login

By passing the host header in:

GET http://127.0.0.1:4440 HTTP/1.1
Accept: application/vnd.pagerduty+json;version=2
Content-Type: application/json
Host: localhost:4440

HTTP/1.1 302 Found
Connection: close
Date: Thu, 16 May 2024 19:20:43 GMT
Vary: Origin, Access-Control-Request-Method, Access-Control-Request-Headers
Location: http://localhost:4440/user/login

Copy link
Contributor

@mrdubr mrdubr left a comment

Choose a reason for hiding this comment

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

Please, see my comments

@@ -50,6 +55,9 @@ class JettyServletContainerCustomizer implements WebServerFactoryCustomizer<Jett
}
})
factory.addServerCustomizers(new BanHttpMethodCustomizer())
if(featureService.featurePresent("setServerUrlOnNohostHeader", false)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it possible that the server.address is not configured?
If so, I'm pretty sure the redirects (302s) will break.

@carlosrfranco carlosrfranco marked this pull request as ready for review May 22, 2024 19:49
@carlosrfranco carlosrfranco requested a review from mrdubr May 24, 2024 18:00
Copy link
Contributor

@mrdubr mrdubr left a comment

Choose a reason for hiding this comment

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

Looks much cleaner! Almost there!
Added a minor comment and a question.

@@ -3,6 +3,7 @@ package rundeckapp.init.servlet
import org.eclipse.jetty.http.HttpMethod
import org.eclipse.jetty.http.HttpStatus
import org.eclipse.jetty.server.Connector
import org.eclipse.jetty.server.HostHeaderCustomizer
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you still need it?

@@ -50,6 +54,9 @@ class JettyServletContainerCustomizer implements WebServerFactoryCustomizer<Jett
}
})
factory.addServerCustomizers(new BanHttpMethodCustomizer())
if(featureService.featurePresent("setServerUrlOnNoHostHeader", false) && serverUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: for future considerations...
For minor perf improvements, it's recommended to order && checks from least expensive to most expensive.

@mrdubr
Copy link
Contributor

mrdubr commented May 24, 2024

Can you also please mark this PR as a "bugbash candidate". Thanks!

Copy link
Contributor

@mrdubr mrdubr left a comment

Choose a reason for hiding this comment

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

Looks great! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants