Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion pkg/vmcp/config/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -591,6 +591,16 @@ func (*DefaultValidator) validateCompositeToolRefs(refs []CompositeToolRef) erro
return nil
}

// The standalone header-forward middleware deliberately allows Authorization
// (an operator may legitimately forward it), but for vMCP passthrough the
// documented contract is stricter: Authorization and Cookie are rejected at
// startup because forwarding caller-supplied credentials verbatim to every
// backend is a credential-leak footgun, not a pass-through use case.
var vmcpRestrictedHeaders = map[string]bool{
"Authorization": true,
"Cookie": true,
}

func (*DefaultValidator) validatePassthroughHeaders(cfg *Config) error {
for i, name := range cfg.PassthroughHeaders {
if name == "" {
Expand All @@ -599,7 +609,7 @@ func (*DefaultValidator) validatePassthroughHeaders(cfg *Config) error {

canonical := http.CanonicalHeaderKey(name)

if middleware.RestrictedHeaders[canonical] {
if middleware.RestrictedHeaders[canonical] || vmcpRestrictedHeaders[canonical] {
return fmt.Errorf("passthroughHeaders[%d]: %q is a restricted header and cannot be forwarded", i, canonical)
}

Expand Down
15 changes: 15 additions & 0 deletions pkg/vmcp/config/validator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,21 @@ func TestValidator_ValidatePassthroughHeaders(t *testing.T) {
wantErr: true,
errMsg: "X-Forwarded-For",
},
{
// Documented contract (virtualmcpserver-api.md): Authorization is
// rejected at startup. Forwarding caller-supplied credentials
// verbatim to every backend is a credential-leak footgun.
name: "Authorization is restricted",
headers: []string{"authorization"},
wantErr: true,
errMsg: "Authorization",
},
{
name: "Cookie is restricted",
headers: []string{"Cookie"},
wantErr: true,
errMsg: "Cookie",
},
{
name: "empty string header name is rejected",
headers: []string{""},
Expand Down
Loading