Add `max_object_properties` parameter for `json_decode()`
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 40.4k
- Forks
- 8.1k
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 96
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the json_decode() entry point and review the max_input_vars precedent mentioned in the issue. Define how a max_object_properties parameter should limit decoded objects, including its interaction with assoc mode, then add coverage showing that oversized objects are rejected or limited as intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c, php
- Domain
- security
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100