Bypassing Laravel wildcard validation rules with an empty JSON key

An empty JSON object key flattened to a double dot like users..role, causing Laravel's validator to skip dependent rules like required_if and Rule::forEach.

JSON allows empty string keys like "", and PHP preserves them when decoding into an array. In Laravel's validator, sending an object keyed by "" instead of a normal list was enough to silently bypass wildcard-dependent rules like required_if and entire Rule::forEach rule sets.

If you relied on Rule::forEach or wildcard rules to enforce authorization checks (for example, Rule::can) or conditional fields on nested items, an attacker could slip a payload right past validation and still get it back in $request->validated().

Reproducing the bypass

Take a simple validation block where admins must provide an invite code:

$validated = $request->validate([
    'users' => ['required', 'array'],
    'users.*.role' => ['required', Rule::in(['user', 'admin'])],
    'users.*.invite_code' => [
        'required_if:users.*.role,admin',
    ],
]);

With a normal JSON array, validation fails as expected:

{
  "users": [
    { "role": "admin" }
  ]
}

Laravel rejects it with The users.0.invite_code field is required when users.0.role is admin.

Now change users from an array to an object with an empty key:

{
  "users": {
    "": { "role": "admin" }
  }
}

Validation passes, and Laravel returns the admin user in $validated without ever requiring invite_code.

Three regexes that disagreed

Internally, Laravel flattens nested input using dot notation. An empty key turns users[""]["role"] into users..role.

The bug came down to a one-character regex mismatch across three files in Illuminate\Validation.

ValidationRuleParser::explodeWildcardRules() matched wildcards with * (zero or more non-dot characters), so it accepted the empty segment between the two dots:

// src/Illuminate/Validation/ValidationRuleParser.php
$pattern = str_replace('\*', '[^\.]*', preg_quote($attribute, '/'));

Meanwhile, ValidationData::extractValuesForWildcards() and Validator::getExplicitKeys() both used + (one or more non-dot characters):

// src/Illuminate/Validation/ValidationData.php
$pattern = str_replace('\*', '[^\.]+', preg_quote($attribute, '/'));

// src/Illuminate/Validation/Validator.php
$pattern = str_replace('\*', '([^\.]+)', preg_quote($this->getPrimaryAttribute($attribute), '/'));

Because [^\.]+ refuses to match an empty segment, Validator::getExplicitKeys() couldn't bind users.*.role to users..role. When required_if went to check the sibling role field, it treated it as missing and let the request through.

ValidationData::extractValuesForWildcards() had the same mismatch, which meant Rule::forEach could skip every rule it was supposed to run on an item stored under "".

The fix

Taylor fixed the disagreement in commit f9c010a by switching both [^\.]+ patterns to [^\.]* so all three places handle empty segments the same way:

// src/Illuminate/Validation/ValidationData.php
$pattern = str_replace('\*', '[^\.]*', preg_quote($attribute, '/'));

// src/Illuminate/Validation/Validator.php
$pattern = str_replace('\*', '([^\.]*)', preg_quote($this->getPrimaryAttribute($attribute), '/'));

The fix shipped in Laravel 13.30.0 on September 1, 2026. No public CVE was assigned, so if your app validates nested arrays with wildcard rules or Rule::forEach and is still below 13.30.0, it's worth updating.

Thanks for reading.
Hristijan