Hi, Here is a tested bookworm debdiff for CVE-2023-4540, from upstream commit ddab2835c583d45dec62680ca8d3cbde55e0bae6. The tracker marks bookworm no-dsa (Minor issue).
Both builds passed. The patched H1 stream spec passed 17 tests, including the upstream premature EOF regression. Lintian output was empty on both builds. Happy to adjust anything if the LTS team wants it done differently Dickson Prepared with AI assistance (OpenAI Codex) and reviewed by me before sending.
diff -Nru '--exclude=.pc' '--exclude=.git' '--exclude=build' base/debian/changelog patched/debian/changelog --- base/debian/changelog 2021-02-15 11:00:25.000000000 +0000 +++ patched/debian/changelog 2026-11-26 06:03:10.596982379 +0000 @@ -1,3 +1,9 @@ +lua-http (0.4-1+deb12u1) bookworm; urgency=medium + + * Backport upstream fix for CVE-2023-4540 (stop draining on early EOF). + + -- Dickson Wu <[email protected]> Thu, 26 Nov 2026 01:20:00 +0000 + lua-http (0.4-1) unstable; urgency=low * New upstream version 0.4 diff -Nru '--exclude=.pc' '--exclude=.git' '--exclude=build' base/debian/patches/CVE-2023-4540.patch patched/debian/patches/CVE-2023-4540.patch --- base/debian/patches/CVE-2023-4540.patch 1970-01-01 00:00:00.000000000 +0000 +++ patched/debian/patches/CVE-2023-4540.patch 2026-11-26 06:03:10.591982313 +0000 @@ -0,0 +1,57 @@ +Description: Return EPIPE when a content-length stream closes early +Origin: upstream, https://github.com/daurnimator/lua-http/commit/ddab2835c583d45dec62680ca8d3cbde55e0bae6 +Bug-Debian: https://bugs.debian.org/1051511 +Applied-Upstream: ddab2835c583d45dec62680ca8d3cbde55e0bae6 +Last-Update: 2026-11-26 +--- +diff --git a/http/h1_stream.lua b/http/h1_stream.lua +index b2469a14..b0ca8219 100644 +--- a/http/h1_stream.lua ++++ b/http/h1_stream.lua +@@ -861,6 +861,8 @@ function stream_methods:read_next_chunk(timeout) + if chunk ~= nil then + self.body_read_left = length_n - #chunk + end_stream = (self.body_read_left == 0) ++ elseif err == nil then ++ return nil, ce.strerror(ce.EPIPE), ce.EPIPE + end + elseif length_n == 0 then + chunk = "" +diff --git a/spec/h1_stream_spec.lua b/spec/h1_stream_spec.lua +index f9cfea94..1303f946 100644 +--- a/spec/h1_stream_spec.lua ++++ b/spec/h1_stream_spec.lua +@@ -295,6 +295,33 @@ describe("http1 stream", function() + server:close() + client:close() + end) ++ it("Doesn't hang when a content-length delimited stream is closed", function() ++ local server, client = new_pair(1.1) ++ local cq = cqueues.new() ++ cq:wrap(function() ++ local stream = client:new_stream() ++ local headers = new_headers() ++ headers:append(":method", "GET") ++ headers:append(":scheme", "http") ++ headers:append(":authority", "myauthority") ++ headers:append(":path", "/a") ++ assert(stream:write_headers(headers, true)) ++ end) ++ cq:wrap(function() ++ local stream = server:get_next_incoming_stream() ++ assert(stream:get_headers()) ++ local res_headers = new_headers() ++ res_headers:append(":status", "200") ++ res_headers:append("content-length", "100") ++ assert(stream:write_headers(res_headers, false)) ++ assert(stream:write_chunk("foo", false)) ++ assert(stream:shutdown()) ++ end) ++ assert_loop(cq, TEST_TIMEOUT) ++ assert.truthy(cq:empty()) ++ server:close() ++ client:close() ++ end) + it("allows pipelining", function() + local server, client = new_pair(1.1) + local cq = cqueues.new() diff -Nru '--exclude=.pc' '--exclude=.git' '--exclude=build' base/debian/patches/series patched/debian/patches/series --- base/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 +++ patched/debian/patches/series 2026-11-26 06:03:10.592982326 +0000 @@ -0,0 +1 @@ +CVE-2023-4540.patch diff -Nru '--exclude=.pc' '--exclude=.git' '--exclude=build' base/http/h1_stream.lua patched/http/h1_stream.lua --- base/http/h1_stream.lua 2021-02-05 15:39:18.000000000 +0000 +++ patched/http/h1_stream.lua 2026-11-26 06:03:10.609982551 +0000 @@ -861,6 +861,8 @@ if chunk ~= nil then self.body_read_left = length_n - #chunk end_stream = (self.body_read_left == 0) + elseif err == nil then + return nil, ce.strerror(ce.EPIPE), ce.EPIPE end elseif length_n == 0 then chunk = "" diff -Nru '--exclude=.pc' '--exclude=.git' '--exclude=build' base/spec/h1_stream_spec.lua patched/spec/h1_stream_spec.lua --- base/spec/h1_stream_spec.lua 2021-02-05 15:39:18.000000000 +0000 +++ patched/spec/h1_stream_spec.lua 2026-11-26 06:03:10.609982551 +0000 @@ -295,6 +295,33 @@ server:close() client:close() end) + it("Doesn't hang when a content-length delimited stream is closed", function() + local server, client = new_pair(1.1) + local cq = cqueues.new() + cq:wrap(function() + local stream = client:new_stream() + local headers = new_headers() + headers:append(":method", "GET") + headers:append(":scheme", "http") + headers:append(":authority", "myauthority") + headers:append(":path", "/a") + assert(stream:write_headers(headers, true)) + end) + cq:wrap(function() + local stream = server:get_next_incoming_stream() + assert(stream:get_headers()) + local res_headers = new_headers() + res_headers:append(":status", "200") + res_headers:append("content-length", "100") + assert(stream:write_headers(res_headers, false)) + assert(stream:write_chunk("foo", false)) + assert(stream:shutdown()) + end) + assert_loop(cq, TEST_TIMEOUT) + assert.truthy(cq:empty()) + server:close() + client:close() + end) it("allows pipelining", function() local server, client = new_pair(1.1) local cq = cqueues.new()
