Skip to content

Scope example item to the tenant to close cross-tenant IDOR - #4

Merged
HafizMMoaz merged 1 commit into
masterfrom
fix/tenant-scope-idor
Jul 18, 2026
Merged

Scope example item to the tenant to close cross-tenant IDOR#4
HafizMMoaz merged 1 commit into
masterfrom
fix/tenant-scope-idor

Conversation

@HafizMMoaz

Copy link
Copy Markdown
Member

Problem

update() and destroy() in ExamplePackageItemController authorise with a capability check alone (can('edit-example-package')), which every tenant's staff passes. With a route-model-bound ExamplePackageItem $item, an id belonging to another company resolved fine and was then edited or deleted. index() scopes by created_by/creator_id, but the mutations do not.

Because every module is generated from this template, the hole reproduces in each new module.

Fix

Put the boundary on the model, not each action: add App\Models\Concerns\TenantScoped to ExamplePackageItem. The row owns itself via created_by (the tenant id), so a foreign id now resolves to null and route-model binding 404s before the controller runs. This is the same trait the other modules use to close the same class of IDOR.

Also removes a stray empty ->with() call left before the flash message in update()/destroy().

Verification

Scaffold a module from the template and hit update/destroy with another tenant's id, expect a 404 rather than an edit/delete.

update() and destroy() authorise with a capability check alone, which every
tenant's staff passes, so a route-model-bound id from another company resolved
and was edited or deleted. Add App\Models\Concerns\TenantScoped to the model
so a foreign id 404s at route binding before the controller runs. Every module
is generated from this template, so the hole reproduced in each one.

Also drop the stray empty ->with() left before the flash message.
@HafizMMoaz
HafizMMoaz requested a review from a team as a code owner July 18, 2026 20:28
@HafizMMoaz
HafizMMoaz merged commit d344dde into master Jul 18, 2026
2 checks passed
@HafizMMoaz
HafizMMoaz deleted the fix/tenant-scope-idor branch July 18, 2026 20:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant