[FPM] Bound cumulative FCGI_PARAMS allocation per request
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend, networking, security
Direzione di ricerca
Start in main/fastcgi.c, especially fcgi_read_request() at lines 1110-1132 and fcgi_get_params()/fcgi_hash_set() at lines 295-350. Reproduce with an isolated TCP FPM listener using the described stream of valid parameters without the terminating empty record. Done means an exceeded cumulative parameter bound terminates the request rather than allowing unbounded allocation during parsing.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
The FastCGI request reader has no cumulative limit for FCGI_PARAMS data.
fcgi_read_request() accepts successive non-empty FCGI_PARAMS records until the terminating empty record (main/fastcgi.c:1110-1132). Each record is bounded by FCGI_MAX_LENGTH, but there is no per-request total byte/record budget. For each parameter, fcgi_get_params() calls fcgi_hash_set(), which stores names and values in additional raw-malloc segments/bucket blocks (main/fastcgi.c:295-350). The accumulated hash is cleaned only when the next request starts, not while the current request is still receiving parameters.
A peer able to connect directly to a TCP FPM listener can send many valid, distinct parameter pairs and keep the request open, growing a worker's memory before the PHP script is dispatched. These allocations are not governed by PHP's memory_limit. The default pool template binds to 127.0.0.1:9000; this report therefore applies only when an untrusted peer can reach the FastCGI listener, not to the default loopback-only deployment behind a properly configured web server.
Validation
Reproduced against a locally built FPM from php-src commit 63b0af4a5c400d93510dca7aa998769609fdc26c. With the pool's memory_limit set to 1M, I sent a BEGIN_REQUEST followed by 100,000 distinct, valid name/value pairs in 31 FCGI_PARAMS records (1,800,000 parameter bytes), and withheld the terminating empty FCGI_PARAMS record. The worker remained in request parsing and its RSS grew from about 6,412 KiB to 9,844 KiB. Current master 68292bc476c709ff7ac0632d963af0e379dc4a53 has byte-identical main/fastcgi.c (blob a393283fcb0b8a156796fc7c21f07d2052737f91).
Expected behavior
Enforce a cumulative per-request bound for FastCGI environment parameters (total bytes and/or count) and terminate the request when exceeded. A per-record maximum alone does not bound total allocation.
Reproduction outline
Against an isolated FPM instance with a TCP listener, send a FastCGI BEGIN_REQUEST, then a stream of FCGI_PARAMS records containing valid unique name/value pairs without sending the terminating empty FCGI_PARAMS record. Observe worker RSS while the request remains in parsing.
Related issue
#16042 reports an FPM behavior when environment parameters are split across FastCGI records. This report concerns the separate lack of a cumulative allocation bound for complete, valid parameters.
- Lingua principale
- C
- Stelle
- 40.7k
- Fork
- 8.3k
- Merge medio
- 2g 17h
- PR unite (30g)
- 159
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi 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.
Altre issue di php/php-src
-
ext/odbc, ext/pdo_odbc: php_odbc_connstr_is_quoted() treats a value with no closing brace as "already quoted," skipping UID/PWD escapingForse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Bug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
zend_set_local_var() overwrites existing compiled variable (CV) zval without calling zval_ptr_dtor()Forse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaBug Status: Needs Triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
Case-insensitive substr_compare, ksort, krsort are still locale-dependentForse già presa @lazerg l’ha presa 5 giorni fa. ApertaBug Extension: standard Status: Verified
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
php/php-src#24552 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
bug intrinsic medium priority rt_lib
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
[CLI] Clarify distinction between 'capture camera' and 'capture screen' in help text and outputAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
espressif/esp-vision#18 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
sumatrapdfreader/sumatrapdf#6417 · 3 commenti ·
-
[BUG] Cython cache evicts most recent instead of oldest entry on cleanupForse già presa @scoder l’ha presa oggi. ApertaBuild System defect
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 61/100
HexaCluster/credcheck#94 ·