-
Notifications
You must be signed in to change notification settings - Fork 0
Add max size validation to envelope.Unmarshal #5
Copy link
Copy link
Open
Labels
area/envelopeJSON envelope helpers and MIME-contract behavior.JSON envelope helpers and MIME-contract behavior.good first issueSmall, well-scoped tasks for new contributors.Small, well-scoped tasks for new contributors.help wantedLooking for community contributions.Looking for community contributions.kind/featureNew functionality or enhancement request.New functionality or enhancement request.priority/highImportant issue to schedule soon.Important issue to schedule soon.
Metadata
Metadata
Assignees
Labels
area/envelopeJSON envelope helpers and MIME-contract behavior.JSON envelope helpers and MIME-contract behavior.good first issueSmall, well-scoped tasks for new contributors.Small, well-scoped tasks for new contributors.help wantedLooking for community contributions.Looking for community contributions.kind/featureNew functionality or enhancement request.New functionality or enhancement request.priority/highImportant issue to schedule soon.Important issue to schedule soon.
Problem statement
envelope.Unmarshaldeserializes JSON into anEnvelopestruct without any size validation beyond checking for empty input. ThePayloadandInputsfields arejson.RawMessage(unbounded byte slices). A craftedBinaryFramewith a valid MIME type containing hundreds of megabytes of JSON can exhaust server memory.For comparison,
core/templatingenforcesmaxTemplateValidationJSONBytes = 1MB. The envelope layer that feeds data into it has no equivalent guard.Proposed change
Add a maximum size constant and check before deserializing:
Also consider validating that
Payloadis valid JSON inMarshal:Affected area
Compatibility / migration
Envelopes exceeding 10MB were never intended to work correctly. The limit is generous — typical envelopes are under 1MB. Adjust the constant if specific use cases require larger payloads.
Additional context
Identified during security review. The attack surface is: attacker sends
BinaryFramewith validapplication/vnd.bubu.packet+jsonMIME type but oversized payload.FromBinaryFrame→Unmarshal→ OOM.