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

Aperta
#1,713 8 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@sayxnn17 ci sta già lavorando.

Dal 14/11/2026.

  • #1718 di @sayxnn17 — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
Mezza giornata
Idoneità per principianti
65/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
Lingua principale
Python
Stelle
322
Fork
793
Merge medio
6g 10h
PR unite (30g)
20

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/PictoPy

Tutte le issue di AOSSIE-Org/PictoPy

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.