BUG:Backend lets an album be locked with no password, making it permanently inaccessible

Open
#1,713 8 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@sayxnn17 is already working on this.

Since Nov 14, 2026.

  • #1718 by @sayxnn17 — closed without merging

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
65/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
backend

Research direction

Start with the password validation in backend/app/schemas/album.py, where the field validator on the create request is skipped when password is omitted, and with the update_album handler that checks current_password only when the album is already locked. Reproduce both requests from the issue against the album endpoints and confirm they return 200 with a locked album that has no password hash. Done when locking without a new password returns a 400 or 422 on both create and update, and tests cover both paths.

Written by the indexing model from the issue text.

Description

bug possible-duplicate
Is there an existing issue for this?
  • I have searched the existing issues
What happened?

The album create/update endpoints accept is_locked: true without a password. The album is saved as locked with password_hash = NULL, so verify_album_password rejects every password from then on. Its photos can't be viewed, it can't be unlocked, and the password can't be changed. Deleting it is the only way out.

Cause

The "locked albums need a password" check in backend/app/schemas/album.py is a @field_validator("password"). In Pydantic v2, field validators don't run on default values, so when the request leaves out password entirely, the check is skipped.

UpdateAlbumRequest has a second gap: the check passes whenever current_password is non-empty. But update_album only verifies current_password if the album is already locked, so for an unlocked album any string works.

Steps to reproduce

  1. Create path:

    POST /albums/   {"name": "A", "is_locked": true}
    

    → 200. Then POST /albums/{id}/images/get with any password → 401 Invalid Password. PUT /albums/{id} to unlock → 401 Incorrect Password.

  2. Update path (on an existing unlocked album):

    PUT /albums/{id}   {"name": "B", "is_locked": true, "current_password": "junk", "password": null}
    

    → 200 Album updated successfully. The album is now locked with no password and can't be opened.

Expected

Both requests should be rejected with a 400/422 when an album is being locked without a new password.

Notes

The Create/Edit dialogs validate this on the client, so normal UI use doesn't hit it. The backend shouldn't rely on that check, though, and any other client or a future UI change could brick albums.

Suggested fix

  • Replace the password field validator in CreateAlbumRequest with a @model_validator(mode="after") so it always runs.
  • In update_album, return 400 when an album that isn't locked yet is being locked without password.
  • Add tests for both paths.

I checked these and I don't think this is a duplicate:

  • #1617: locked albums can be deleted without a password (delete_album).
  • #1631: images can be added/removed on locked albums without a password.
  • #1662: frontend unlock caching; a wrong password briefly opens the album.

All three are about a missing or wrong password check on an album that has a password. This issue is about the backend letting an album be locked with no password stored at all (password_hash = NULL), because the @field_validator("password") in schemas/album.py is skipped when password is omitted, plus the current_password bypass in update_album. After that, no password can open, unlock or edit the album.

The open fixes for those issues (#1675, #1701, #1691) don't touch this validator, so they wouldn't fix this.

I'd like to work on this if it's approved.

Record
  • I agree to follow this project's Code of Conduct
Dominant language
Python
Stars
322
Forks
793
Avg merge
6d 10h
Merged PRs (30d)
20

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from AOSSIE-Org/PictoPy

All issues in AOSSIE-Org/PictoPy

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.