mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-10-26 18:31:34 +01:00
The duplex frame codec accepted a request or a response `id` of any length up to the whole-frame cap. The host broker keeps one id per distinct dispatched request for the no-replay guarantee. A provider that controls the transport could send distinct near-frame-limit ids and force the host to retain many gigabytes before the lifetime count ceiling, so the host adapter process could exhaust memory. Add a finite protocol bound for the id field: - Export `DEFAULT_MAX_DUPLEX_REQUEST_ID_BYTES` (256 bytes). The generated gateway builds each id with `randomUUID()` (36 bytes), so this bound gives large headroom and caps the retained bytes per id. - Reject an over-limit id as an `id_too_large` protocol error in both codec copies (the host codec and the embedded gateway codec). The read path returns the error; it never throws. The whole-frame cap stays unchanged. - Enforce the id bound in the broker before the seen set, the pending record, and the forward, as defense in depth. The refusal allocates no controller, no timer, and no forward, and records no telemetry. - State the worst-case retained id bytes at the lifetime-limit definition (50,000 * 256 = 12,800,000 bytes). Add shared fixture vectors for a maximal-allowed id and an over-limit id, so both codec copies prove the same bound. Add regression tests for the flood, the no-replay path, and the byte-not-character measure. Co-authored-by: Paperclip <noreply@paperclip.ing>