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

Abierto
#1,713 8 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 3 días

@sayxnn17 ya está trabajando en esto.

Desde el 14/11/2026.

  • #1718 de @sayxnn17 — cerrado sin fusionar

Evaluación

Dificultad
3/5
Tiempo estimado
Medio día
Aptitud para principiantes
65/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
python
Área
backend

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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
Lenguaje dominante
Python
Estrellas
322
Forks
793
Merge medio
6 d 10 h
PR fusionados (30 d)
20

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de AOSSIE-Org/PictoPy

Todos los issues de AOSSIE-Org/PictoPy

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.