Skip to content

fix(payload): build full jku/x5u URL in basic payload instead of bare domain - #293

Merged
hahwul merged 1 commit into
mainfrom
hahwul/bughunt-payload
Sep 2, 2026
Merged

fix(payload): build full jku/x5u URL in basic payload instead of bare domain#293
hahwul merged 1 commit into
mainfrom
hahwul/bughunt-payload

Conversation

@hahwul

@hahwul hahwul commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Summary

The basic jku/x5u payload from the payload command emitted the raw
--jwk-attack value verbatim — a bare domain — as the header value:

jku = "evil.com"      # not a valid absolute URI, --jwk-protocol ignored

A JWKS/cert resolver that fetches this URL server-side would never reach the
attacker's endpoint (no scheme → not fetchable), so the primary and most
important
URL payload was effectively non-functional. Meanwhile every other
jku/x5u variant already produced correct full URLs:

  • the bypass variants use {protocol}://{trust}Z{domain}, …@…, …%0d%0a…
  • the ssrf target emits complete URLs (http://169.254.169.254/…)

--jwk-protocol (default https, documented as http/https) was silently
ignored for the basic payload.

Fix

Prepend the configured scheme so the basic payload is a valid, fetchable URL
that honours --jwk-protocol, consistent with the bypass and SSRF variants. A
value that already carries a scheme is passed through verbatim so a
pre-schemed input never produces a double scheme (https://https://…).

Before / After

# jwt-hack payload <TOKEN> --target jku --jwk-attack evil.com --jwk-protocol http
before:  jku = "evil.com"
after:   jku = "http://evil.com"

Bypass variants are unchanged; --target ssrf and the scan command
(generate_jku_x5u_ssrf_payload) are unaffected.

Tests

  • Updated test_generate_url_payload_jku_basic and
    test_generate_url_payload_x5u_with_trust to expect the full URL.
  • Added test_generate_url_payload_basic_respects_protocol covering the
    https default, --jwk-protocol=http, and the pre-schemed pass-through
    (no double scheme).
  • cargo test (558 tests), cargo fmt --check, cargo clippy --all-targets
    all clean.

Scope / constraints

  • Only src/payload/mod.rs touched (within assigned scope).
  • JSON serialization contract unchanged (only a payload value is fixed;
    structure/keys/format untouched). Token lines remain structurally intact.

… domain

The basic jku/x5u payload emitted the raw --jwk-attack value verbatim
(e.g. `jku: "evil.com"`), which is not a valid absolute URI and silently
ignored --jwk-protocol. A server resolving the header would never fetch
the attacker's endpoint, so the primary (and most important) URL payload
was effectively non-functional, while every bypass variant and the SSRF
probes correctly used a full `{protocol}://…` URL.

Prepend the configured scheme so the basic payload is a fetchable URL
that honours --jwk-protocol, matching the bypass and SSRF variants. A
value that already carries a scheme is passed through verbatim to avoid
producing a double scheme.

Updates the affected unit tests and adds a regression test asserting the
scheme is applied (and not duplicated for pre-schemed inputs).
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@hahwul
hahwul merged commit 8a31c62 into main Sep 2, 2026
9 checks passed
@hahwul
hahwul deleted the hahwul/bughunt-payload branch September 2, 2026 00:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants