Add `max_object_properties` parameter for `json_decode()`
まだ誰も着手していません。
- 主要言語
- C
- スター
- 40.4k
- フォーク
- 8.2k
- 平均マージ
- 2日 13時間
- マージ済み PR(30日)
- 96
説明
Description
Currently, json_decode() is vulnerable to HashTable supercolliding, when integers are used as property names in assoc mode, or perhaps when strings with some known hashes are used. This can be trivially exploited to cause major performance issues in applications which accept JSON payloads from a client.
While this is obviously a tough issue to solve globally, I think allowing users of json_decode() to limit the max number of object properties would mostly eliminate the problem for JSON handling, since most use cases should know or be able to predict what the max reasonable size of an object should be. I think this should probably be fairly easy to implement.
A precedent for this does exist: max_input_vars was implemented to mitigate HashDoS for query parameters over a decade ago, so I don't think this is a crazy idea.
Disclaimer: I did already report a security issue for this and was told to create a feature request, so here it is.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
json_decode() のエントリーポイントから始め、issue で言及されている max_input_vars の先例を確認してください。max_object_properties パラメーターでデコードされたオブジェクトをどのように制限するかを、assoc モードとの相互作用も含めて定義し、サイズが大きすぎるオブジェクトが意図したとおりに拒否または制限されることを示すテストカバレッジを追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- c, php
- 領域
- security
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 30/100