54 lines
2.9 KiB
Markdown
54 lines
2.9 KiB
Markdown
---
|
|
id: "bug-1962"
|
|
status: "fixed"
|
|
status_updated: "2026-10-10"
|
|
status_note: ""
|
|
component: "apiserver"
|
|
severity: "security"
|
|
timestamp: "2026-10-10T10:16:07Z"
|
|
last_seen: "2026-10-10T10:16:07Z"
|
|
occurrences: 1
|
|
files: ["src/frontend/apiserver/middleware/validatehandler.go"]
|
|
tags: ["apiserver", "security", "jwt"]
|
|
related: []
|
|
fix_commits: ["387a421c"]
|
|
gitea_issue: 393
|
|
gitea_synced_status: "fixed"
|
|
gitea_synced_hash: "409f4cc5764b"
|
|
---
|
|
|
|
# bug-1962: apiserver JWT excluded-path check drops the last character of every entry, matching unintended paths
|
|
|
|
## Description
|
|
**Observed:** (source reading; follow-up of the 2026-10-10 P0 fixes (bug-1936..1957))
|
|
`ValidateHandler.isExcludedPath` (`middleware/validatehandler.go:52-61`) trims the last character of every excluded entry, not only a trailing `*`, and matches by prefix: `/ping` matches any path starting with `/pin`, and `/swagger/*any` never matches.
|
|
|
|
**Expected:** Exact entries match exactly; only entries ending in `*` match by prefix.
|
|
**Impact:** Security: paths that merely share a prefix with an excluded entry skip JWT validation.
|
|
**Found by:** follow-up of the 2026-10-10 P0 fixes (bug-1936..1957)
|
|
## Environment
|
|
- OS: no /etc/os-release; Docker container; NixOS kernel; kernel Linux 6.18.33 x86_64
|
|
- libc: glibc 2.42-47 (interpreter /nix/store/wb6rhpznjfczwlwx23zmdrrw74bayxw4-glibc-2.42-47/lib/ld-linux-x86-64.so.2)
|
|
- Toolchain: gcc (GCC) 15.2.0, meson 1.9.1
|
|
- Build: asan (xce.build)
|
|
- Code: scheduler-framework @ 19be145d-dirty
|
|
- Deployment: any (found by source reading; confirmed by the RED test of the fix)
|
|
|
|
## Reproduction
|
|
1. Request `/pinX` (or any route sharing the prefix) without a token: JWT validation is skipped.
|
|
- Frequency: deterministic (by code reading; confirmed by the RED test of the fix)
|
|
- Evidence: the code sites quoted in Description; no logs kept.
|
|
## Root cause
|
|
`isExcludedPath` (`middleware/validatehandler.go`) cut the last character of every excluded entry and matched by prefix. Pre-existing.
|
|
|
|
## Fix
|
|
The (hardcoded) excluded list moved to `jwtExcludedPaths`; entries match exactly; an entry ending in a gin catch-all segment (`/swagger/*any`) matches anything under `/swagger/`; ping, logon, logout and swagger still excluded.
|
|
|
|
## Verification
|
|
- Test: `TestIsExcludedPath`, `TestValidateHandler_PrefixLookAlikeNeedsToken` (`middleware/validatehandler_test.go`): RED `isExcludedPath("/pinX") = true, want false`, `isExcludedPath("/swagger/index.html") = false, want true`, `/pinX without a token reached the handler (status 200)`; GREEN after.
|
|
- Suites: `xce-build.sh all asan xce.build --incremental` on the merged branch, 2026-10-10: C suites Ok 157 / Fail 0; frontend Go tests ok (the build now also runs apiserver cmd, middleware, models and router)
|
|
- Live: n/a: unit/fixture-level verification; no live deployment was run
|
|
|
|
## References
|
|
- Fix commits: `387a421c` (on `scheduler-framework`)
|
|
- Found as a follow-up of the 2026-10-10 P0 fixes (bug-1936..1957)
|