bug: The JWT bypass matches a cleaned path but forwards the raw path, so /mcp/../healthz skips validation

オープン
#1,884 コメント 0 件 リアクション 0 件 担当者 1 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@evaline-ju がすでに取り組んでいます。

2026年11月16日 から。

評価

この issue はまだ評価されていません。

説明

bug

Problem

The inbound JWT bypass compares a cleaned path, but the app behind the sidecar gets the raw path. A request with .. segments can match a bypass pattern and then reach a protected handler with no token.

/healthz and /.well-known/* are in bypass.DefaultPatterns (core/bypass/matcher.go:12), so the default config has this problem.

Reproduction (main at 676557d35)

  1. Cortex side, Go test:
    • bypass.NewMatcher(bypass.DefaultPatterns).Match("/mcp/../healthz") returns true.
    • A reverseproxy.NewServer in front of a test backend gets the raw request POST /mcp/../healthz HTTP/1.1. The backend sees RequestURI = "/mcp/../healthz", and the status is 200.
  2. App side: a FastAPI 0.136 app on uvicorn 0.35 with @app.post("/mcp/{rest:path}"). curl --path-as-is -X POST http://127.0.0.1:<port>/mcp/../healthz returns {"handler":"protected-mcp","rest":"../healthz"}.

Together: the request skips JWT validation as /healthz, and the app runs the protected /mcp handler.

Cause

  • core/bypass/matcher.go:46: Match runs path.Clean(requestPath) before it matches. The repo's own test asserts that Match("/foo/../healthz") is true.
  • core/plugins/jwtvalidation/plugin.go:393-398 passes pctx.Path to the bypass check. The reverse proxy sets pctx.Path from the decoded r.URL.Path (core/listener/reverseproxy/server.go:337). So /mcp/..%2Fhealthz also decodes to /mcp/../healthz.
  • The reverse proxy forwards the original path. It has no ServeMux that cleans or redirects the path.

Fix

In Match, return false when path.Clean(p) != p (allow one trailing slash if needed). Then a non-canonical path never bypasses validation. Also match on the escaped path, not the decoded one. Add a test for /mcp/../healthz and /mcp/..%2Fhealthz through jwt-validation.

Impact if not fixed

In sidecar deployments, a caller with no token can reach protected inbound routes on apps that do not normalize .. segments. The laptop install does not use inbound JWT validation. Not checked: frameworks other than FastAPI (Express, Spring). The envoy-sidecar path (ext_proc) was not tested.

主要言語
Go
スター
26
フォーク
46
平均マージ
9時間 55分
マージ済み PR(30日)
257

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rossoctl/cortex のほかの issue

rossoctl/cortex の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。