Skip to content

Commit 2876c90

Browse files
committed
fix(api/v2): always bind the internal-dispatch marker
The marker was only ever set, never cleared, so a dispatch with no parent echo context would inherit an outer dispatch's route instead of failing closed as its comment claimed. Write the key unconditionally and let shouldSkipRouteCheck's non-empty guard reject the unbound case. Address pr-swarm finding: security
1 parent 441eac0 commit 2876c90

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

pkg/modules/humabridge/humabridge.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,13 @@ type groupPrefixAdapter struct {
7070

7171
func (a *groupPrefixAdapter) ServeHTTP(w http.ResponseWriter, r *http.Request) {
7272
ctx := r.Context()
73-
// No parent route to bind the marker to means the dispatch gets authorised
74-
// like any client request.
73+
route := ""
7574
if c, ok := ctx.Value(EchoContextKey).(*echo.Context); ok {
76-
ctx = context.WithValue(ctx, internalDispatchKey{}, c.Path())
75+
route = c.Path()
7776
}
77+
// Always write the key: an inherited marker from an outer dispatch would
78+
// otherwise describe a route this one isn't on.
79+
ctx = context.WithValue(ctx, internalDispatchKey{}, route)
7880
r = r.Clone(ctx)
7981
if a.groupPrefix != "" && !strings.HasPrefix(r.URL.Path, a.groupPrefix) {
8082
r.URL.Path = a.groupPrefix + r.URL.Path

0 commit comments

Comments
 (0)