Repository navigation
fix(rocky9): prevent /health.php from clearing PHP-FPM auto_prepend_file - #787
Conversation
|
Faz sentido e corrige o problema real. Aprovação com uma ressalva de testes. A causa descrita é consistente com um bug ainda aberto do PHP-FPM: valores recebidos por PHP_ADMIN_VALUE podem permanecer no worker e afetar requisições posteriores. Isso está documentado no php-src #24689; o uso de PHP_ADMIN_VALUE via FastCGI também consta na documentação oficial do PHP-FPM. Depois de /health.php, mesmo PID: Com a implementação do PR: Portanto:
Recomendo acrescentar um teste comportamental que confirme:
Resumo de segurança: 0 críticas, 0 altas, 0 médias, 1 baixa — cobertura de regressão insuficiente. |
6f676d5
into
scieloorg:codex/php8-rocky9-migration-pushable
Summary
Fixes a PHP-FPM worker state poisoning bug observed while validating
infrascielo/metodologia:v7.14-qaon SciELO Paraguay staging (PHP 8.5.12):docker/rocky9/httpd-scielo.confsets:proxy:unix:/run/php-fpm/www.sock|fcgi://localhost/,PHP_ADMIN_VALUEoverwritesauto_prepend_filefor the lifetime of that PHP-FPM worker process across subsequent requests (pm.max_requests = 250). After Docker's periodicHEALTHCHECKhits/health.phpa few times (pm.max_children = 8), all PHP-FPM workers stop loadinghtdocs/compat.php, causing endpoints that rely oncompat.php(sendMail.php,articleRequestGraphicPage.php, and legacycompat.phppolyfills) to fail withHTTP 500(Call to undefined function scielo_utf8_encode()).Changes
docker/rocky9/compat-prepend.php+docker/rocky9/php-scielo.ini+docker/rocky9/Dockerfile:Install
/opt/scielo-health/compat-prepend.php(copied andphp -lchecked during image build) and setauto_prepend_file = /opt/scielo-health/compat-prepend.php. It loads/var/www/html/htdocs/compat.phponly when it exists andSCRIPT_FILENAME !== '/opt/scielo-health/health.php', preserving/health.phpindependence for older mounted trees without mutating worker INI state.docker/rocky9/httpd-scielo.conf:Remove
<Location "/health.php"> SetEnv PHP_ADMIN_VALUE "auto_prepend_file=" </Location>.htdocs/applications/scielo-org/users/functions.php:Add a defensive
SCIELO_COMPAT_LOADEDrequire_onceforhtdocs/compat.php(matching the existing pattern inhtdocs/oai/scielo-oai.phpandhtdocs/classMySQLDatabase.php) for standalone/non-container deployments.tests/security_regression.php:Add regression checks verifying
httpd-scielo.confdoes not setauto_prepend_file=andphp-scielo.inireferences/opt/scielo-health/compat-prepend.php.Verification
php -l /opt/scielo-health/compat-prepend.php->No syntax errors detected/opt/httpd/bin/httpd -d /etc/httpd -f conf/httpd.conf -t->Syntax OKphp /var/www/html/tests/security_regression.phpinsidev7.14-qastaging container ->Security regression tests passed/health.php12 times (HTTP 200), then verifiedsendMail.phpandarticleRequestGraphicPage.phpacross 8 consecutive requests (HTTP 200on all 8/8 vsHTTP 500before the fix).