Repository navigation
【管理画面・ブログ】不正なパラメーターを指定すると 500 エラーになる問題を解決 - #4652
Merged
Merged
Conversation
VAddy の定期スキャンで検出した、数字以外の ID や不正な値を指定したときに 500 エラーとなる箇所を、404 または既定値での表示となるよう修正。 - 一覧の数値の絞り込み条件(コンテンツ・ユーザー・ブログ記事・最近の動き・ アップロード・サイト内検索・管理画面のサイト ID)に数字以外が渡された場合は条件にしない - 受信メール CSV ダウンロードで対応していない文字コードは UTF-8 とする - パスの ID に int 型を指定(アクセスルール・ユーザー・ユーザーグループ・サイト・ ブログカテゴリ・ブログタグ・アップロードカテゴリの編集等) - コンテンツ削除・カスタムエントリー・存在しないプラグイン・存在しない画像は 404 - アクセスルールグループ追加で prefix が無い場合は Admin とする - ブログの日付アーカイブで年月日として解釈できない値は 404 - プラグインのデータ初期化で PUT 以外はプラグイン一覧へ戻す Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
配列形式のIDが除外されず整数列の検索条件に渡されるため、ユーザー一覧・ブログ記事一覧・サイト内検索で変換例外による500エラーが引き続き発生します。
3 open issues
配列形式のユーザーグループIDを無効値として処理する · New 配列形式のブログIDを条件から除外する · New 配列形式の検索IDを既定値または条件なしにする · New
What changed in this PR
#4649 に続き、baserCMS の管理画面・ブログ・サイト内検索で、不正なパラメーターによる 500 エラーを防ぐための変更です。
変更内容:
- 数値の絞り込み条件を検証し、不正な値は除外または既定値に置換。
- 不正な ID・日付や存在しない対象を 404 とし、CSV 文字コードとプラグイン初期化の例外的な入力にも対応。
- 各処理の異常系を確認する回帰テストを追加。
| File | Description |
|---|---|
| plugins/bc-uploader/tests/TestCase/Service/UploadFilesServiceTest.php | 不正なカテゴリ ID の除外テストを追加。 |
| plugins/bc-uploader/tests/TestCase/Controller/Admin/UploaderFilesControllerTest.php | 存在しない画像の 404 テストを追加。 |
| plugins/bc-uploader/src/Service/UploaderFilesService.php | カテゴリ ID の数値検証を追加。 |
| plugins/bc-uploader/src/Controller/Admin/UploaderFilesController.php | 画像データが存在しない場合を 404 に変更。 |
| plugins/bc-uploader/src/Controller/Admin/UploaderCategoriesController.php | 編集対象 ID に int 型を指定。 |
| plugins/bc-search-index/tests/TestCase/Service/SearchIndexesServiceTest.php | 不正な検索 ID の処理をテスト。 |
| plugins/bc-search-index/src/Service/SearchIndexesService.php | サイト・コンテンツ関連 ID の検証を追加。 |
| plugins/bc-mail/tests/TestCase/Service/Admin/MailMessagesAdminServiceTest.php | CSV 文字コードの正常系・異常系を更新。 |
| plugins/bc-mail/src/Service/Admin/MailMessagesAdminService.php | 未対応の文字コードを UTF-8 に置換。 |
| plugins/bc-custom-content/tests/TestCase/Controller/Admin/CustomEntriesControllerTest.php | 不正なテーブル ID の例外テストを追加。 |
| plugins/bc-custom-content/src/Controller/Admin/CustomEntriesController.php | テーブル ID を検証し、不正値を 404 に変更。 |
| plugins/bc-blog/tests/TestCase/Service/BlogPostsServiceTest.php | 不正な記事絞り込み ID のテストを追加。 |
| plugins/bc-blog/tests/TestCase/Controller/BlogControllerTest.php | 不正な日付アーカイブの 404 テストを追加。 |
| plugins/bc-blog/src/Service/BlogPostsService.php | ユーザー・タグ・カテゴリ ID の検証を追加。 |
| plugins/bc-blog/src/Controller/BlogController.php | 解釈できない日付パラメーターを 404 に変更。 |
| plugins/bc-blog/src/Controller/Admin/BlogTagsController.php | 編集対象 ID に int 型を指定。 |
| plugins/bc-blog/src/Controller/Admin/BlogCategoriesController.php | 追加先ブログ ID を int 型に変更。 |
| plugins/baser-core/tests/TestCase/Service/UsersServiceTest.php | 不正なユーザーグループ ID のテストを追加。 |
| plugins/baser-core/tests/TestCase/Service/DblogsServiceTest.php | 不正なユーザー ID の除外テストを追加。 |
| plugins/baser-core/tests/TestCase/Service/ContentsServiceTest.php | 不正な作成者・フォルダー条件のテストを追加。 |
| plugins/baser-core/tests/TestCase/Middleware/BcAdminMiddlewareTest.php | 不正なサイト ID の既定値処理をテスト。 |
| plugins/baser-core/tests/TestCase/Controller/Admin/UsersControllerTest.php | 編集・代理ログインの不正 ID をテスト。 |
| plugins/baser-core/tests/TestCase/Controller/Admin/PluginsControllerTest.php | 未存在プラグインと PUT 以外の初期化をテスト。 |
| plugins/baser-core/tests/TestCase/Controller/Admin/PermissionsControllerTest.php | アクセスルール編集の不正 ID をテスト。 |
| plugins/baser-core/tests/TestCase/Controller/Admin/PermissionGroupsControllerTest.php | prefix 未指定時の表示テストを追加。 |
| plugins/baser-core/tests/TestCase/Controller/Admin/ContentsControllerTest.php | 削除時の不正 ID の 404 テストを追加。 |
| plugins/baser-core/src/Service/UsersService.php | ユーザーグループ ID の検証を追加。 |
| plugins/baser-core/src/Service/DblogsService.php | 最近の動きのユーザー ID を検証。 |
| plugins/baser-core/src/Service/ContentsService.php | 作成者・フォルダー ID の検証と存在確認を追加。 |
| plugins/baser-core/src/Middleware/BcAdminMiddleware.php | 不正なサイト ID を既定サイトに置換。 |
| plugins/baser-core/src/Controller/Admin/UsersController.php | 編集・代理ログインの ID に整数型を指定。 |
| plugins/baser-core/src/Controller/Admin/UserGroupsController.php | 編集対象 ID に int 型を指定。 |
| plugins/baser-core/src/Controller/Admin/SitesController.php | 編集対象 ID に int 型を指定。 |
| plugins/baser-core/src/Controller/Admin/PluginsController.php | インストール対象の存在確認と初期化時のリダイレクトを追加。 |
| plugins/baser-core/src/Controller/Admin/PermissionsController.php | 編集アクションの各 ID に整数型を指定。 |
| plugins/baser-core/src/Controller/Admin/PermissionGroupsController.php | prefix 未指定時の既定値を Admin に設定。 |
| plugins/baser-core/src/Controller/Admin/ContentsController.php | 削除対象 ID の検証を追加。 |
Review effort: Balanced
| } | ||
| // 数値で指定する条件に数字以外が渡されると型変換できず例外になるため、条件にしない | ||
| if (in_array($key, ['site_id', 's', 'content_id', 'c', 'content_filter_id', 'cf'], true) | ||
| && is_scalar($value) && !ctype_digit((string)$value)) { |
ユーザー一覧の user_group_id、ブログ記事一覧の user_id・blog_tag_id・ blog_category_id、サイト内検索の s・c・cf などに配列(?user_group_id[]=1 等)を 渡すと、除外処理を通らずに整数列の条件へ渡され 500 になっていたため、 数字以外と同様に条件にしないよう修正。コンテンツ一覧の author_id・folder_id にも 同じ判定を追加。 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…0-errors # Conflicts: # plugins/baser-core/tests/TestCase/Controller/Admin/PermissionsControllerTest.php # plugins/baser-core/tests/TestCase/Controller/Admin/UsersControllerTest.php # plugins/bc-blog/tests/TestCase/Service/BlogPostsServiceTest.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

概要
VAddy(脆弱性診断)の定期スキャンで、数字以外の ID や不正な値を指定したときに 500 エラーとなる箇所が見つかったため、404 または既定値での表示となるよう修正しました。脆弱性ではなく、入力値の扱いの不備です(#4649 の続き)。
変更内容
folder_id・author_id)、ユーザー一覧(user_group_id)、ブログ記事一覧(user_id・blog_tag_id・blog_category_id)、最近の動き(user_id)、アップロード一覧(uploader_category_id)、サイト内検索(s・c・cf)site_idは既定のサイトとして扱う/archives/date/2024/xx。従来は年別アーカイブを表示していた)prefixが無い場合はAdminとするテスト
abcがそのまま通る前提だったためSJIS-winに変更し、不正な値が UTF-8 になるケースを追加🤖 Generated with Claude Code