Add `max_object_properties` parameter for `json_decode()`
Nessuno ha ancora preso questa issue.
- Lingua principale
- C
- Stelle
- 40.4k
- Fork
- 8.1k
- Merge medio
- 2g 13h
- PR unite (30g)
- 96
Descrizione
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.
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Parti dal punto di ingresso json_decode() e verifica il precedente di max_input_vars menzionato nell’issue. Definisci come un parametro max_object_properties debba limitare gli oggetti decodificati, inclusa la sua interazione con la modalità assoc, quindi aggiungi una copertura che dimostri che gli oggetti troppo grandi vengono rifiutati o limitati come previsto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c, php
- Ambito
- security
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 30/100