Sec: Update hackney to version 4.9.1
Hackney 4.9 enforces max_body while it reads and returns
{:error, {:closed, partial}} for a truncated body; the hackney
regression tests now pin that. The certifi override goes, as
hackney itself now asks for certifi ~> 2.18.0.
This commit is contained in:
parent
90479b3415
commit
eabdde8a20
5 changed files with 20 additions and 24 deletions
|
|
@ -14,7 +14,8 @@
|
|||
#
|
||||
# Pleroma cannot work around this: since 4.0 Hackney ignores `with_body` and
|
||||
# always returns a fully read binary, so a synchronous request never yields a
|
||||
# handle to close, and a truncated read still reports `{:ok, body}`.
|
||||
# handle to close. Up to 4.8 a truncated read also reported `{:ok, body}`;
|
||||
# since 4.9 it is `{:error, {:closed, partial_body}}`.
|
||||
#
|
||||
# Media proxy warming hits this whenever an attachment fetch is cut short and
|
||||
# the outbound proxy is used as a CONNECT tunnel, since tunnels are never
|
||||
|
|
@ -50,11 +51,9 @@ defmodule Pleroma.HTTP.HackneyConnLeakTest do
|
|||
# pool: false takes hackney's connect_direct/4 path, the same unpooled shape
|
||||
# a CONNECT tunnel gets. A pooled connection is reaped by the pool's own
|
||||
# grace timer and would not show the leak.
|
||||
assert {:ok, %Tesla.Env{status: 200, body: body}} =
|
||||
request(server, pool: false)
|
||||
assert {:error, {:closed, body}} = request(server, pool: false)
|
||||
|
||||
# The short read still reports success, which is why nothing downstream
|
||||
# knows to clean up.
|
||||
# The short read hands back what did arrive.
|
||||
assert byte_size(body) == @sent_bytes
|
||||
|
||||
leaked = wait_for_cleanup(before)
|
||||
|
|
@ -70,7 +69,7 @@ defmodule Pleroma.HTTP.HackneyConnLeakTest do
|
|||
test "a pooled request with a truncated body does not leak either", %{server: server} do
|
||||
before = conn_pids()
|
||||
|
||||
assert {:ok, %Tesla.Env{status: 200}} = request(server, pool: :media)
|
||||
assert {:error, {:closed, _}} = request(server, pool: :media)
|
||||
|
||||
assert wait_for_cleanup(before) == []
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,8 +4,9 @@
|
|||
|
||||
# Hackney 4 ignores `with_body` and always returns a fully read binary, so
|
||||
# `Tesla.Adapter.Hackney` never reaches the clause that honours `:max_body`.
|
||||
# The limit is enforced by Pleroma.Tesla.Middleware.MaxBody instead; these
|
||||
# exercise it against the real adapter.
|
||||
# Hackney 4.9 enforces `max_body` itself while reading (CVE-2026-97200);
|
||||
# Pleroma.Tesla.Middleware.MaxBody stays as the check for every adapter. These
|
||||
# exercise both against the real adapter.
|
||||
defmodule Pleroma.HTTP.HackneyMaxBodyRegressionTest do
|
||||
use ExUnit.Case, async: false
|
||||
|
||||
|
|
@ -62,12 +63,11 @@ defmodule Pleroma.HTTP.HackneyMaxBodyRegressionTest do
|
|||
assert byte_size(body) == @body_bytes
|
||||
end
|
||||
|
||||
# Pins why the middleware is needed. Tesla.Adapter.Hackney only honours
|
||||
# :max_body on the branch where hackney hands back a ref, which 4.x never
|
||||
# does for a synchronous request. Should this ever start failing, hackney or
|
||||
# Tesla have regained streaming and the middleware can go.
|
||||
test "the bare adapter does not enforce max_body", %{server: server} do
|
||||
url = "#{server.base_url}/big"
|
||||
# Hackney 4.0 to 4.8 read the whole body whatever `max_body` said; 4.9
|
||||
# stops reading once the body goes over it (CVE-2026-97200). Should this
|
||||
# start failing, the hackney pin has gone back to a version without the fix.
|
||||
test "the bare adapter enforces max_body", %{server: server} do
|
||||
url = "#{server.base_url}/chunked"
|
||||
|
||||
adapter_opts =
|
||||
HackneyAdapterHelper.options(
|
||||
|
|
@ -77,10 +77,8 @@ defmodule Pleroma.HTTP.HackneyMaxBodyRegressionTest do
|
|||
|
||||
client = Tesla.client([], Tesla.Adapter.Hackney)
|
||||
|
||||
assert {:ok, %Tesla.Env{status: 200, body: body}} =
|
||||
assert {:error, :body_too_large} =
|
||||
Tesla.request(client, method: :get, url: url, opts: [adapter: adapter_opts])
|
||||
|
||||
assert byte_size(body) == @body_bytes
|
||||
end
|
||||
|
||||
defp start_server do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue