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
Why it matters
Input with regex syntax can change which strings an application accepts.
What Skylos flags
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
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
- Skylos checks supported request string extractors, simple format! placeholders between literal fragments, and a resolved regex constructor.
- 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].