-
Notifications
You must be signed in to change notification settings - Fork 85
Description
BIP 78 does not restrict the size of the response, but specifies that content length must be included.
The v1 receiver enforces a reasonable limit on the request:
rust-payjoin/payjoin/src/receive/v1.rs
Lines 95 to 97 in 34ee78d
| if content_length > 4_000_000 * 4 / 3 { | |
| return Err(InternalRequestError::ContentLengthTooLarge(content_length).into()); | |
| } |
however, a similar limit was not included in payjoin-cli, response.bytes().to_vec() could potentially make unbounded allocations given a large enough response body:
rust-payjoin/payjoin/src/send/v1.rs
Lines 276 to 277 in 34ee78d
| let mut res_str = String::new(); | |
| response.read_to_string(&mut res_str).map_err(InternalValidationError::Io)?; |
(note that the error mapping also seems inaccurate, not sure what happens in the case of invalid utf8 in the response)
nor is a size limit enforced in the payjoin-cli sender:
rust-payjoin/payjoin-cli/src/app/v1.rs
Line 99 in 34ee78d
| let psbt = ctx.process_response(&mut response.bytes().await?.to_vec().as_slice()).map_err( |
because these are unbounded allocations a malicious receiver can cause memory exhaustion for the sender.
there may be other issues in v1, and similarly we should check that the in the v2 implementation no such unbounded allocations (e.g. r.bytes().to_vec()) are used for all parties (sender, receiver, directory and relay)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status