Skip to main content

SKY-D390 · Security in code

Request controls initial allocation capacity

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
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A sufficiently large request value can exhaust the memory available to a service.

What Skylos flags

src/lib.rs · RustReported on line 3
use axum::extract::Path;pub fn scratch(Path(size): Path<usize>) {    let _buf = String::with_capacity(size);}

What Skylos leaves alone

src/lib.rs · Rust
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

  1. 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.
  2. 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].

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.