Skip to content

unserialize() に allowed_classes オプションを追加#6622

Merged
dotani1111 merged 2 commits intoEC-CUBE:4.3from
nobuhiko:fix/unserialize-allowed-classes
Mar 11, 2026
Merged

unserialize() に allowed_classes オプションを追加#6622
dotani1111 merged 2 commits intoEC-CUBE:4.3from
nobuhiko:fix/unserialize-allowed-classes

Conversation

@nobuhiko
Copy link
Contributor

@nobuhiko nobuhiko commented Feb 12, 2026

Summary

  • セキュリティ診断で指摘された unserialize()allowed_classes 未指定の問題を修正
  • 非会員フローでセッションに保存される CustomerAddress のデシリアライズ時に、許可するクラスを明示的に指定
  • オブジェクトインジェクション攻撃のリスクを軽減

修正内容

  • ShippingMultipleController.php: 非会員のお届け先追加時の unserialize()allowed_classes を追加
  • ShippingMultipleItemType.php: 非会員の配送先リスト構築時の unserialize()allowed_classes を追加
  • Generator.php(テストフィクスチャ): 同様の修正を適用

allowed_classes に含めるクラス

  • CustomerAddress — メインのエンティティ
  • Customer — 顧客エンティティ
  • Pref — 都道府県マスタ
  • Country — 国マスタ

fix #6620

Test plan

  • bin/phpunit tests/Eccube/Tests/Web/ShoppingControllerWithMultipleNonmemberTest.php で非会員複数配送テスト実行
  • bin/phpunit tests/Eccube/Tests/Web/ShoppingControllerWithNonmemberTest.php で非会員テスト実行

🤖 Generated with Claude Code

Summary by CodeRabbit

リリースノート

  • バグ修正
    • 複数配送時の非会員アドレス処理において、セッションデータからのオブジェクト復元時のセキュリティを強化しました。これにより、意図しないクラスのインスタンス化を防止し、より安全なデータ処理を実現します。

nobuhiko and others added 2 commits January 23, 2026 10:53
セキュリティ診断で指摘された、unserialize() の allowed_classes 未指定の
問題を修正。非会員フローでセッションに保存される CustomerAddress の
デシリアライズ時に、許可するクラスを明示的に指定することで、
オブジェクトインジェクション攻撃のリスクを軽減する。

fix EC-CUBE#6620

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@coderabbitai
Copy link

coderabbitai bot commented Feb 12, 2026

📝 Walkthrough

Walkthrough

セッションデータから非会員顧客住所を復元する際の unserialize() 呼び出しに、allowed_classes オプションを追加し、CustomerAddressCustomerPrefCountry クラスのインスタンス化のみを許可するセキュリティ強化が実装されました。

Changes

Cohort / File(s) Summary
unserialize() セキュリティ強化
src/Eccube/Controller/ShippingMultipleController.php, src/Eccube/Form/Type/ShippingMultipleItemType.php, tests/Eccube/Tests/Fixture/Generator.php
非会員顧客住所のセッション復元時に、unserialize()allowed_classes オプションで許可するクラスを明示的に指定。オブジェクト注入脆弱性の防止と PHP 7.0 以降での安全な逆シリアル化を実現。

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 セッションの扉、鍵かけました
許可されし住所だけが、戻ります
セキュリティの旅、一歩また一歩
悪い子は入れない、我が番地へ
安全なお届け、ほっぺたで祝う🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは、unserialize()にallowed_classesオプションを追加するという変更の主要な目的を明確に反映しており、簡潔で説明的です。
Linked Issues check ✅ Passed すべての修正ファイル(ShippingMultipleController.php、ShippingMultipleItemType.php、Generator.php)が、issue #6620で指定された箇所にallowed_classesオプションを正しく追加しており、要件を完全に満たしています。
Out of Scope Changes check ✅ Passed すべての変更は非会員フローのセッション処理におけるunserialize()呼び出しへのallowed_classes追加に限定されており、issue #6620のスコープ内です
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Feb 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.84%. Comparing base (fba6352) to head (40d92e8).
⚠️ Report is 188 commits behind head on 4.3.

Additional details and impacted files
@@             Coverage Diff              @@
##                4.3    #6622      +/-   ##
============================================
- Coverage     82.70%   78.84%   -3.87%     
- Complexity        0     6631    +6631     
============================================
  Files           480      475       -5     
  Lines         26507    26539      +32     
============================================
- Hits          21923    20925     -998     
- Misses         4584     5614    +1030     
Flag Coverage Δ
E2E ?
Unit 78.84% <100.00%> (-3.87%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dotani1111 dotani1111 added the improvement 機能改善 label Feb 25, 2026
@dotani1111 dotani1111 added this to the 4.4.0 milestone Feb 25, 2026
@dotani1111
Copy link
Contributor

dotani1111 commented Feb 25, 2026

@nobuhiko
PRありがとうございます。
確認を進めます。

@dotani1111 dotani1111 self-assigned this Mar 5, 2026
@dotani1111 dotani1111 merged commit c8659b2 into EC-CUBE:4.3 Mar 11, 2026
128 of 129 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

unserialize() に allowed_classes オプションが未指定

3 participants