Authorization bypass: replyAction() in Comment Livewire component bypasses item visibility
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 569
- Forks
- 119
- Avg merge
- 9h 20m
- Merged PRs (30d)
- 1
Description
Summary
The replyAction() method in app/Livewire/Item/Comment.php (line 82) uses Item::findOrFail($itemId) without the visibleForCurrentUser() scope, allowing any authenticated user to reply to comments on private items in private projects.
Inconsistency (1-of-N Pattern)
Every other item access point in the codebase correctly applies the visibleForCurrentUser() scope:
ItemControllerline 24:Item::query()->visibleForCurrentUser()->where('slug', ...)->firstOrFail()ItemControllerline 136:$project->items()->visibleForCurrentUser()->findOrFail($itemId)Header.php,SpotlightSearch.php,BoardColumn.php,RecentItems.phpall use->visibleForCurrentUser()editAction()in the same file (line 56) properly scopes:auth()->user()->comments()->findOrFail($commentId)
Only replyAction() skips visibility enforcement.
Vulnerable Code
// Comment.php line 76-92
->action(function (array $data, array $arguments): void {
$commentData = $arguments['comment'];
$commentId = is_array($commentData) ? $commentData['id'] : $commentData->id;
$itemId = is_array($commentData) ? $commentData['item_id'] : $commentData->item_id;
$item = Item::findOrFail($itemId); // No visibility check
$comment = $item->comments()->findOrFail($commentId);
$item->comments()->create([
'parent_id' => $comment->id,
'user_id' => auth()->id(),
'content' => $data['content']
]);
// ...
});
Impact
- Any authenticated user can reply to comments on private items (items with
private = true) - Any authenticated user can reply to comments on items in private projects
- The
$itemIdcomes from client-side$arguments['comment']data, which Livewire passes from the browser
Suggested Fix
$item = Item::query()->visibleForCurrentUser()->findOrFail($itemId);
This applies the same visibility filtering used everywhere else in the codebase.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in app/Livewire/Item/Comment.php at replyAction() and compare its item lookup with the visibleForCurrentUser() usage in ItemController and the other listed components. Done means replies to private items and private-project items are rejected for users who cannot view them, while authorized replies continue to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- laravel, php
- Domain
- backend, security
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100