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

オープン
#581 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
php, symfony
領域
api, backend, security

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
PHP
スター
32
フォーク
8
平均マージ
1時間 11分
マージ済み PR(30日)
123

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

components-web-app/api-components-bundle のほかの issue

components-web-app/api-components-bundle の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。