ockam icon indicating copy to clipboard operation
ockam copied to clipboard

detect, log and discard messages too large to be send on the wire

Open polvorin opened this issue 1 year ago • 4 comments

Observed behavior

Currently each individual ockam message is limited to up to 2^16 bytes when serialized. On the wire, messages are prepended with a 2bytes header indicating their length, following the encoded message itself.

But this is not really enforced when serializing. The size advertised on the wire is just truncated, and the message is sent anyway

Steps to reproduce

Can be easily tested using the existing examples on examples/rust/get_started

  • Modify 04-routing-over-transport-initiator.rs so the message it sent is larger than 2^16 
  • Run cargo run --example 04-routing-over-transport-responder to start the listener side
  • Run cargo run --example 04-routing-over-transport-initiator to launch the connecting side

The message will be tried to be send anyway, and an error will be reported on the responder side.

Expected behavior

We must detect if the msg size is larger than 2^16 , and if that's the case do not send the message, instead return a TransportError here when serializing the msg

That must be done on all transport where applicable, not only the TCP one (for example the uds one is affected too )

Ockam Version

v0.102.0

polvorin avatar Nov 08 '23 18:11 polvorin

Hello, if issue #6880 is currently unassigned or available, please consider assigning it to me.

prajwalgh avatar Nov 09 '23 05:11 prajwalgh

Sure, go ahead @prajwalgh ! And let us know if you have any questions 👍

adrianbenavides avatar Nov 09 '23 14:11 adrianbenavides

hi, I looked into it and I think I can solve it.

shautvast avatar Dec 07 '23 13:12 shautvast

https://github.com/build-trust/ockam/pull/7079

shautvast avatar Dec 08 '23 13:12 shautvast