Skip to content

Fix hidden albums leaking via "present in albums" list#4387

Merged
ildyria merged 2 commits into
masterfrom
copilot/fix-discussion-4355-issue
Jun 1, 2026
Merged

Fix hidden albums leaking via "present in albums" list#4387
ildyria merged 2 commits into
masterfrom
copilot/fix-discussion-4355-issue

Conversation

Copilot AI commented May 31, 2026

Copy link
Copy Markdown
Contributor

When a photo exists in both a visible album and a hidden (link-required) album, the /Photo/{id}/albums endpoint was exposing the hidden album to any user who could see the photo — leaking the album's existence and granting unintended access.

Root cause

PhotoController::albums() filtered using AlbumPolicy::canAccess(), which returns true for any public album regardless of is_link_required. Albums with is_link_required = true are intentionally hidden from listings but were surfaced through this endpoint.

Changes

  • PhotoController::albums() — replaces the canAccess filter with an explicit visibility check:

    • Owner → always included
    • Explicitly shared user (current_user_permissions !== null) → included
    • Public album → only included if is_link_required === false (and not password-locked)
  • GetPhotoAlbumsTest — adds regression test testHiddenAlbumNotShownToNonOwner: photo in a visible public album + a hidden (link-required) album; verifies the hidden album is absent from the response for unauthenticated users.

// Before — hides nothing link-required
->filter(fn ($album) => $album_policy->canAccess($user, $album))

// After — respects listing visibility
$public_perm = $album->public_permissions();
return $public_perm !== null
    && $public_perm->is_link_required === false
    && ($public_perm->password === null || $album_policy->isUnlocked($album));

Copilot AI and others added 2 commits May 31, 2026 22:10
Co-authored-by: ildyria <627094+ildyria@users.noreply.github.com>
Co-authored-by: ildyria <627094+ildyria@users.noreply.github.com>
@ildyria ildyria marked this pull request as ready for review May 31, 2026 22:16
@ildyria ildyria requested a review from a team as a code owner May 31, 2026 22:16
@codecov

codecov Bot commented May 31, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 90.23%. Comparing base (46c372d) to head (597bcee).

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread app/Http/Controllers/Gallery/PhotoController.php
@ildyria ildyria merged commit 77fd7bf into master Jun 1, 2026
45 checks passed
@ildyria ildyria deleted the copilot/fix-discussion-4355-issue branch June 1, 2026 12:10
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.

3 participants