High severityPHPInjectionHIGH confidence
Preg Replace Eval Modifier
preg_replace() is called with the deprecated /e (PREG_REPLACE_EVAL) modifier, which evaluates the replacement as PHP code and is a code injection vector (CWE-94).
Standards mapping
- OWASP Top 10
- A03:2021 - Injection
- OWASP ASVS
- V5.3.6 (L1)
Vulnerable vs. safe
Flagged by this check
return preg_replace('/(\w+)/e', 'strtoupper("$1")', $subject);Passes - the safe pattern
return preg_replace_callback('/(\w+)/', fn($m) => strtoupper($m[1]), $subject);Why it matters & how to fix it
preg_replace() is called with the deprecated /e (PREG_REPLACE_EVAL) modifier, which evaluates the replacement as PHP code and is a code injection vector (CWE-94). Remove /e and use preg_replace_callback() instead.
References
Rule ID integsec-php-preg-replace-eval-modifier - engine: Opengrep - license: MIT - Copyright (c) IntegSec Inc.
TurboPentest runs this check automatically
Connect a GitHub repo and this check runs on every white-box pentest - AI-validated and reported with proof, from $99 per target.
Start a pentestRelated checks
- JavaScript / TypeScript - InjectionCode Injection Tainted Input
- JavaScript / TypeScript - InjectionEval Dynamic Argument
- JavaScript / TypeScript - InjectionNoSQL Query From Request
- JavaScript / TypeScript - InjectionNoSQL Where Operator
- JavaScript / TypeScript - InjectionOS Command Injection Tainted Input
- JavaScript / TypeScript - InjectionSQL Injection String Concatenation