Laravel JSON:API include can empty a table (CVE-2026-114508): which APIs to check
Laravel 12.45.0 added a built-in JSON:API resource. From that release up to 12.67.0, and in 13.x before 13.27.0, the nested part of ?include= was handed to Eloquent’s loadMissing() without being checked against the relationships the resource declares. Change ?include=comments to ?include=comments.truncate and Eloquent calls truncate as if it were a relation method. If the relation has rows and the database lets the statement through, the whole comments table is emptied, and only then does the response turn into an HTTP 500. The advisory is CVE-2026-114508 (GHSA-5wcm-3v2w-8362), CVSS 3.1 score 6.5, fixed in 12.68.0 and 13.27.0.
The fix shipped in August 2026 and the CVE was published in October. It is being discussed again because the reporter, Hristijan Manasijev, wrote it up on 26 November. I reproduced it on OrbStack with 12.67.0 and 12.68.0 against SQLite, MySQL and PostgreSQL. The result broadly matches the write-up, but whether the table is emptied, and how much goes with it, depends on the database, foreign keys and the database account’s privileges. If you use JsonApiResource, upgrade first; if you cannot yet, check whether your application’s database account can run TRUNCATE.
Timeline
All dates below are Taipei time. The JSON:API resource arrived in 12.45.0, released on 2026-01-06 (PR #57571). Taylor Otwell merged PR #61322 (13.x) and #61323 (12.x) on 25 August, both titled “Fix resource loading” with no description, and 13.27.0 and 12.68.0 were released that evening. The release notes list the change only as “Fix resource loading” and do not mark it as a security fix. Laravel published the GitHub advisory on 19 October, alongside CVE-2026-114509 (a token guard authentication bypass), and NVD added the CVE on 22 October. At the time of checking, its NVD status was still Awaiting Analysis.
The release notes gave no sign of a security risk, and the advisory followed about eight weeks after the fix.
Fixing first and disclosing later, while the problem is still small and before anything goes wrong, is a reasonable order, and I have no quarrel with it. But you can only deal with what you know you do not know. A release note that only says “Fix resource loading” leaves readers unaware that there is anything they do not know, so where the upgrade lands in their queue is down to luck. The fix can still be quiet; a line telling users to prioritise this release costs little and lets people finish the job before the advisory appears.
How it happens
JsonApiRequest::sparseIncluded() splits include=comments.truncate in two. The first segment, comments, is compared with the resource’s toRelationships(), and undeclared relations are filtered out. The second segment is the problem. In 12.67.0, ResolvesJsonApiElements::compileResourceRelationships() does this for every loaded relation:
// laravel/framework v12.67.0, ResolvesJsonApiElements.php
if (! is_null($relatedModels) && $this->includesPreviouslyLoadedRelationships === false) {
if (! empty($relations = $request->sparseIncluded($relationName))) {
$relatedModels->loadMissing($relations);
}
}
$relations is ['truncate'], straight from the query string, and nothing compares it with the relationships CommentResource declares. loadMissing() ends up in Eloquent\Builder::getRelation(), which obtains the relation with $this->getModel()->newInstance()->$name(). Comment has no truncate() method, so Model::__call forwards the call to the query builder, and Query\Builder::truncate() sends its SQL against the whole table with no where clause. What comes back is an Eloquent\Builder rather than a Relation, so the BadMethodCallException is only thrown at the next step, when addEagerConstraints() is called. By then the rows are gone.
The fix compiles nested includes only for relationships the resource declares, and the loadMissing($relations) block is removed. The tests added in the PR send include=comments.truncate and include=posts.comments.truncate and assert a 200 with Comment::count() unchanged.
Reproduction
The test app is the laravel/laravel 12.x skeleton. User defines a hasMany relationship through comments(), UserResource extends JsonApiResource and returns ['comments'] from toRelationships(), and the GET /api/users/{user} route requires no authentication. The data is three users and five comments: two for alice, three for bob and none for carol. The database is rebuilt before every request, and DB::listen records the SQL that executed successfully; failed statements show up in the exception message instead.
// routes/api.php
Route::get('/users/{user}', fn (User $user) => new UserResource($user));
Actual output for alice (GET /api/users/1?include=comments.truncate) on 12.67.0 with SQLite:
framework=12.67.0 driver=sqlite
before: comments=5
GET include=comments.truncate user=1 -> HTTP 500
sql: select * from "users" where "id" = ? limit 1
sql: select * from "comments" where "comments"."user_id" in (1)
sql: delete from sqlite_sequence where name = ?
sql: delete from "comments"
exception: BadMethodCallException: Call to undefined method Illuminate\Database\Eloquent\Builder::addEagerConstraints()
after: comments=0
Alice has two comments, yet all five rows in the table are deleted, bob’s included. When the request targets carol, the relation is empty, so Eloquent\Collection::loadMissing() does nothing; the response is a 200 and the data is intact. An attacker therefore has to pick a resource whose relation has rows.
How the three databases behaved on 12.67.0:
| Database | SQL sent | Default case | Request wrapped in a transaction, then rolled back | Another table has a foreign key to comments | Database account with only SELECT, INSERT, UPDATE, DELETE |
|---|---|---|---|---|---|
| SQLite 3.53.4 | delete from "comments" |
All 5 rows deleted | Rows restored | Blocked by the foreign key (Laravel enables SQLite foreign key checks by default), 500, data intact | Not applicable |
| MySQL 8.4.13 | truncate table |
All 5 rows deleted | Rows not restored | Blocked with error 1701, data intact | Error 1142 (DROP privilege required), data intact |
| PostgreSQL 17.12 | truncate ... restart identity cascade |
All 5 rows deleted | Rows restored | The referencing comment_likes table is emptied as well |
permission denied, data intact |
The write-up says Laravel ran TRUNCATE TABLE. SQLite has no TRUNCATE, so what it receives is a DELETE. MySQL’s TRUNCATE causes an implicit commit, so a surrounding transaction cannot undo it. PostgreSQL’s TRUNCATE can be rolled back, but Laravel’s PostgresGrammar adds cascade by default, so here the foreign key widens the damage and the table that references comments is emptied too. In this setup the foreign key blocked the deletion on MySQL and SQLite: it used the default NO ACTION behaviour, and the child table already had referencing rows. With ON DELETE CASCADE, SQLite’s DELETE could take the child rows with it; I did not test that case.
On 12.68.0 the same request returns a 200 on all three databases, the only SQL is the two selects, and the data is unchanged.
I did not test 13.x; the affected range before 13.27.0 is taken from the advisory and NVD. The test route has no authentication. If a real route requires login, an attacker needs at least an account that can read the API; the PR:N in the CVSS vector does not mean the route’s own authorisation is bypassed.
Which projects to check
For this payload to empty a table, all of the following must hold. The app uses Laravel’s built-in Illuminate\Http\Resources\JsonApi\JsonApiResource on a version from 12.45.0 to 12.67.0, or 13.x before 13.27.0. The resource’s toRelationships() declares at least one relation. Clients can send include with a nested path. The included relation has rows. The application’s database account can run TRUNCATE (DROP on MySQL, TRUNCATE on PostgreSQL), or the database is SQLite. Routes that only use a plain JsonResource and never go through the built-in JSON:API resource do not reach this code. Projects using a package such as Spatie laravel-query-builder should still check whether they also use the built-in JSON:API resource.
# In range if 12.45.0 <= x < 12.68.0, or 13.x < 13.27.0
composer show laravel/framework | grep -E '^versions'
# Is the built-in JSON:API resource in use?
grep -rn 'Resources\\JsonApi\\JsonApiResource' app/
Run composer update laravel/framework and check that you end up on at least 12.68.0 on 12.x or 13.27.0 on 13.x. If you cannot upgrade straight away, you can reject requests whose include contains a . in middleware, or deny the application’s database account the TRUNCATE privilege. I only tested the privilege route.
On MySQL, TRUNCATE falls under the DROP privilege, and an application that shares its account with migrations usually has DROP and ALTER as well. Split migrations and the application into two accounts and remove DROP (MySQL) or TRUNCATE (PostgreSQL) from the application account, and in my tests this request became a privilege error. That stops this one payload; you still need to upgrade. A CVSS of 6.5 does not look high, but the real loss depends on the entry point and the account’s privileges; I wrote about ordering patches that way in Ordering security patches by entry point, privilege and evidence.
The more clever tricks a system has, the more strange things it produces. __call forwarding an unknown method to the query builder saves typing, and truncate being called as a relation name grew out of that convenience. Go has no __call. Whether another ORM that loads relations by string name can be steered into a non-relation method depends on its implementation, but letting an external parameter decide which relations load should be limited at the boundary either way. Checking against a hard-coded allowlist at the boundary looks clumsy, and you edit it every time you add a relation, but in return an external string can only select what you thought about in advance. Parameters such as include, sort and fields deserve the same treatment.
Notes
- CVE-2026-114508 affects Laravel’s built-in
JsonApiResourcefrom 12.45.0 to 12.67.0 and in 13.x before 13.27.0; the fixed versions are 12.68.0 and 13.27.0. - The second segment of a nested include was not checked against the resource’s declarations and was called as an Eloquent method;
truncatehas no where clause, so the whole table goes. - In my tests Laravel issued
DELETEon SQLite andTRUNCATEon MySQL, where a rollback could not restore the rows; on PostgreSQL it addedcascade, which emptied the referencing table as well. - No rows were deleted when the relation was empty, when a foreign key blocked it (MySQL, SQLite), or when the database account lacked the TRUNCATE privilege.
- The fix shipped in August without a security label in the release notes; the advisory followed in October.
Further reading
- GHSA-5wcm-3v2w-8362: Laravel’s advisory, primary source for affected versions and CVSS.
- CVE-2026-114508 (NVD): the NVD entry, primary source.
- laravel/framework PR #61322: the 13.x fix and tests, primary source; 12.x is PR #61323.
- Laravel v12.68.0 release: official release notes, primary source.
- Laravel v13.27.0 release: official release notes, primary source.
- Hristijan Manasijev: Laravel JSON:API include truncate: the reporter’s own write-up, primary source for the reporter’s account.
Ideas and technical judgement by Sheng; drafted with Claude · Reviewed with Codex and Grok; reproduced on OrbStack with Laravel 12.67.0 and 12.68.0, PHP 8.5.13, SQLite 3.53.4, MySQL 8.4.13 and PostgreSQL 17.12, 13.x not tested; sources checked up to 2026-11-27 (Taipei time)