Improper validation of the next_urls parameter #16702
Labels
severity: low
Does not significantly disrupt application functionality, or a workaround is available
status: accepted
This issue has been accepted for implementation
type: bug
A confirmed report of unexpected behavior in the application
Deployment Type
Self-hosted
NetBox Version
v3.7.5
Python Version
3.10
Steps to Reproduce
The NetBox application makes use of redirection on several endpoints. The redirect URL is being supplied through the
next_urls
parameter.The HTTP parameter next_urls gets filtered by the following snippet in order to only accept relative URL:
However, the filtering function is only checking that the supplied parameter next_url starts with a /.
This way, it is possible to circumvent this filtering by supplying a double-slashed payload. As an example the following payload would work : //www.google.com
As expected, once the request is submitted, the application responds with a 302 status code which includes the new location header :
One could expect the redirection to fail. Indeed, according to RFC 7231, which defines HTTP/1.1 semantics and content, the Location header field's value must be a valid URI reference.
However, as the RFC does not explicitly mention schema less URLs, they are considered valid URI references. As such it is up to the browser to decide which default schema to use. For Chrome and Firefox it is defaulting to HTTP or HTTPS resulting in a valid redirection.
Expected Behavior
An HTTP error response or a redirect to the main page.
Observed Behavior
Redirect to the targeted website.
The text was updated successfully, but these errors were encountered: