SKY-D390 · Security in code
Request controls initial allocation capacity
HighCWE-789
A Rust request supplies a buffer capacity. The rule covers initial allocations and reservations on a new integer vector.
- Languages
- Rust
- Quality gate
- counted toward the gate limits (full and diff scans)
- Finding type
- review
Why it matters
A sufficiently large request value can exhaust the memory available to a service.
What Skylos flags
use axum::extract::Path;pub fn scratch(Path(size): Path<usize>) { let _buf = String::with_capacity(size);}What Skylos leaves alone
use axum::extract::Path;pub fn scratch(Path(size): Path<usize>) { let _buf = String::with_capacity(size.min(4096));}Why Skylos leaves it alone
The capacity is limited to 4096 bytes.
How Skylos decides
- Skylos looks for a destructured usize request extractor and a direct capacity call at the start of a function, including simple aliases of the size.
- It skips earlier checks and unknown control flow.
How to fix it
Choose a maximum based on the request budget and enforce it before allocation.
When it can be wrong
- An application may enforce the size limit in middleware that runs before the handler.
Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.
How to silence it
Record the reason on the reported line with
// skylos: ignore[SKY-D390].