FPM/FastCGI: FCGI_HASH_FUNC reads var[3] for 3-character names (guarded only by var_len < 3)
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Aptitud para principiantes
- 72/100
Línea de trabajo
Lee la definición de FCGI_HASH_FUNC en main/fastcgi.h y la llamada de análisis de parámetros FastCGI en main/fastcgi.c, cerca de la línea 1019. Comprueba cómo gestiona la función hash los nombres de tres caracteres y luego revisa las pruebas FastCGI existentes para encontrar un lugar adecuado donde cubrir ese caso. La tarea estará terminada cuando el hash deje de leer más allá de un nombre de tres caracteres y pasen las pruebas pertinentes.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
main/fastcgi.h:
#define FCGI_HASH_FUNC(var, var_len) \
(UNEXPECTED(var_len < 3) ? (unsigned int)var_len : \
(((unsigned int)var[3]) << 2) + \
(((unsigned int)var[var_len-2]) << 4) + \
(((unsigned int)var[var_len-1]) << 2) + \
var_len)
The guard is var_len < 3, but the body reads var[3]. For a name of length exactly 3, the valid indices are 0..2, so var[3] is one byte past the name.
In FastCGI param parsing (main/fastcgi.c:1019) name and value are contiguous in the param buffer:
fcgi_hash_set(&req->env, FCGI_HASH_FUNC(p, name_len), (char*)p, name_len, (char*)p + name_len, val_len);
so for a 3-char name var[3] reads the first byte of the value (or the record terminator) — inside the allocation. A true 1-byte out-of-bounds read is only conceivable for a crafted record whose 3-char name sits exactly at the end of the content buffer with an empty value; even then the byte is only fed into a hash and never returned, and the whole surface is behind the FastCGI socket.
So this is a minor correctness nit / optional hardening, not a security issue. Confirmed by source on PHP-8.6 and PHP-8.3 (main/fastcgi.h).
Suggested fix
Guard the var[3] access — e.g. change the condition to var_len < 4 so that 3-char names take the (unsigned int)var_len fast path. This only changes internal hash values (recomputed each run) and removes the past-the-name read.
PHP Version
PHP-8.6 and PHP-8.3 branch heads (confirmed by source).
Operating System
Linux
- Lenguaje dominante
- C
- Estrellas
- 41.9k
- Forks
- 8.5k
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 117
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de php/php-src
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
FPM: NULL dereference in fpm_status_export_to_zval() when the scoreboard copy fails (PHP-8.3)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
php/php-src#26067 · 4 comentarios ·
Los mantenedores suelen responder en 1 día
-
FPM: fpm_request_end() releases the scoreboard writer lock without acquiring it (8.6 regression)Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
SessionInterfaceHandler is throwing a deprecation notice as a warning instead of a deprecationAbiertoBug Status: Verified
Dificultad 1/5 Menos de una hora Aptitud para principiantes 74/100
Los mantenedores suelen responder en 1 día
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start codePosiblemente ocupada @lazerg la tomó hace 5 días. AbiertoBug Status: Needs Triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día
Todos los issues de php/php-src
Issues similares
-
CF_CFDP_S_SendFileData computes the file checksum from the SB buffer after CFE_SB_TransmitBufferAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
-
needs triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
389ds/389-ds-base#8251 ·
Los mantenedores suelen responder en 1 día
-
bug data-types
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
ClickHouse/clickhouse-cpp#645 ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
ROCm/hrx-system#3628 ·
Los mantenedores suelen responder en 1 día