Bug #79723 [NEW]: sapi_cgi_read_post() ignores EOF

From: Date: Sun, 21 Jun 2020 18:58:52 +0000
Subject: Bug #79723 [NEW]: sapi_cgi_read_post() ignores EOF
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-227586@lists.php.net to get a copy of this message
From: sam dot revitch at protonmail dot ch Operating system: Linux PHP version: 7.4.7 Package: FPM related Bug Type: Bug Bug description:sapi_cgi_read_post() ignores EOF Description: ------------ When FPM receives records: FCGI_BEGIN_REQUEST, FCGI_PARAMS, including CONTENT_LENGTH=x one or more nonempty FCGI_STDIN, with a total data length of y < x, and FCGI_STDIN end-of-stream (empty data) And the script reads php://input to the end, the read will hang until the socket is closed. This is because sapi_cgi_read_post() expects CONTENT_LENGTH bytes, and does not appear to honor the FastCGI end-of-stream indicator if it receives fewer. This is an edge case. I stumbled upon it using Apache, mod_proxy_fcgi, and mod_security, where mod_security aborts a request based on part of the body. It's certainly a bug that Apache doesn't close the FastCGI socket or send an abort record. However, PHP shouldn't be hanging indefinitely after receiving an end-of-stream. -- Edit bug report at https://bugs.php.net/bug.php?id=79723&edit=1 -- Fix committed: https://bugs.php.net/fix.php?id=79723&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=79723&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=79723&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=79723&r=needscript Try newer version: https://bugs.php.net/fix.php?id=79723&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=79723&r=support Expected behavior: https://bugs.php.net/fix.php?id=79723&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=79723&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=79723&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=79723&r=globals PHP version support discontinued: https://bugs.php.net/fix.php?id=79723&r=phptooold Daylight Savings: https://bugs.php.net/fix.php?id=79723&r=dst IIS Stability: https://bugs.php.net/fix.php?id=79723&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=79723&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=79723&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=79723&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=79723&r=mysqlcfg

« previous php.bugs (#227586) next »