CVE-2026-142649: CVE-2026-142649: Input Validation Bypass via Loose Type Comparison in Laravel Framework
CVE-2026-142649: Input Validation Bypass via Loose Type Comparison in Laravel Framework Vulnerability ID: CVE-2026-142649 CVSS Score: 5.3 Published: 2026-12-03 CVE-2026-142649 (also tracked as GHSA-h2hg-mfj4-rg7q) i
CVE-2026-142649: Input Validation Bypass via Loose Type Comparison in Laravel Framework
Vulnerability ID: CVE-2026-142649
CVSS Score: 5.3
Published: 2026-12-03
CVE-2026-142649 (also tracked as GHSA-h2hg-mfj4-rg7q) is an input validation bypass vulnerability affecting the validation subsystem of the Laravel web application framework (laravel/framework). Specifically, the validateIn method in src/Illuminate/Validation/Concerns/ValidatesAttributes.php performs non-strict comparisons when evaluating scalar input values against defined allowlists for the 'in', 'Rule::in', and 'not_in' validation rules. Because PHP's native in_array() function defaults to loose equality (==) when the third parameter ($strict) is omitted, numeric strings with non-canonical representationsβsuch as leading or trailing whitespace, embedded newlines, leading zeros, positive signs, decimal points, or scientific notationβevaluate as equal to standard numeric allowlist entries. Furthermore, because Laravel's validated() and valid() accessor methods return the original, un-canonicalized input string rather than the matched allowlist token, unvalidated characters and unexpected string formats propagate directly into downstream business logic, database queries, and state enforcement checks.
TL;DR
An omitted strict flag in PHP's in_array() call within Laravel's validateIn method allows non-canonical numeric strings (containing whitespace, newlines, scientific notation, or leading zeros) to bypass the 'in', 'Rule::in', and 'not_in' validation rules. Fixed in Laravel 12.67.0 and 13.26.0.
β οΈ Exploit Status: POC
Technical Details
- CVE ID: CVE-2026-142649 (GHSA-h2hg-mfj4-rg7q)
- CWE Classification: CWE-697: Incorrect Comparison
- CVSS v3.1 Score: 5.3 Medium (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N)
- EPSS Score: 0.46% (41.58th Percentile)
- Affected Component: Illuminate\Validation\Concerns\ValidatesAttributes::validateIn
- Attack Vector: Network (Unauthenticated HTTP Request with Non-Canonical Numeric String)
- Exploit Status: PoC (Unit tests in vendor patch)
- CISA KEV Status: Not Listed
Affected Systems
- laravel/framework
-
laravel/framework: < 12.67.0 (Fixed in:
12.67.0) -
laravel/framework: >= 13.0.0, < 13.26.0 (Fixed in:
13.26.0)
Code Analysis
Commit: 0db83d4
Enforce strict comparison in validateIn by passing true as the third parameter to in_array()
diff --git a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php
index e23dbce..63ecdd2 100644
--- a/src/Illuminate/Validation/Concerns/ValidatesAttributes.php
+++ b/src/Illuminate/Validation/Concerns/ValidatesAttributes.php
@@ -1522,7 +1522,7 @@ public function validateIn($attribute, $value, $parameters)
return count(array_diff($value, $parameters)) === 0;
}
- return ! is_array($value) && in_array((string) $value, $parameters);
+ return ! is_array($value) && in_array((string) $value, $parameters, true);
}
/**
diff --git a/tests/Validation/ValidationInRuleTest.php b/tests/Validation/ValidationInRuleTest.php
index cd66ae4..12d28f0 100644
--- a/tests/Validation/ValidationInRuleTest.php
+++ b/tests/Validation/ValidationInRuleTest.php
@@ -8,6 +8,7 @@
use Illuminate\\
Validation\\Rule;
use Illuminate\\Validation\\Rules\\In;
use Illuminate\\Validation\\Validator;
+use PHPUnit\\Framework\\Attributes\\TestWith;
use PHPUnit\\Framework\\TestCase;
include_once 'Enums.php';
@@ -89,4 +90,22 @@ public function testInRuleValidation()
$v = new Validator($trans, ['x' => 'foo'], ['x' => ['required', Rule::in('foo', 'bar')]]);
$this->assertTrue($v->passes());
}
+
+ #[TestWith([' 1', false])]
+ #[TestWith(['1 ', false])]
+ #[TestWith(["\t1", false])]
+ #[TestWith(["1\n", false])]
+ #[TestWith(['01', false])]
+ #[TestWith(['+1', false])]
+ #[TestWith(['1.0', false])]
+ #[TestWith(['1e0', false])]
+ #[TestWith(['1', true])]
+ public function testInRuleIsNotLoosyBypassed(mixed $value, bool $expectation)
+ {
+ $trans = new Translator(new ArrayLoader, 'en');
+
+ $v = new Validator($trans, ['x' => $value], ['x' => ['in:1,2,3']]);
+
+ $this->assertSame($expectation, $v->passes());
+ }
}
Exploit Details
- GitHub: Official patch commit containing PHPUnit test cases demonstrating the validation bypass vectors (' 1', '1 ', '\t1', '1\n', '01', '+1', '1.0', '1e0').
Mitigation Strategies
- Upgrade laravel/framework to version 12.67.0 or 13.26.0 (or later) to enforce strict comparison (in_array with $strict = true) in validateIn.
- Enforce explicit data type validation rules (such as 'integer' or 'digits') alongside 'in', 'Rule::in', and 'not_in' rules when validating numeric identifiers.
- Explicitly cast validated numeric parameters to (int) before performing downstream strict comparisons (===), match() expressions, or cache key generation.
- Maintain the TrimStrings middleware globally across all HTTP and API route groups to strip leading and trailing whitespace and newline characters.
Remediation Steps:
- Audit composer.lock to identify if laravel/framework is on a vulnerable version (< 12.67.0 or >= 13.0.0, < 13.26.0).
- Run 'composer update laravel/framework' to install version 12.67.0+ or 13.26.0+.
- Review application validation rules using 'in', 'Rule::in', or 'not_in' with numeric parameters to ensure downstream consumers handle strict string types properly.
- Run the application's automated test suite to verify that no legacy workflows depend on non-canonical numeric strings passing validation.
References
- GitHub Security Advisory GHSA-h2hg-mfj4-rg7q
- Laravel Framework Pull Request #61146
- Fix Commit 0db83d4177675d9290bee91f33f90b2b5828e56e
- Laravel v12.67.0 Release Notes
- Laravel v13.26.0 Release Notes
- NVD - CVE-2026-142649
- CVE.org - CVE-2026-142649
Read the full report for CVE-2026-142649 on our website for more details including interactive diagrams and full exploit analysis.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.