-
Notifications
You must be signed in to change notification settings - Fork 11
Open
Description
The current spec says
This allows the parser to pre-size any internal construct used for parsing
While useful for optimization and essential for the way UBJ byte arrays would work, this requires implementations carefully allow for configuration of limits on collection size. Consider the simple memory exhaustion from careless parsing of this partial payload
[[][$][L][#][H][i][5][1e+12] // A terrabyte of data
[0]
[0]
The spec should have a section dedicated to outlining prevention of resource exhaustion. Methods to do this would include:
- A parsing mode which doesn't preallocate memory, and instead uses an incrementally growing data structure (such as a Java
ArrayListwith a small initial size). This would lean on external systems to limit size (like max entity size in a HTTP library) as well as force the attacker to actually send the full declared size to consume the memory. - A limit on the number of elements in a single collection. eg. an array of bytes could have no more than 500000000 elements.
- A limit on the total number of elements in a collection and its nested collections combined. So a limit of 500000000 elements would prevent a 2d array of 400000000 by 400000000 elements.
Metadata
Metadata
Assignees
Labels
No labels