logos-co / nomos-node

Nomos blockchain node
52 stars 18 forks source link

Byte limits for DaBlob <> Bincode serde #714

Open romanzac opened 2 months ago

romanzac commented 2 months ago

Proposed change

To discuss whether and/or how to apply limits during DaBlob <> Bincode serde to prevent certain types of DOS attacks.

Code snippet for reference:

   async fn stream_disperse(
        mut stream: DispersalStream,
        message: DaBlob,
        subnetwork_id: SubnetworkId,
    ) -> Result<StreamHandlerFutureSuccess, DispersalError> {
        println!("I have been called!");
        let blob_id = message.id();
        let blob = bincode::serialize(&message).map_err(|error| DispersalError::Serialization {
            error,
            blob_id: blob_id.clone().try_into().unwrap(),
            subnetwork_id,
        })?;
    .
    .
    .
    }    

Bincode docs

https://docs.rs/bincode/1.3.3/bincode/config/trait.Options.html