Skip to content

Enforce response size limits (1 MiB) for provider JSON - #99

Merged
kilork merged 2 commits into
masterfrom
fix-95-response-size-limits
Oct 4, 2026
Merged

kilork merged 2 commits into
masterfrom
fix-95-response-size-limits

Conversation

@kilork

@kilork kilork commented Aug 30, 2026 •

Copy link
Copy Markdown
Owner

Fixes #95

  • Shared internal crate::http::json helper: reads body as bytes, errors ClientError::ResponseTooBig above the limit before parsing.
  • Wired into discovery config, JWKS, token requests (OIDC + UMA2), userinfo, introspection.
  • Configurable limit: default is 1 MiB (crate::http::MAX_RESPONSE_SIZE); for providers whose JWK set is larger (many signing keys), new sibling methods jwks_with_max_size and jwks_insecure_with_max_size accept a custom limit (usize::MAX disables it) — same sibling pattern as Enforce https for JWKS fetch with per-call insecure opt-out #89. Other fetches keep the default; the limit inside the Client::discover flow stays at the default until the per-client settings from Security hardening: verify-or-error decode without JWKS, discovery issuer pinning, https for provider endpoints #92 part 3 land.
  • Error-returning call sites surface it as Error::ClientError(ResponseTooBig) (transparent).

@kilork kilork self-assigned this Oct 4, 2026
@kilork
kilork force-pushed the fix-95-response-size-limits branch from 3813312 to 677dfca Compare October 4, 2026 19:36
kilork added 2 commits October 4, 2026 21:52
Provider responses are untrusted input. All JSON parses of provider
responses (discovery config, JWKS, token requests, userinfo, UMA2) go
through a shared internal helper that reads the body and errors with
ClientError::ResponseTooBig if it exceeds 1 MiB before parsing.

Fixes #95
Providers with many signing keys can have JWK sets larger than the
default 1 MiB limit. Sibling methods jwks_with_max_size and
jwks_insecure_with_max_size accept a custom limit (usize::MAX
disables it), following the jwks/jwks_insecure sibling pattern
(#89). Other fetches keep the
default limit.
@kilork
kilork force-pushed the fix-95-response-size-limits branch from 677dfca to 91f87e4 Compare October 4, 2026 19:52
@kilork
kilork merged commit 63594fc into master Oct 4, 2026
2 checks passed
@kilork
kilork deleted the fix-95-response-size-limits branch October 4, 2026 19:59
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.

Enforce response size limits for provider JSON payloads

1 participant