Skip to content
dyoktoPublic

About

Negative tests for OAuth, MCP authorization, ID-JAG and AuthZEN implementations

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

mustbreak

mustbreak

CI License

Negative tests for OAuth, MCP authorization, ID-JAG and AuthZEN implementations. Each case sends the request an attacker would send and checks that the target refuses it the way the spec says it must.

Conformance suites check that an implementation does what the spec describes. mustbreak only checks what happens when someone sends what the spec forbids: a Client ID Metadata Document URL that resolves to a private address, an ID-JAG addressed to another authorization server, a token minted for a different resource.

Install

The quick start goes from install to a PDP that fails a case and one that passes it, then an MCP client, all on loopback. Docs site: https://dyokto.github.io/mustbreak/.

brew install kanywst/tap/mustbreak
go install github.com/dyokto/mustbreak@latest

Prebuilt binaries for macOS and Linux are on the releases page, with SBOMs, cosign signatures and build provenance (gh attestation verify <file> -R dyokto/mustbreak).

mustbreak moved from kanywst/mustbreak to dyokto/mustbreak on 2026-12-03. Releases up to v0.1.1 use the module path github.com/kanywst/mustbreak and verify with -R kanywst/mustbreak.

Use

The target's role picks the subcommand. Some cases attack a server directly; others need mustbreak to play a hostile server and wait for the client under test to connect.

mustbreak list                                  # every case, its role and spec level
mustbreak as  --issuer https://as.example --profile as.yaml
mustbreak rs  --resource https://mcp.example/mcp --profile rs.yaml
mustbreak client --run 'my-client connect {url}'      # an MCP client, once per attempt
mustbreak client --login-url 'https://app.example/login'   # a web client; mustbreak is the browser
mustbreak pdp --url https://pdp.example         # AuthZEN PDP

Common flags:

--case MB-05,MB-07     # run only these
--profile dex.yaml     # target-specific setup: test clients, how to get a code or token
--json                 # machine-readable result (schema mustbreak.results/v1)
--fail-on must         # exit 2 if a MUST-level case fails or cannot run (must | should | any)
-v                     # print the evidence for every case

Each case reports pass, fail, skip (the target does not support the feature, or the profile does not give what the case needs) or error (the case could not run). A case decides from what the target sends back, or from what mustbreak's own listeners receive. Where a pass could come from a broken setup, the case first runs an honest attempt (the right code_verifier, a valid token, honest metadata) and reports error if that does not work.

Profile

A profile tells mustbreak how to drive the target. Only what the selected cases need has to be there. e2e/dex-as.yaml is a working one for dex.

issuer: http://127.0.0.1:5556/dex
public_client:       { id: mb-public, redirect_uri: https://client.example/callback }
confidential_client: { id: mb-confidential, secret: "...", redirect_uri: https://client.example/callback }
authorize:
  params: { connector_id: mock }   # extra query parameters, so a code comes back without a human
  follow_hosts: []                 # other hosts the login may redirect through

listen: 0.0.0.0:9443               # mustbreak's own listener (CIMD documents, ID-JAG JWKS, MB-04 upstream)
public_url: https://mb.example     # how the target reaches it
private_url: https://host.docker.internal:9443   # the same listener under a special-use address (MB-05)

idjag: { issuer: https://idp.example, key: idp.pem, subject: alice }   # the IdP the AS trusts
registration: { initial_access_token: "..." }

resource: https://mcp.example/mcp
rs:
  tokens: { valid: "...", other_resource: "..." }   # or fetched with client_credentials and `resource`
  upstream: { tool: fetch, arguments: { url: "https://mb.example/upstream" } }

client:
  rfc9207: true                    # a web client that implements RFC 9207 (MB-13)
  downstream: { token_url: https://dex.example/token, id: app, secret: "...", redirect_uri: https://app.example/cb }   # for a client that is itself an AS (MB-17)

pdp: { url: https://pdp.example, subject: { type: user, id: alice }, resource: { type: doc, id: "1" }, action: { name: read } }

GitHub Action

- uses: dyokto/[email protected]
  with:
    version: v0.1.1
    args: as --profile .github/mustbreak.yaml --fail-on must

Cases

The section numbers were checked against these versions: RFC 6749, 7523, 7591, 7636, 8707, 8725, 9207, 9700, 9728; draft-ietf-oauth-v2-1-17; draft-ietf-oauth-client-id-metadata-document-03 (CIMD); draft-ietf-oauth-identity-assertion-authz-grant-06 (ID-JAG); MCP 2026-07-28 (authorization); OpenID Connect Core 1.0; AuthZEN Authorization API 1.0. MCP sections have no numbers, so they are cited by heading.

Level is the strongest keyword the cited text uses for the expected behaviour.

ID Role Spec and section Level Attack Expected refusal
MB-01 client RFC 9728 §3.3 MUST Protected resource metadata whose resource differs from the resource identifier the client derived the well-known URL from Client does not use the metadata
MB-02 client RFC 9728 §3.3 MUST WWW-Authenticate resource_metadata points to metadata whose resource is not the URL the client requested Client does not use the metadata
MB-03 rs MCP 2026-07-28 Authorization "Token Handling"; RFC 8707 §2 MUST Access token issued by the same AS for another resource 401; the request is not served
MB-04 rs MCP 2026-07-28 Authorization, Security Considerations "Access Token Privilege Restriction" MUST NOT Call a tool that reaches an upstream API, with mustbreak recording what the upstream receives The client's token never reaches the upstream
MB-05 as CIMD §10.7 MUST NOT client_id URL whose host resolves to a special-use address (loopback, link-local, private) AS does not fetch; the request fails
MB-06 as CIMD §6 MUST NOT client_id URL that answers 302 to an internal host AS does not follow the redirect; treated as an error (§6.1)
MB-07 as CIMD §4 MUST Metadata document whose client_id is not the URL it was fetched from AS rejects the client; no redirect to it (§6.1)
MB-08 as CIMD §10.11 SHOULD Metadata document larger than 5 KB AS stops reading and treats it as an error
MB-09 as OAuth 2.1 (draft -17) §4.1.1, §4.1.2.1, §7.5.2 MUST Public client sends code_challenge_method=plain, or no code_challenge at all Authorization request rejected
MB-10 as RFC 7636 §4.6; RFC 9700 §2.1.1, §4.8.2 MUST Token request with a wrong or missing code_verifier for a code issued with a challenge; or a code_verifier for a code issued without one invalid_grant
MB-11 as RFC 9700 §2.1, §4.1.3 MUST redirect_uri that differs from the registered one by a trailing slash, letter case, an extra path segment or a query Request rejected; no redirect to the given URI
MB-12 client RFC 6749 §10.12; RFC 9700 §4.7.1 MUST Deliver the attacker's authorization response (code and state) to the victim's browser session Client rejects the callback; the victim is not logged in as the attacker
MB-13 client RFC 9207 §2.4; MCP 2026-07-28 Authorization "Authorization Response Validation" MUST Authorization response with an iss that is not the AS the request went to, or without iss from an AS that advertises support Client rejects the response; the code is not sent to any token endpoint
MB-14 as ID-JAG §4.4.1 MUST ID-JAG whose aud is another authorization server, or an array with more than one element invalid_grant
MB-15 as ID-JAG §4.4.1; RFC 7523 §3 (item 4) MUST Expired ID-JAG; and an ID-JAG with under 60 seconds left Expired: invalid_grant. Under 60 seconds left: exchanged normally, no 5xx (a robustness check from the fix below, not a spec rule; reported but not counted)
MB-16 as RFC 7523 §3 (item 7) MAY Present the same ID-JAG (jti) twice Second exchange rejected. Replay protection is optional in RFC 7523, so a fail here is reported as a finding, not a MUST violation
MB-17 client OIDC Core §5.3.2 MUST UserInfo response whose sub differs from the ID Token's sub Client does not use the UserInfo values
MB-18 rs RFC 8725 §2.1, §3.1 MUST JWT access token with alg: none, or signed with HS256 using the AS's public key as the HMAC secret 401
MB-19 as RFC 7591 §5, §3.2.2 MUST Dynamic registration with a redirect_uris entry that is plain http on a non-localhost host invalid_redirect_uri
MB-20 pdp AuthZEN Authorization API 1.0 §10.1.1, §10.1.2, §7.2.1 MUST Evaluation request missing a required attribute (for example subject.type); an evaluations batch where one item errors 400 for the missing attribute; the failing item's decision is false

Cases taken from fixes that already landed:

ID Fix
MB-03 modelcontextprotocol/go-sdk#1388
MB-12 GHSA-7g9f-57qp-jhgx (zalando/skipper)
MB-15 cloudflare/workers-oauth-provider#303
MB-17 dexidp/dex#4828

What it does not check

  • Whether an implementation follows the spec in the normal case. Use the OpenID conformance suite for that.
  • Scanning for exposed MCP servers or tool-poisoning in tool descriptions.
  • Finding problems in production services you do not own. Run it against your own deployment or a local build.

Limits of the cases as written:

  • MB-05 to MB-08 need the AS to reach mustbreak's listener. A compliant AS will not fetch from a special-use address, so all four need a public_url it will fetch from; otherwise they report error. For private_url, prefer a special-use address other than loopback (such as host.docker.internal): CIMD §10.7 lets a development setup fetch loopback URLs.
  • MB-01 and MB-02 need a client that starts from the resource URL (--run or a manual connect). With --run, MB-12 can only check a forged state, and skips a client that sends PKCE; the two-session login CSRF needs --login-url. The hostile token endpoint checks PKCE, so a client protected by PKCE alone passes.
  • MB-13 skips a --login-url client unless the profile sets client.rfc9207; RFC 9207 binds only clients that implement it.
  • MB-17 fails only when the mismatched UserInfo values show up: in the page, the --run output, or the ID Token a client.downstream gets. A login that succeeds without showing them is an error.
  • MB-04 needs a tool that makes the server call {public_url}/upstream. MB-18 needs JWT access tokens.
  • MB-14 to MB-16 need the AS to trust mustbreak as an IdP.

CI runs MB-05 to MB-08, MB-10, MB-11, MB-17 and MB-19 against dex v2.46.1 and a dex master build, and the client cases against the MCP client in modelcontextprotocol/go-sdk v1.9.0 (e2e).

License

Apache-2.0

About

Negative tests for OAuth, MCP authorization, ID-JAG and AuthZEN implementations

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages