Commit 1dbbdda
committed
fix: percent-encoded path bypass of ManagementInterceptor loopback gate
- A request to /%6Danagement (or any other percent-encoded equivalent) has
requestURI = "/%6Danagement", which is not string-equal to "/management",
so the loopback check was silently skipped
- Spring Security's PathPatternRequestMatcher and Tomcat's servlet mapping
both operate on the decoded path, so the request was still permitted and
dispatched to ManagementController.updateManagementRegistry(), allowing an
unauthenticated remote caller to toggle CredHub's read-only mode
- Fix: decode requestURI with UriUtils.decode() (stripping context path first)
before any comparison, mirroring what Tomcat's CoyoteAdapter.UDecoder does
when producing servletPath; this works in both production (Tomcat decodes)
and MockMvc tests (requestURI is always set, servletPath is not)
- Apply the same decoded path variable to the read-only mode exemption checks
for /management and /interpolate so encoded variants of those paths are also
correctly handled
ai-assisted=yes
TNZGOV-41011 parent 530356f commit 1dbbdda
2 files changed
Lines changed: 37 additions & 3 deletions
File tree
- components/management/src
- main/kotlin/org/cloudfoundry/credhub
- test/kotlin/org/cloudfoundry/credhub/interceptors
Lines changed: 19 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| 10 | + | |
| 11 | + | |
10 | 12 | | |
11 | 13 | | |
12 | 14 | | |
| |||
17 | 19 | | |
18 | 20 | | |
19 | 21 | | |
20 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
21 | 37 | | |
22 | 38 | | |
23 | 39 | | |
24 | 40 | | |
25 | 41 | | |
26 | | - | |
27 | | - | |
| 42 | + | |
| 43 | + | |
28 | 44 | | |
29 | 45 | | |
30 | 46 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
97 | 115 | | |
0 commit comments