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 2 commits into
base: main
Choose a base branch
from

Conversation

carlosrfranco
Copy link
Contributor

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

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

@mrdubr mrdubr May 16, 2024

Choose a reason for hiding this comment

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

Suggested change
factory.addServerCustomizers(new RundeckHostHeaderCustomizer(serverUrl, Integer.parseInt(serverPort ?: "4440")))
factory.addServerCustomizers(new RundeckHostHeaderCustomizer(serverUrl: serverUrl, serverPort : Integer.parseInt(serverPort ?: "4440")))

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

String serverUrl
int serverPort

RundeckHostHeaderCustomizer(String serverUrl) {
Copy link
Contributor

Choose a reason for hiding this comment

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

you don't need the explicit constructors in groovy.

In Groovy, the default constructor is a no-argument constructor that is automatically provided by the language if no other constructors are defined. This constructor allows you to create an instance of a class without passing any arguments. Additionally, Groovy's default constructor enables you to use named parameters in a map-like syntax to set properties when creating an instance of the class.

@@ -24,6 +25,28 @@ class BanHttpMethodCustomizer implements JettyServerCustomizer {
}
}

class RundeckHostHeaderCustomizer implements JettyServerCustomizer {
Copy link
Contributor

Choose a reason for hiding this comment

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

IIUIC, this inner class does not logically belong to the BanHttpMethodCustomizer class.

@@ -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
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

2 participants