⚠️

سلب مسئولیت و اخلاق حرفه‌ای

این مطالب صرفاً برای اهداف آموزشی، پژوهشی و افزایش آگاهی امنیتی ارائه شده‌اند. هرگونه استفاده غیرمجاز، غیرقانونی یا سوءاستفاده از اطلاعات، ابزارها و روش‌های مطرح‌شده، کاملاً بر عهده مخاطب است. نویسنده و منتشرکننده هیچ مسئولیتی در قبال خسارات، آسیب‌ها یا پیامدهای ناشی از استفاده نادرست از این مطالب نخواهند داشت.

CVE-2026-142643: Laravel exists and unique validation rules bypassed by JSON integer and boolean values on MySQL and MariaDB | Alireza Bolbolabadi - Red Team Security
LOADING

CVE-2026-142643: Laravel exists and unique validation rules bypassed by JSON integer and boolean values on MySQL and MariaDB

Overview

Laravel is a web application framework used to build PHP web applications, and its request validation layer is one of the most widely relied-upon integrity controls in Laravel codebases. Rules such as exists and unique are commonly used to guarantee that a submitted value — an invitation code, a token, a tenant identifier — actually points at a database record before an application acts on it.

CVE-2026-142643 shows that this guarantee could be broken under specific conditions. The exists and unique rules passed integer and boolean values originating from a JSON request straight into the database query instead of converting them to strings. When the database is MySQL or MariaDB, comparing a string column against an integer triggers type coercion: the column value is cast to a number before comparison. The practical consequence is that a JSON payload carrying 0, false or [0] can satisfy a rule written as required|exists:invites,code even though the non-numeric string column never contained a valid matching value.

The flaw is fixed in Laravel 13.43.0 and 12.73.0.

How the flaw works

The vulnerable path is a combination of three factors:

  1. Input format. The request body is JSON. Form-encoded input is always treated as a string and is not affected.

  1. Validation rule. The controller or form request applies exists or unique to the submitted value.

  1. Database engine and column type. The target column is a non-numeric string, and the database is MySQL or MariaDB. PostgreSQL and SQLite are not affected.

When all three align, the SQL comparison executed by the validation rule receives an integer or boolean rather than the string identifier the developer intended. MySQL and MariaDB then coerce the string column to a number to perform the comparison, and numeric zero-like values can match rows that hold no legitimate identifier at all. The advisory describes the case as bypassing a "must reference an existing record" check, and the sample rule required|exists:invites,code points to a plausible deployment shape where invitation or redeem codes are validated against a string column.

Attack scenario

An unauthenticated attacker submits JSON to an endpoint that accepts it and applies an affected exists or unique rule against a non-numeric string column. Instead of supplying a real code, the attacker sends a numeric or boolean value such as 0, false or [0]. If the comparison coerces to zero, validation passes and the request proceeds as though the supplied identifier were legitimate.

What happens next is application-specific. The vulnerable component is a validation primitive, not a business-logic bypass with a single defined outcome: the effect ranges from a rejected-but-misleading validation result to acceptance of a record reference that should never have been honoured. Consequences can include skipping a redeem step, accepting an invalid identifier, or bypassing an invitation gate. The advisory does not establish that any particular Laravel application exposes such an endpoint, so real-world impact depends on the target application's routes, request formats, database schema and authorization model — and on whether the referenced code is a secret whose validity actually matters.

Affected systems

  • Laravel 13.x — versions prior to 13.43.0 are affected; 13.43.0 contains the fix.

  • Laravel 12.x — versions prior to 12.73.0 are affected; 12.73.0 contains the fix.

  • Database engine — only MySQL and MariaDB are vulnerable to the coercion behaviour. PostgreSQL and SQLite are not affected.

  • Request format — only JSON request bodies are affected. Form-encoded requests always deliver strings and are not affected.

  • Validation rules — exists and unique are the affected rules.

  • Column type — exploitation requires the compared column to be a non-numeric string, such as an alphanumeric code column.

Applications on other Laravel branches, or those using PostgreSQL, SQLite, or exclusively form-encoded request parsing, should still confirm their configuration against the advisory rather than assume they are safe by default.

Mitigation

  • Upgrade the framework. Move to Laravel 13.43.0 or later on the 13.x branch, or 12.73.0 or later on the 12.x branch. Both releases contain the fix.

  • Harden identifier input until an upgrade is possible. Reject non-string values before exists or unique validation runs when the target column is a non-numeric string, and normalise request input so identifiers are validated as strings. JSON arrays and booleans need explicit rejection as well, since [0] is a documented bypass input. Apply this server-side; client-side checks are not a control.

  • Audit exposed routes. Review unauthenticated endpoints that accept JSON and rely on exists or unique, prioritising those validating invitation codes, tokens, or other externally supplied references.

  • Watch for residual exposure. Older application code that performs manual lookups without Laravel's validation rules would not necessarily be corrected by the framework update and warrants a separate review.

Detection guidance

Review application logs and request telemetry for JSON values such as 0, false, [0], or other unexpected numeric and boolean types submitted to endpoints performing exists or unique checks. Database audit logs may show validation queries whose comparison value is numeric or boolean rather than the expected string identifier. Detection should be scoped to the affected routes and parameter names, since the advisory defines no universal Laravel log signature.

Expert insight

The interesting part of this defect is not the missing type check but where it lands. Laravel's validation layer is a trust boundary: developers reasonably assume that exists means "this exact string exists". The bug converts that assumption into "this value exists after the database engine decides how to compare it", and it does so silently, with no error, no exception and no log entry.

The MySQL and MariaDB specificity is what turns a type-handling mistake into a security-relevant bypass. Loose type coercion is a long-standing database behaviour that most application code never encounters directly, because string parameters normally arrive as strings. JSON input puts scalars, arrays and booleans into the same channel, and the framework forwarded them without normalisation. The same request against PostgreSQL or SQLite fails closed, which is precisely the kind of inconsistency that makes a cross-database application behave differently in production than in a developer's local environment.

The mitigating factors are meaningful: remote reachability without authentication is possible, but only when an endpoint accepts JSON, applies the affected rule, and does so against a string column on a coercive database engine. Exploitation is also not free of consequences — the attacker bypasses a validation check, not an authorization decision, and what that check was protecting depends entirely on the application. Rated at CVSS 5.3 and with no exploitation recorded and no KEV listing, this sits best in the medium band rather than the critical one, and the highest-value response is the framework upgrade combined with an inventory of JSON endpoints that use exists or unique.

منابع

·
← اخبار