
Oauth Auditor
io.github.4hmetuyar由 GitHub 帳號 4hmetuyar 發布v0.1.2更新於 Oct 24, 2026
Scans MCP server auth code for OAuth 2.1 anti-patterns: token passthrough, missing audience
概覽
掃描 MCP 伺服器的授權程式碼,找出權杖透傳、缺少受眾驗證、缺少 PKCE 等 OAuth 2.1 反模式。
- 可以做什麼
- 掃描程式碼片段、單一檔案或整個目錄中的 OAuth 反模式,並依類別與嚴重程度回報結果
- 列出支援的偵測規則及其類別
- 檢查權杖透傳、缺少受眾驗證、探索端點 SSRF、PKCE、重新導向驗證與硬編碼用戶端密鑰
- 在 TypeScript/JavaScript 規則之外,另提供 Python 與 Go 專用規則
- 輸出 SARIF 2.1.0 供 CI/CD 程式碼掃描使用,並可讀取 guardbee.yml 設定檔
- 適用情境
- 適合正在開發或審查作為 OAuth 資源伺服器的 MCP 伺服器、並希望在發布前依規範快速檢查授權程式碼的開發者。也適合想把檢查結果放進助理對話或接入 CI 流程的人,但它並非完整的協定一致性測試。
- 執行需求
- 以本機 stdio 程序執行,通常透過 npx 從 npm 套件啟動,因此需要 Node.js 以及下載套件的網路存取。未宣告需要帳號、API 金鑰或環境變數。guardbee.yml 設定檔為選用。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Oauth Auditor,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
@guardbee/mcp-oauth-auditor
🇬🇧 English | 🇹🇷 Türkçe | 🇨🇳 中文 | 🇯🇵 日本語 | 🇰🇷 한국어 | 🇧🇷 Português | 🇪🇸 Español | 🇩🇪 Deutsch
[npm version] [npm downloads] [License: MIT]
An MCP (Model Context Protocol) server that scans an MCP server's own authorization code for OAuth 2.1 anti-patterns named in the MCP specification's own Security Considerations section.
The MCP spec doesn't leave this to guesswork — it explicitly calls out token passthrough (forwarding a client's token to a downstream API unchanged, instead of exchanging/re-scoping it) and missing audience validation (accepting a token whose aud claim was never issued for this server) as the central authorization failure modes for a server acting as an OAuth resource server. This package checks for exactly those two, plus three related anti-patterns in the same family.
Telemetry is off by default. With
GUARDBEE_TELEMETRY=1it sends the server, tool, success, duration and short parameter values such as a file path; longer strings and fields likecontent,tokenorpasswordare replaced with a placeholder. See@guardbee/mcp-telemetry.
Why these two specifically
Token passthrough matters because a token a client presented to this server was scoped and audienced for this server — not whatever downstream API the server's own tool handlers call next. Forwarding it unchanged means the downstream service is trusting a credential it never issued, on the basis of a server-side decision the original token issuer never approved.
Missing audience validation is the same failure from the other direction: jwt.verify(token, key) confirms a token's signature is valid, but says nothing about who it was issued for. Without an explicit audience check, a token minted for a completely unrelated resource server — one that happens to share the same issuer/signing key — will verify successfully here too. This is the textbook confused-deputy substitution the MCP spec is warning about.
The other three patterns are adjacent, concrete instances of the same "an MCP server's auth code trusts something it shouldn't" theme: an OAuth/OIDC discovery URL built from client-supplied input (the shape behind a real disclosed CVE), a redirect_uri validated with a prefix/substring check instead of an exact match (open-redirect bypass), and PKCE silently missing from an authorization request (required by OAuth 2.1 unconditionally, not just for public clients).
Features
- 6 categories: token-passthrough, token-validation, discovery-ssrf, pkce, redirect-validation, secrets-exposure
- Two of the checks (missing audience validation, missing PKCE) look for an absence near a call site rather than a fixed regex — they extract the full
jwt.verify(...)call (or the authorization-request URL construction) and confirmaudience:/code_challengeis genuinely nowhere nearby, not just matched by a lucky string position - SARIF 2.1.0 output — CI/CD integration (GitHub Code Scanning, etc.)
- Config file support via
guardbee.yml - 18 unit tests — a positive and a negative (false-positive) scenario for every pattern, plus one fully-correct OAuth flow that produces zero findings. Found and fixed a real regex bug during development (a trailing
\bafter a]character that can never match, since]isn't a word character — silently missed the bracket-notation form of header access). End-to-end verified against a fixture with all 6 anti-patterns deliberately planted (caught all 6), and against the entire guardbee-mcp monorepo (401 files — zero findings in any real third-party code; the only non-test matches were the scanner's own pattern-definition source textually containing the stringjwt.verify(inside a regex literal and a doc comment, not actual vulnerable usage)
Quick Start
Claude Desktop / MCP Client
CLI (CI/CD)
MCP Tools
Detected Patterns
Python and Go
The language comes from the file extension, and Python- and Go-specific rules run only on their own files.
- Python (FastAPI / Starlette / Flask, PyJWT, python-jose, authlib):
python_missing_audience_validation(jwt.decodewith noaudience=and no authlibclaims_optionsaud),python_audience_verification_disabled("verify_aud": False),python_token_passthrough_to_downstream(theAuthorizationheader or all ofrequest.headerson arequests/httpx/ client call),missing_pkce_on_auth_requeston authlibcreate_authorization_url/authorize_redirectwith nocode_challenge, and the discovery SSRF, redirect, state and0.0.0.0rules. - Go (golang-jwt / jwx, go-oidc, golang.org/x/oauth2, go-sdk and mcp-go HTTP transports):
go_missing_audience_validation(jwt.Parsewith nojwt.WithAudience),go_oidc_client_id_check_skipped,go_token_passthrough_to_downstream(out.Header.Set("Authorization", r.Header.Get("Authorization"))),go_hardcoded_oauth_client_secret,go_loose_redirect_uri_validation(strings.HasPrefix),go_predictable_state_handle(math/rand, time),go_oauth_discovery_ssrf,go_auth_url_opened_via_shell,missing_pkce_on_auth_requestonAuthCodeURLwith noS256ChallengeOption, andListenAndServe(":8080")aslisten_all_interfaces. - Both:
token_passthrough_via_variable— the incomingAuthorizationheader read into a variable that is then put on an outgoing request.
Every finding links its section of the MCP spec Security Best Practices (SARIF helpUri) and carries its OWASP MCP Top 10 id as a SARIF tag. The newer rules are heuristics over one file at a time: a check done in another module (an auth middleware, an iss comparison in a helper) is not seen.
Live probe
Read-only checks of a running HTTP MCP endpoint: does it answer an initialize without credentials (probe_unauthenticated_access), and does it accept a foreign Host (probe_dns_rebinding_host_accepted) or Origin (probe_foreign_origin_accepted)? It sends no credentials, calls nothing beyond initialize, closes any session it opened, and refuses a host that resolves to a public address unless --allow-public. CLI only: an agent cannot start it through the MCP tools.
Configuration (guardbee.yml)
Limitations (by design)
- TypeScript/JavaScript, Python and Go. Each has rules for its common libraries (above). Other languages (Rust, Java, C#, …) and other libraries are only matched where they happen to share a shape with these, e.g. a literal
client_secretorresponse_type=code. - Heuristic, not a full OAuth conformance test. This finds specific anti-patterns in source, not a live protocol conformance check against a running authorization server. It won't catch every way an OAuth flow can be misimplemented — only the handful the MCP spec calls out as the highest-stakes ones.
- The absence-based checks (audience, PKCE) use a bounded text window, not a real parser — a
jwt.verify()call whose options object happens to be built far away from the call site (a variable passed in, rather than an inline object) won't be checked foraudiencecorrectly.
Development
License
MIT — GuardBee
Feedback
Questions, ideas, or a false positive? Start a thread in GitHub Discussions or open an issue. If GuardBee is useful to you, a ⭐ on the repository helps others find it.
來源:packages/oauth-auditor/README.md,提交 fe7dc3a
工具
0版本歷史
1- v0.1.2最新Sep 29, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分