Skip to content

Fix basePath validation for dashboard template - #12729

Merged
traefiker merged 3 commits into
traefik:v3.6from
gndz07:fix/html-template
Feb 25, 2026
Merged

traefiker merged 3 commits into
traefik:v3.6from
gndz07:fix/html-template

Conversation

@gndz07

@gndz07 gndz07 commented Feb 25, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Replace the imported text/template with html/template for the dashboard template and add validation for the basePath configuration.

Motivation

A stricter regex validation will allow user to be warned early if the URL in their basePath is not a valid URL.
text/template provides no automatic escaping for HTML or JavaScript contexts. Switching to html/template ensures values rendered into the dashboard template are properly escaped, preventing potential injection issues.

More

  • Added/updated tests
  • Added/updated documentation

@gndz07 gndz07 changed the title Use html/template for dashboard template Fix basePath validation for dashboard template Feb 25, 2026
Comment thread pkg/config/static/static_config.go Outdated
Comment thread pkg/config/static/static_config.go Outdated
Comment thread pkg/config/static/static_config_test.go

@mmatur mmatur left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@rtribotte rtribotte left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@traefiker
traefiker merged commit a0654af into traefik:v3.6 Feb 25, 2026
64 of 65 checks passed
)

// Allowed characters in URL following RFC 3986 (https://www.rfc-editor.org/rfc/rfc3986#section-2)
var validBasePath = regexp.MustCompile(`^/[a-zA-Z0-9/_.-]*$`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only glancing over, but I noticed . in the accepted range; is path traversing allowed? (/api/../../, /api/./foo/); not sure if those are problematic or handled elsewhere; mostly curious!

@gndz07 gndz07 Feb 26, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Hello @thaJeztah,

The . character is valid in a URL and may legitimately be used by some users when defining their basePath. Additionally, this value can only be set through the static configuration, meaning it is controlled by a Traefik administrator. Given this condition, we think that path traversal is not a concern in this context at the moment 🙂

alexlebens pushed a commit to alexlebens/infrastructure that referenced this pull request Mar 6, 2026
This PR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [traefik/traefik](https://github.com/traefik/traefik) | patch | `v3.6.9` → `v3.6.10` |

---

### Release Notes

<details>
<summary>traefik/traefik (traefik/traefik)</summary>

### [`v3.6.10`](https://github.com/traefik/traefik/blob/HEAD/CHANGELOG.md#v3610-2026-03-06)

[Compare Source](traefik/traefik@v3.6.9...v3.6.10)

[All Commits](traefik/traefik@v3.6.9...v3.6.10)

**Bug fixes:**

- **\[docker]** Bump Docker and OpenTelemetry dependencies ([#&#8203;12761](traefik/traefik#12761) by [mmatur](https://github.com/mmatur))
- **\[fastproxy]** Bump github.com/valyala/fasthttp to v1.69.0 ([#&#8203;12763](traefik/traefik#12763) by [kevinpollet](https://github.com/kevinpollet))
- **\[healthcheck, grpc]** Remove path parsing with grpc healthcheck ([#&#8203;12760](traefik/traefik#12760) by [rtribotte](https://github.com/rtribotte))
- **\[k8s/gatewayapi]** Fix Gateway API router's rules ([#&#8203;12753](traefik/traefik#12753) by [rtribotte](https://github.com/rtribotte))
- **\[middleware]** Fix HasSecureHeadersDefined returning false when stsSeconds is 0 ([#&#8203;12684](traefik/traefik#12684) by [veeceey](https://github.com/veeceey))
- **\[otel]** Bump go.opentelemetry.io/otel dependencies ([#&#8203;12754](traefik/traefik#12754) by [rtribotte](https://github.com/rtribotte))
- **\[server]** Bump golang.org/x/net to v0.51.0 ([#&#8203;12756](traefik/traefik#12756) by [kevinpollet](https://github.com/kevinpollet))
- **\[webui]** Fix priority display in dashboard and ACME bypass redirect ([#&#8203;12740](traefik/traefik#12740) by [mmatur](https://github.com/mmatur))
- **\[webui]** Fix basePath validation for dashboard template ([#&#8203;12729](traefik/traefik#12729) by [gndz07](https://github.com/gndz07))

**Documentation:**

- **\[middleware]** Correct documentation for Digest auth ([#&#8203;12651](traefik/traefik#12651) by [Zash](https://github.com/Zash))
- Add missing `.http` to TOML table names ([#&#8203;12713](traefik/traefik#12713) by [Darsstar](https://github.com/Darsstar))
- Fix incorrect TOML example in entrypoints docs ([#&#8203;12711](traefik/traefik#12711) by [mfmfuyu](https://github.com/mfmfuyu))
- Fix API basepath option documentation ([#&#8203;12744](traefik/traefik#12744) by [nmengin](https://github.com/nmengin))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My41MS4wIiwidXBkYXRlZEluVmVyIjoiNDMuNTEuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiYXV0b21lcmdlIiwiaW1hZ2UiXX0=-->

Reviewed-on: https://gitea.alexlebens.dev/alexlebens/infrastructure/pulls/4498
Co-authored-by: Renovate Bot <renovate-bot@alexlebens.net>
Co-committed-by: Renovate Bot <renovate-bot@alexlebens.net>
@gndz07
gndz07 deleted the fix/html-template branch June 19, 2026 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants