Upload routes inherit the Get operation's security, not Patch's

Aperta
#581 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
72/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
php, symfony
Ambito
api, backend, security

Direzione di ricerca

Start with UploadableResourceMetadataCollectionFactory, where the upload route is built from the resource's Get operation. Inspect how security and securityPostDenormalize are assigned, and trace the resource's Patch/Put metadata instead. The change is complete when the generated upload operation inherits the write operation's security and the documented anonymous-upload reproduction is rejected.

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

Descrizione

Problem

The bundle builds an uploadable resource's item upload route (POST {iri}/upload) from the resource's Get operation (UploadableResourceMetadataCollectionFactory), so the upload operation gets Get's security. A component with a public Get (the normal case: anyone can read published content) therefore has no operation-level security on uploads. Only the firewall's access_control (component writes admin-only in the template's security.yaml) stops a visitor from replacing a file.

Repro

  1. Add #[Silverback\Uploadable] + an #[UploadableField] to a component whose operations are Get (public) and Patch(security: "is_granted('ROLE_ADMIN')").
  2. Remove or loosen the access_control line for component writes.
  3. POST /_api/component/<type>/<id>/upload as an anonymous user: the upload is accepted.

Fix used locally (Dons Hub)

Restrict Get to reads unless admin, so the derived upload operation is admin-only:

new Get(security: "request === null or request.getMethod() in ['GET', 'HEAD'] or is_granted('ROLE_ADMIN')"),

The proper fix would be for the factory to base the upload operation's security (and securityPostDenormalize) on the resource's Patch/Put operation instead of Get.

Lingua principale
PHP
Stelle
32
Fork
8
Merge medio
1h 11m
PR unite (30g)
123

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

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 components-web-app/api-components-bundle

Tutte le issue di components-web-app/api-components-bundle

Issue simili

Altre issue su PHP

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.