Published on

A Laravel JSON:API GET could truncate a table

A Laravel JSON:API GET could truncate a table
Authors
On this page

You can empty a Laravel table with a GET request. No POST, no DELETE, no write permission. Just a slightly weird include query parameter on a JSON:API endpoint.

That is CVE-2026-114508, also tracked as GHSA-5wcm-3v2w-8362. This is not a bug I found. Hristijan Manasijev reported it and wrote up how it works. I'm passing it along because the upgrade is simple and the failure mode is ugly.

What happened

Laravel's built-in JSON:API resources (JsonApiResource) arrived in 12.45.0. Clients can ask for related models with the usual include parameter:

GET /api/authors/1?include=comments

His write-up shows that appending a nested segment that is not a relationship was enough:

GET /api/authors/1?include=comments.truncate

Laravel checked the first segment, comments, against the relationships declared on the author resource. That part is real, so it passed. The next segment, truncate, was handed to Eloquent's loadMissing() without being checked against the comment resource.

Eloquent then tried to load a relationship named truncate on the comment model. There isn't one. Model::__call() forwarded the call to the query builder, and the query builder has a real truncate() method. That runs TRUNCATE TABLE immediately.

The write-up says the response was still an HTTP 500, because truncate() does not return a Relation and Laravel then failed inside addEagerConstraints(). By then the comments table was already empty, for every author, not just author 1.

The same pattern worked deeper in the graph, for example ?include=posts.comments.truncate. It was not limited to truncate either. Any zero-argument query builder method reachable through Model::__call() could be invoked the same way.

The official fix tests in PR #61322 use those exact include paths and assert that the comments are still there.

Who is affected

You are in the affected range if you run laravel/framework in either of these windows:

The bug lives in the JSON:API resource code. If your app does not return JsonApiResource responses, this path should not run. Laravel 11 and earlier never shipped these resources.

The advisory rates it 6.5 Medium. The impact is data loss, not data theft: a caller with access to a read endpoint could empty a related table.

How to check

See the installed version:

composer show laravel/framework

Or look up laravel/framework in composer.lock and read the locked version. If you are on 12.x below 12.68.0, or 13.x below 13.27.0, and you use JSON:API resources, you should upgrade.

How to fix

Upgrade laravel/framework to 12.68.0 or 13.27.0, whichever major you are on:

composer update laravel/framework

Then confirm the new version with composer show laravel/framework again. If the version does not move, check the constraint in composer.json.

The fix removes the unvalidated loadMissing() call. Nested include segments are now handed to the child JsonApiResource, which only resolves relationships it declares in toRelationships(). A name it does not declare, like truncate, is ignored.

I would still allowlist includes in your own code. The framework patch closes this hole, but the habit is the same anywhere user input can become a method or relation name:

$allowed = [
    'comments',
    'posts',
    'posts.comments',
];

$includes = collect(explode(',', (string) $request->query('include', '')))
    ->map(fn (string $include) => trim($include))
    ->filter(fn (string $include) => in_array($include, $allowed, true))
    ->values();

Pass only that list into whatever loads relationships. Don't forward the raw query string.

The takeaway

If a request parameter can reach a method name, allowlist it. Laravel checked the first segment and trusted the rest. That is the kind of gap that turns a read into a TRUNCATE.

Upgrade first. Then make sure your own include handling does the same thing the framework now does: only names you have declared get through.


Resources

Frequently asked questions

Which Laravel versions are affected by CVE-2026-114508?
laravel/framework 12.45.0 through 12.67.x, and 13.0.0 through 13.26.x. The fixes are 12.68.0 and 13.27.0. Only apps that return Laravel JSON:API resources are in the path. Laravel 11 and earlier never shipped those resources.
How do I check if my app is affected?
Run composer show laravel/framework, or read the locked version in composer.lock. If you are below 12.68.0 or 13.27.0 and you use JsonApiResource, upgrade.
How do I fix the Laravel JSON:API include truncate bug?
Upgrade laravel/framework to 12.68.0 or 13.27.0. As a backup habit, allowlist include names in your own code and never pass the raw query string into relationship loading.