Skip to content

Conversation

@sanikachavan5
Copy link
Contributor

@sanikachavan5 sanikachavan5 commented Aug 31, 2025

Description

This pull request addresses a security issue in the UIMetricsProxy handler by improving how proxied URL paths are cleaned and validated to prevent path traversal attacks. The main focus is on ensuring that user-supplied paths cannot escape the intended base URL, even in edge cases.

Security improvements to URL path handling:

  • Paths are now cleaned using path.Clean with a leading slash to ensure that any ../ segments are properly removed, preventing path traversal attacks. (agent/ui_endpoint.go)
  • The previous redundant cleaning of the parsed URL path after construction has been removed, as the cleaning is now handled earlier and more securely. (agent/ui_endpoint.go)

Base URL validation enhancements:

  • The check for whether the target URL is within the base URL now ensures the base URL has a trailing slash for proper prefix matching, and allows an exact match of the base URL without the trailing slash. This prevents attackers from escaping the base path by manipulating the URL. (agent/ui_endpoint.go)

Testing & Reproduction steps

Links

PR Checklist

  • updated test coverage
  • external facing docs updated
  • appropriate backport labels added
  • not a security concern

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.

  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.

  • If applicable, I've documented the impact of any changes to security controls.

    Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@sanikachavan5 sanikachavan5 requested a review from a team as a code owner August 31, 2025 17:42
@sanikachavan5 sanikachavan5 added backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 backport/ent/1.21 changes are backported to 1.21 ent labels Sep 2, 2025
// handler, can't backtrack far enough to eat into the BaseURL either. But we
// leave this in anyway in case something changes in the future.
if !strings.HasPrefix(u.String(), cfg.BaseURL) {

Copy link
Collaborator

Choose a reason for hiding this comment

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

can we add UT for this

@@ -0,0 +1,3 @@
```release-note:security
security: Fix path cleaning of proxied urls.
Copy link
Member

Choose a reason for hiding this comment

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

Nit : security: Fixed proxied URL path validation to prevent path traversal.

Copy link
Collaborator

@dduzgun-security dduzgun-security left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this, I've added few comments on the PR to review

@sanikachavan5 sanikachavan5 force-pushed the sanikachavan5/SECVULN-25362-fix-path-cleaning-of-proxied-urls branch from 341333c to 0753e55 Compare September 4, 2025 19:13
Copy link
Collaborator

@dduzgun-security dduzgun-security left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for addressing the comments.

@sanikachavan5 sanikachavan5 merged commit f278040 into main Sep 22, 2025
110 checks passed
@hc-github-team-consul-core hc-github-team-consul-core added the backport/1.21 This release series is longer active on CE, use backport/ent/1.21 label Sep 22, 2025
sanikachavan5 added a commit that referenced this pull request Sep 23, 2025
* fix path cleaning of proxied urls

* add changelog

* added more tests

* add tests and address review comments

* address review changes
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

7 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

4 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.18,1.19,1.20,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

3 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19,1.21] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

20 similar comments
@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

@hc-github-team-consul-core
Copy link
Collaborator

📣 Hi @sanikachavan5! a backport is missing for this PR [22671] for versions [1.19] please perform the backport manually and add the following snippet to your backport PR description:

<details>
	<summary> Overview of commits </summary>
		- <<backport commit 1>>
		- <<backport commit 2>>
		...
</details>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/all Apply backports for all active releases per .release/versions.hcl backport/ent/1.18 Changes are backported to 1.18 ent backport/ent/1.19 Changes are backported to 1.19 ent backport/ent/1.20 backport to ent 1.20 backport/ent/1.21 changes are backported to 1.21 ent backport/1.21 This release series is longer active on CE, use backport/ent/1.21

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants