Skip to main content

SKY-D389 · Security in code

Request text inserted into a regular expression

MediumCWE-74

Unescaped request text is placed between fixed parts of a regular expression. The input can change the pattern.

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

Input with regex syntax can change which strings an application accepts.

What Skylos flags

src/lib.rs · RustReported on line 5
use axum::extract::Path;use regex::Regex;pub fn matcher(Path(value): Path<String>) {    let p = format!("^user/{value}$");    let _ = Regex::new(&p);}

What Skylos leaves alone

src/lib.rs · Rust
use axum::extract::Path;use regex::Regex;pub fn matcher(Path(value): Path<String>) {    let literal = regex::escape(&value);    let _ = Regex::new(&format!("^user/{literal}$"));}

Why Skylos leaves it alone

The extractor value is escaped before interpolation.

How Skylos decides

  1. Skylos checks supported request string extractors, simple format! placeholders between literal fragments, and a resolved regex constructor.
  2. Supplying a complete search pattern has separate semantics.

How to fix it

Use regex::escape before inserting a value intended to match literal text.

When it can be wrong

  • Search or policy features that deliberately accept regex fragments may need this behavior.

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-D389].

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