php-sdk/docs
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Antoine Bluchet df5379c047
[Server] Harden JSON-RPC input parsing against malformed input and resource exhaustion (#383)
* fix: harden JSON-RPC input parsing against malformed input and DoS

MessageFactory::create() detected batches via $input[0] === '{', which
mishandled valid-but-non-object JSON: a scalar ("5") or leading-whitespace
object silently returned [] (with a PHP warning) or could reach a foreach
over a non-array. It also had no bound on batch size, letting one small
request expand into arbitrarily many operations (amplification).

- Detect single-vs-batch from the decoded JSON type (object vs list array)
  instead of the raw first byte; reject scalars and empty payloads as
  InvalidInputMessageException rather than crashing or no-oping.
- Cap batch size (maxBatchSize, default 100) and reject oversized batches.
- Reject non-object batch elements as InvalidInputMessageException instead
  of letting them hit a TypeError.
- Bound the StreamableHttpTransport POST body (maxBodyBytes, default 4 MiB),
  returning 413, with an incremental read so unknown-size/chunked bodies
  cannot exhaust memory.

* docs: document input-hardening limits in CHANGELOG and transports guide

Add CHANGELOG entries and docs/transports.md sections for the JSON-RPC
batch size cap (maxBatchSize) and the StreamableHttpTransport request
body size cap (maxBodyBytes), plus the type-based single-vs-batch
message detection.
2026-07-06 00:10:13 +02:00
..
authorization.md [Server] Oauth2 based on middleware (#221) 2026-03-10 17:10:07 +01:00
client.md Document v0.6.0 changes in CHANGELOG and docs (#311) 2026-06-02 17:47:04 +02:00
events.md feat(server): add server lifecycle events (#175) 2026-02-23 22:40:43 +01:00
examples.md [Schema][Server] Add MCP Apps extension (io.modelcontextprotocol/ui) support (#281) 2026-06-01 09:35:54 +01:00
extensions.md [Schema][Server] Add MCP Apps extension (io.modelcontextprotocol/ui) support (#281) 2026-06-01 09:35:54 +01:00
index.md Document v0.6.0 changes in CHANGELOG and docs (#311) 2026-06-02 17:47:04 +02:00
mcp-elements.md Document v0.6.0 changes in CHANGELOG and docs (#311) 2026-06-02 17:47:04 +02:00
server-builder.md Document v0.6.0 changes in CHANGELOG and docs (#311) 2026-06-02 17:47:04 +02:00
server-client-communication.md [Schema][Server] Add top-level title to Tool (#288) 2026-04-26 15:37:40 +02:00
transports.md [Server] Harden JSON-RPC input parsing against malformed input and resource exhaustion (#383) 2026-07-06 00:10:13 +02:00