You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This commit was created on GitHub.com and signed with GitHub’s verified signature.
Behavior changes: read before upgrading
An mruby body filter no longer runs a second time on the empty buffer at the end of a proxied response
Before: on a response from an upstream (proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass or memcached_pass), after an earlier phase handler left Nginx.rputs or Nginx.echo output in the module context and then declined, an mruby_output_body_filter(_code) ran a second time on the empty last buffer that the upstream sends after the body. A body filter whose output on an empty body is non-empty, such as one that prepends to or appends to f.body, produced bytes on that second run, and they were sent after the response, past its Content-Length.
Now: the body filter passes that trailing empty buffer on without running its code again, so no bytes are sent after the framed response.
Why it changed:
The defect: the bytes that a body filter whose output on an empty body is non-empty produced on the second run and that were sent past the response's Content-Length. On a connection that is kept alive, the client reads those bytes as the start of the next response on that connection; GHSA-5qjv-293c-64f8 has the details.
Why the old behavior could not be kept: the second run had no body to transform, so any bytes it produced could only follow a response that was already framed and sent.
What the documentation promised: docs/class_and_method/ did not describe the body filter running a second time, and docs/directives/ did not describe output after the response.
Affected: a location with mruby_output_body_filter(_code) whose output on an empty body is non-empty, served from an upstream whose Content-Length is known, with an earlier handler that leaves Nginx.rputs or Nginx.echo output and then returns a negative code the request declines past (in practice Nginx::DECLINED). A body filter that leaves an empty body empty, such as f.body = f.body.upcase, a static file, and a response sent chunked are unchanged.
What to do: nothing; rebuild the module with this release. A body filter that was guarded against an empty body (for example with unless f.body.empty?) can keep the guard or drop it.