public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/erlang] f43: Backported fixes from the OTP 27.3.4.20 security release
@ 2026-11-26 16:07 Peter Lemenkov
  0 siblings, 0 replies; only message in thread
From: Peter Lemenkov @ 2026-11-26 16:07 UTC (permalink / raw)
  To: git-commits

            A new commit has been pushed.

            Repo   : rpms/erlang
            Branch : f43
            Commit : 77a1e6038ce8dcbb80d6b31e2feb7e55a7ae293b
            Author : Peter Lemenkov <lemenkov@gmail.com>
            Date   : 2026-11-26T16:20:44+01:00
            Stats  : +761/-4 in 9 file(s)
            URL    : https://src.fedoraproject.org/rpms/erlang/c/77a1e6038ce8dcbb80d6b31e2feb7e55a7ae293b?branch=f43

            Log:
            Backported fixes from the OTP 27.3.4.20 security release

- CVE-2026-116225: bound sub-identifier size in the SNMP BER OID decoder
- CVE-2026-116382: stop ESI header names from creating atoms (inets)
- CVE-2026-116295: replace CR, LF and NUL with SP in serialized headers (inets)
- CVE-2026-119443: protect against fetching an external DTD by default (xmerl)
- CVE-2026-116293: fix binary_to_term for a reference with zero id words (erts)
- CVE-2026-120961: fix out-of-bounds access by dec_term FLOAT_EXT (erts)
- CVE-2026-117642: remove all recursive calls to dec_term (erts)

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

---
diff --git a/erlang.spec b/erlang.spec
index 87bb97e..b7a5786 100644
--- a/erlang.spec
+++ b/erlang.spec
@@ -70,7 +70,7 @@
 
 Name:		erlang
 Version:	26.2.5.21
-Release:	12%{?dist}
+Release:	13%{?dist}
 Summary:	General-purpose programming language and runtime environment
 
 License:	Apache-2.0
@@ -129,6 +129,13 @@ Patch27: otp-0027-inets-stdlib-eldap-Bound-integer-parsing-to-mitigate.patch
 Patch28: otp-0028-snmp-Bound-integer-parsing-in-the-BER-decoder.patch
 Patch29: otp-0029-ssl-Check-SNI-in-TLS-1.2-session-reuse.patch
 Patch30: otp-0030-ssl-Make-anonymous-handling-stricter.patch
+Patch31: otp-0031-snmp-Bound-sub-identifier-size-in-the-BER-OID-decode.patch
+Patch32: otp-0032-inets-stop-ESI-header-names-from-creating-atoms.patch
+Patch33: otp-0033-inets-replace-CR-LF-and-NUL-with-SP-in-serialized-he.patch
+Patch34: otp-0034-xmerl-Add-option-to-protect-against-fetching-DTD.patch
+Patch35: otp-0035-erts-Fix-binary_to_term-for-reference-with-zero-id-w.patch
+Patch36: otp-0036-erts-Fix-out-of-bounds-access-by-dec_term-FLOAT_EXT.patch
+Patch37: otp-0037-erts-Remove-all-recursive-calls-to-dec_term.patch
 # end of autogenerated patch tag list
 
 BuildRequires:	gcc
@@ -1977,6 +1984,15 @@ ERL_TOP=${ERL_TOP} make TARGET=${TARGET} release_tests
 
 
 %changelog
+* Thu Nov 26 2026 Peter Lemenkov <lemenkov@gmail.com> - 26.2.5.21-13
+- CVE-2026-116225: bound sub-identifier size in the SNMP BER OID decoder
+- CVE-2026-116382: stop ESI header names from creating atoms (inets)
+- CVE-2026-116295: replace CR, LF and NUL with SP in serialized headers (inets)
+- CVE-2026-119443: protect against fetching an external DTD by default (xmerl)
+- CVE-2026-116293: fix binary_to_term for a reference with zero id words (erts)
+- CVE-2026-120961: fix out-of-bounds access by dec_term FLOAT_EXT (erts)
+- CVE-2026-117642: remove all recursive calls to dec_term (erts)
+
 * Wed Nov 25 2026 Peter Lemenkov <lemenkov@gmail.com> - 26.2.5.21-12
 - CVE-2026-124286: reject anonymous server signature on TLS 1.2/DTLS client
 

diff --git a/otp-0030-ssl-Make-anonymous-handling-stricter.patch b/otp-0030-ssl-Make-anonymous-handling-stricter.patch
index 6dc9fa3..cb9fd33 100644
--- a/otp-0030-ssl-Make-anonymous-handling-stricter.patch
+++ b/otp-0030-ssl-Make-anonymous-handling-stricter.patch
@@ -10,9 +10,6 @@ Fixes CVE-2026-124286.
 
 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
 Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
----
- lib/ssl/src/ssl_handshake.erl | 7 +------
- 1 file changed, 1 insertion(+), 6 deletions(-)
 
 diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl
 index 59611e50c4..381a3a5e3e 100644

diff --git a/otp-0031-snmp-Bound-sub-identifier-size-in-the-BER-OID-decode.patch b/otp-0031-snmp-Bound-sub-identifier-size-in-the-BER-OID-decode.patch
new file mode 100644
index 0000000..566b2da
--- /dev/null
+++ b/otp-0031-snmp-Bound-sub-identifier-size-in-the-BER-OID-decode.patch
@@ -0,0 +1,114 @@
+From: Konrad Pietrzak <konrad@erlang.org>
+Date: Wed, 30 Sep 2026 15:08:00 +0200
+Subject: [PATCH] snmp: Bound sub-identifier size in the BER OID decoder
+
+dec_oid_element/3 accumulated Num*128 + Dig over as many continuation
+octets as the sender supplied. Nothing terminated the loop but an octet
+with the 8th bit cleared, so one sub-identifier could span an entire
+datagram. Past roughly 60 bits the accumulator is a bignum and every
+multiplication reallocates and copies it, making the decode quadratic in
+the length of the sub-identifier: 231 ms for 64 kB of octets and 13.5 s
+for 500 kB, measured on an idle machine.
+
+The input is reachable before authentication. Varbind OIDs are decoded by
+snmpa_mpd:v3_proc via dec_scoped_pdu/1, which for an unauthenticated USM
+stage-1 discovery message runs with no user and no key, and for v1 and
+v2c on any inbound packet. Decoding happens inline in the single
+snmpa_net_if process, which does not re-arm the socket until it returns,
+so saturating that one process stalls every SNMP packet the node
+receives.
+
+Apply the two bounds RFC 2578 #3.5 states: at most 128 sub-identifiers
+per value, and a maximum sub-identifier value of 2^32-1. The value needs
+ceil(32/7) = 5 base-128 octets, so cap the octet count at five as well.
+The octet cap is what removes the quadratic term, since a five octet
+accumulator stays a fixnum. Five octets carry 35 bits, though, so the
+octet cap alone would admit values between 2^32 and 2^35-1; the value
+check closes that gap.
+
+The octet cap has to be tested before the terminating clause. The last
+octet of an over-long sub-identifier has its 8th bit cleared, so a guard
+placed after that clause never sees it and accepts six octet
+sub-identifiers while rejecting longer ones. The check also stops at the
+point of detection instead of walking to the end of the sub-identifier,
+which is what keeps the rejection cost independent of the input size, so
+the reported octet count is the limit plus one rather than the true
+length.
+
+The sub-identifier count is checked once in dec_oid_notag/1 rather than
+in the fold, because calling length/1 on the accumulator per iteration
+would reintroduce the quadratic behaviour it is meant to remove.
+
+Related: GHSA-qghx-23m5-r55m
+
+Fixes CVE-2026-116225.
+
+(cherry picked from commit a1bfce6a034b5cbb17f85b3eea2f601c7a691805)
+
+[Backport to OTP 26: source change applied as-is; the snmp_pdus_SUITE.erl
+test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/snmp/src/misc/snmp_pdus.erl b/lib/snmp/src/misc/snmp_pdus.erl
+index 2d12e1c31b..be4e0a1c75 100644
+--- a/lib/snmp/src/misc/snmp_pdus.erl
++++ b/lib/snmp/src/misc/snmp_pdus.erl
+@@ -36,6 +36,14 @@
+ -define(UINT64_MAX_OCTETS,  9).  %% Counter64
+ -define(VERSION_MAX_OCTETS, 10). %% msgVersion -- deliberately generous
+ 
++%% RFC 2578 #3.5: an OBJECT IDENTIFIER value has at most 128
++%% sub-identifiers and each sub-identifier has a maximum value of 2^32-1,
++%% which needs ceil(32/7) = 5 base-128 octets. Five octets carry 35 bits,
++%% so the octet count alone does not enforce the value constraint.
++-define(OID_SUBID_MAX_OCTETS, 5).
++-define(OID_SUBID_MAX_VALUE,  16#FFFFFFFF).
++-define(OID_MAX_SUBIDS,       128).
++
+ %% See RFC1155, RFC1157, RFC1901, RFC1902, RFC1905, RFC2272
+ 
+ 
+@@ -440,7 +448,13 @@ dec_oid_tag([6 | Bytes]) ->
+ dec_oid_notag(Bytes) ->
+     {Size, [H | Tail]} = dec_len(Bytes),
+     {Oid, Rest} = dec_oid_elements(Tail, Size - 1, []),
+-    {[H div 40, H rem 40 | Oid], Rest}.
++    %% The two leading arcs are both encoded in H, hence the - 2.
++    case length(Oid) of
++        N when N =< ?OID_MAX_SUBIDS - 2 ->
++            {[H div 40, H rem 40 | Oid], Rest};
++        N ->
++            exit({error, {bad_oid_length, {N + 2, ?OID_MAX_SUBIDS}}})
++    end.
+ 
+ dec_oid_elements(L, 0, Acc) ->
+     {lists:reverse(Acc), L};
+@@ -450,8 +464,25 @@ dec_oid_elements([Dig|Tail], Size, Acc) ->
+     {Num, Neaten, Tl} = dec_oid_element(Tail,1,Dig band 127),
+     dec_oid_elements(Tl, Size - Neaten, [Num|Acc]).
+ 
++%% The octet cap must be tested before the terminating clause below: the
++%% last octet of an over-long sub-identifier has its 8th bit cleared and
++%% would otherwise be accepted. Stopping here rather than walking to the end
++%% of the sub-identifier is what keeps the cost independent of the input
++%% size, so the reported count is the limit plus one, not the true octet
++%% count.
++dec_oid_element(_Bytes, Neaten, _Num) when Neaten >= ?OID_SUBID_MAX_OCTETS ->
++    exit({error, {bad_oid_subidentifier,
++                  {Neaten + 1, ?OID_SUBID_MAX_OCTETS}}});
+ dec_oid_element([Dig|Tail], Neaten, Num) when Dig < 128 ->
+-    {Num*128+Dig,Neaten+1,Tail};
++    %% Five octets hold 35 bits, so a sub-identifier can be within the
++    %% octet cap and still exceed the value RFC 2578 #3.5 allows.
++    case Num*128+Dig of
++        SubId when SubId =< ?OID_SUBID_MAX_VALUE ->
++            {SubId,Neaten+1,Tail};
++        SubId ->
++            exit({error, {bad_oid_subidentifier_value,
++                          {SubId, ?OID_SUBID_MAX_VALUE}}})
++    end;
+ dec_oid_element([Dig|Tail],Neaten, Num) ->
+     dec_oid_element(Tail, Neaten+1, Num*128 + (Dig band 127)).
+ 

diff --git a/otp-0032-inets-stop-ESI-header-names-from-creating-atoms.patch b/otp-0032-inets-stop-ESI-header-names-from-creating-atoms.patch
new file mode 100644
index 0000000..4eefc02
--- /dev/null
+++ b/otp-0032-inets-stop-ESI-header-names-from-creating-atoms.patch
@@ -0,0 +1,128 @@
+From: Konrad Pietrzak <konrad@erlang.org>
+Date: Thu, 10 Sep 2026 16:59:38 +0200
+Subject: [PATCH] inets: stop ESI header names from creating atoms
+
+http_env_element/3 guards the raw ESI header name with
+list_to_existing_atom/1, but then created a different atom,
+"http_" ++ HeaderName, with list_to_atom/1 unconditionally. Atoms are
+never reclaimed, so every distinct header name a server had ever seen
+cost one permanent atom. The loop feeds itself: an atom created that way
+is a valid seed for the guard on a later request, so a header named
+"node" creates http_node, which then lets a header named "http_node"
+create http_http_node, and so on with no bound at all. Reproduced against
+a live httpd with erl_script_alias, reaching http_http_http_node in three
+rounds.
+
+The env key is now picked out of a fixed list of the standard request
+header names, which exist as atoms because the module names them
+literally rather than because a request asked for them. The documented
+mod_esi contract of {http_<lowercase-header-name>, string()} still holds
+for those. A header outside that set is placed under http_other, which is
+already where a header name that is not an existing atom has always
+ended up.
+
+Fixes CVE-2026-116382.
+
+(cherry picked from commit 5c5c8c038ae7044368bc7bc1eedea09d77a3047a)
+
+[Backport to OTP 26: the httpd_request_handler.erl hunk added
+get_esi_headers/0,1 after protocol/1, which OTP 26 does not have in this
+module; only get_esi_headers was taken (it does not depend on protocol/1).
+httpd_basic_SUITE.erl test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/inets/src/http_server/httpd_request_handler.erl b/lib/inets/src/http_server/httpd_request_handler.erl
+index 9d28714f17..6d2d06bbf2 100644
+--- a/lib/inets/src/http_server/httpd_request_handler.erl
++++ b/lib/inets/src/http_server/httpd_request_handler.erl
+@@ -26,7 +26,7 @@
+ -behaviour(gen_server).
+ 
+ %% Application internal API
+--export([start_link/2, start_link/3, socket_ownership_transfered/3]).
++-export([start_link/2, start_link/3, socket_ownership_transfered/3, get_esi_headers/0]).
+ 
+ %% gen_server callbacks
+ -export([init/1, handle_call/3, handle_cast/2, handle_info/2,
+@@ -783,3 +783,22 @@ setopts(Socket, SocketType, Options) ->
+         {error, _} -> %% inet can return einval instead of closed
+             self() ! {http_transport:close_tag(SocketType), Socket}
+     end.
++
++get_esi_headers() ->
++    get_esi_headers(get(esi_headers)).
++
++get_esi_headers(undefined) ->
++    %% 'other' is the catch-all field of #http_request_h{} rather than a
++    %% header name, and http_other is already taken as the ESI env key
++    %% that carries the headers which get no atom of their own. Mapping
++    %% it here would shadow that key.
++    HeaderList = record_info(fields, http_request_h) -- [other],
++    EsiHeaders = lists:map(fun(Header) ->
++                            HeaderStr = atom_to_list(Header),
++                            EsiHeader = "http_" ++ re:replace(HeaderStr, "-", "_", [{return, list}, global]),
++                            list_to_atom(EsiHeader)
++                           end, HeaderList),
++    put(esi_headers, EsiHeaders),
++    EsiHeaders;
++get_esi_headers(EsiHeaders) when is_list(EsiHeaders) ->
++    EsiHeaders.
+diff --git a/lib/inets/src/http_server/httpd_script_env.erl b/lib/inets/src/http_server/httpd_script_env.erl
+index 089822bc9e..1ab6575540 100644
+--- a/lib/inets/src/http_server/httpd_script_env.erl
++++ b/lib/inets/src/http_server/httpd_script_env.erl
+@@ -26,6 +26,14 @@
+ -include("httpd.hrl").
+ -include("httpd_internal.hrl").
+ 
++%% The ESI env keys for standard request headers follow the
++%% {http_<name>, string()} contract documented in mod_esi. The set of
++%% names is derived once from the standard fields of #http_request_h{}
++%% in http_internal.hrl, with '-' replaced by '_', so http_env_element/3
++%% can look a name up in that fixed set and fail closed on everything
++%% else instead of creating an atom from a request supplied header name.
++%% See httpd_request_handler:get_esi_headers/0.
++
+ %%%=========================================================================
+ %%%  Internal application API 
+ %%%=========================================================================
+@@ -158,7 +166,36 @@ http_env_element(esi, VarName0, Value)  ->
+     list_to_existing_atom(VarName0),
+     VarName = re:replace(VarName0,"-","_", [{return,list}, global]),
+     HeaderName = http_util:to_lower(VarName),
+-    {list_to_atom("http_"++ HeaderName), Value}.
++    %% The guard above only proves that the raw header name is a known
++    %% atom; it says nothing about the prefixed one built here, which used
++    %% to be created with list_to_atom/1 unconditionally. That grew the
++    %% atom table by one permanent entry per distinct header name ever
++    %% received, and since every atom so created is itself a valid seed
++    %% for the guard on a later request the reachable set of names grew
++    %% without bound: header "node" created http_node, which let a later
++    %% header named "http_node" create http_http_node, and so on.
++    %%
++    %% Only the standard header names get an atom key now, and it is
++    %% picked out of a fixed list rather than built from request data.
++    %% Anything else raises here and the caller puts it under http_other,
++    %% which is where a non-standard header belongs anyway.
++    {esi_header_atom("http_" ++ HeaderName), Value}.
++
++esi_header_atom(Prefixed) ->
++    EsiHeaderAtoms = httpd_request_handler:get_esi_headers(),
++    esi_header_atom(Prefixed, EsiHeaderAtoms).
++
++esi_header_atom(Prefixed, [Atom | Atoms]) ->
++    case atom_to_list(Atom) of
++        Prefixed ->
++            Atom;
++        _ ->
++            esi_header_atom(Prefixed, Atoms)
++    end;
++esi_header_atom(Prefixed, []) ->
++    %% Not a standard header. Raise so create_http_header_elements/4
++    %% routes it to http_other instead of minting an atom for it.
++    error({not_a_standard_header, Prefixed}).
+ 
+ multi_value([]) ->
+   [];

diff --git a/otp-0033-inets-replace-CR-LF-and-NUL-with-SP-in-serialized-he.patch b/otp-0033-inets-replace-CR-LF-and-NUL-with-SP-in-serialized-he.patch
new file mode 100644
index 0000000..33dee89
--- /dev/null
+++ b/otp-0033-inets-replace-CR-LF-and-NUL-with-SP-in-serialized-he.patch
@@ -0,0 +1,138 @@
+From: Konrad Pietrzak <konrad@erlang.org>
+Date: Tue, 17 Nov 2026 15:35:43 +0100
+Subject: [PATCH] inets: replace CR, LF and NUL with SP in serialized headers
+
+Header field names and values were written to the wire without
+checking for CR, LF or NUL. A CR or LF in a value ended the header
+line early, so the peer read the rest as additional header lines or
+as the start of a second message.
+
+On the client side this affects every header passed to
+httpc:request/4,5, including with the headers_as_is option. The same
+replacement is applied to httpd response headers and to chunked
+trailers as defence in depth, so that header values from customize
+callbacks and CGI scripts are written to the wire as one field line.
+
+Each CR, LF and NUL in a field name or value is now replaced with SP,
+which RFC 9110 section 5.5 allows as an alternative to rejecting the
+message. Replacing rather than rejecting avoids a new error return,
+and replacing rather than deleting keeps token boundaries intact.
+Chunked trailers are serialized the same way.
+
+Fixes CVE-2026-116295.
+
+(cherry picked from commit a3197fab19232e370d940cb187fa3201b2c9bd48)
+
+[Backport to OTP 26: the http_util.erl -export conflict was resolved by
+keeping OTP 26's connection_tokens/1 entry and adding strip_ctl_chars/1.
+http_format_SUITE.erl / httpd_basic_SUITE.erl test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/inets/src/http_client/httpc_request.erl b/lib/inets/src/http_client/httpc_request.erl
+index f0176ae1ce..c5ca190bb0 100644
+--- a/lib/inets/src/http_client/httpc_request.erl
++++ b/lib/inets/src/http_client/httpc_request.erl
+@@ -266,7 +266,9 @@ method(Method) ->
+ http_headers([], Headers) ->
+     lists:flatten(Headers);
+ http_headers([{Key,Value} | Rest], Headers) ->
+-    Header = Key ++ ": " ++ Value ++ ?CRLF,
++    %% headers_as_is bypasses http_request:http_headers/1
++    Header = http_util:strip_ctl_chars(Key) ++ ": " ++
++        http_util:strip_ctl_chars(Value) ++ ?CRLF,
+     http_headers(Rest, [Header | Headers]).
+ 
+ handle_proxy(_, Headers) when is_list(Headers) ->
+diff --git a/lib/inets/src/http_lib/http_chunk.erl b/lib/inets/src/http_lib/http_chunk.erl
+index 0588937275..54216b788d 100644
+--- a/lib/inets/src/http_lib/http_chunk.erl
++++ b/lib/inets/src/http_lib/http_chunk.erl
+@@ -295,4 +295,5 @@ encode_trailers(Trailers) ->
+ encode_trailers([], Acc) ->
+     Acc ++ ?CRLF ++ ?CRLF;
+ encode_trailers([{Header, Value} | Rest], Acc) ->
+-    encode_trailers(Rest, Header ++ ":" ++ Value ++ ?CRLF ++ Acc).
++    encode_trailers(Rest, http_util:strip_ctl_chars(Header) ++ ":" ++
++                        http_util:strip_ctl_chars(Value) ++ ?CRLF ++ Acc).
+diff --git a/lib/inets/src/http_lib/http_request.erl b/lib/inets/src/http_lib/http_request.erl
+index dad441ce19..c81581d9c0 100644
+--- a/lib/inets/src/http_lib/http_request.erl
++++ b/lib/inets/src/http_lib/http_request.erl
+@@ -290,7 +290,8 @@ headers_other([{Key, Value} | Rest], Headers) ->
+     headers_other(Rest, [mk_key_value_str(Key, Value) | Headers]).
+ 
+ mk_key_value_str(Key, Value) ->
+-    try Key ++ ": " ++ value_to_list(Value) ++ ?CRLF of
++    try http_util:strip_ctl_chars(Key) ++ ": " ++
++        value_to_list(http_util:strip_ctl_chars(Value)) ++ ?CRLF of
+         HeaderStr ->
+             HeaderStr
+     catch
+diff --git a/lib/inets/src/http_lib/http_util.erl b/lib/inets/src/http_lib/http_util.erl
+index 48869d1228..b72305b0a5 100644
+--- a/lib/inets/src/http_lib/http_util.erl
++++ b/lib/inets/src/http_lib/http_util.erl
+@@ -29,7 +29,8 @@
+ 	 timestamp/0, timeout/2,
+ 	 html_encode/1,
+ 	 maybe_add_brackets/2,
+-	 connection_tokens/1
++	 connection_tokens/1,
++	 strip_ctl_chars/1
+ 	]).
+ 
+ 
+@@ -39,6 +40,31 @@
+ to_upper(Str) ->
+     string:uppercase(Str).
+ 
++%% Replace each CR, LF and NUL in a header field name or value with SP,
++%% as allowed by RFC 9110 5.5, so the field cannot end early and inject
++%% header lines or a second message. Replacing rather than deleting keeps
++%% token boundaries ("a\r\nb" must not become "ab"). Accepts iodata and
++%% preserves its shape.
++strip_ctl_chars(Value) when is_binary(Value) ->
++    << <<(replace_ctl_char(Octet))>> || <<Octet>> <= Value >>;
++strip_ctl_chars(Value) when is_list(Value) ->
++    strip_ctl_chars_list(Value).
++
++strip_ctl_chars_list([]) ->
++    [];
++strip_ctl_chars_list([Octet | Rest]) when is_integer(Octet) ->
++    [replace_ctl_char(Octet) | strip_ctl_chars_list(Rest)];
++strip_ctl_chars_list([Nested | Rest]) ->
++    [strip_ctl_chars(Nested) | strip_ctl_chars_list(Rest)];
++strip_ctl_chars_list(Tail) ->
++    %% Improper list, e.g. an iolist with a binary tail
++    strip_ctl_chars(Tail).
++
++replace_ctl_char($\r)   -> $\s;
++replace_ctl_char($\n)   -> $\s;
++replace_ctl_char(0)     -> $\s;
++replace_ctl_char(Octet) -> Octet.
++
+ to_lower(Str) ->
+     string:lowercase(Str).
+ 
+diff --git a/lib/inets/src/http_server/httpd_custom.erl b/lib/inets/src/http_server/httpd_custom.erl
+index 2b9701ef75..350ca2740d 100644
+--- a/lib/inets/src/http_server/httpd_custom.erl
++++ b/lib/inets/src/http_server/httpd_custom.erl
+@@ -69,11 +69,13 @@ response_default_headers(Module) ->
+ %% Internal functions -----------------------------------
+ %%--------------------------------------------------------------------
+ httpify({Key0, Value}) ->
++    %% Every response header passes here, including ESI/CGI/customize ones
++    Key1 = http_util:strip_ctl_chars(Key0),
+     %% make sure first letter is capital (defacto standard)
+-    Words1 = string:tokens(Key0, "-"),
++    Words1 = string:tokens(Key1, "-"),
+     Words2 = upify(Words1, []),
+     Key    = new_key(Words2),
+-    Key ++ ": " ++ Value ++ ?CRLF .
++    Key ++ ": " ++ http_util:strip_ctl_chars(Value) ++ ?CRLF .
+ 
+ new_key([]) ->
+     "";

diff --git a/otp-0034-xmerl-Add-option-to-protect-against-fetching-DTD.patch b/otp-0034-xmerl-Add-option-to-protect-against-fetching-DTD.patch
new file mode 100644
index 0000000..b313cbd
--- /dev/null
+++ b/otp-0034-xmerl-Add-option-to-protect-against-fetching-DTD.patch
@@ -0,0 +1,161 @@
+From: Lars Thorsen <lars@erlang.org>
+Date: Tue, 10 Nov 2026 14:06:53 +0100
+Subject: [PATCH] xmerl: Add option to protect against fetching DTD
+
+xmerl_scan gets a new option to protect against scanning
+of untrusted DTD.
+{fetch_external_DTD, Boolean}: gives the possibility to choose
+if the DTD will befetched or not (false is default).
+
+The secure way to use DTD is let fetch_external_DTD have it's
+default setting and use the option doctype_DTD to give the DTD
+that should be used.
+
+Fixes CVE-2026-119443.
+
+(cherry picked from commit 4d5dc15b3ba923ad9d939c560749239289ba41f3)
+
+[Backport to OTP 26: applied the fetch_external_DTD scanner option plus the
+fetch_and_parse/3 guard and catch-all that skip fetching an external DTD
+unless one was explicitly provided (doctype_DTD) or fetch_external_DTD is
+set - closing the XXE by default. Kept OTP 26's allow_entities=true default
+(OTP 27's flip to false is a separate change) and did not propagate
+allow_entities into nested parses. Dropped the OTP 27 -doc/-type additions
+(including the new option's edoc, which OTP 26's compiler would reject) and
+the test-suite changes; the option still works via initial_state/2.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/xmerl/include/xmerl.hrl b/lib/xmerl/include/xmerl.hrl
+index 42a7779f08..ce591e0499 100644
+--- a/lib/xmerl/include/xmerl.hrl
++++ b/lib/xmerl/include/xmerl.hrl
+@@ -1,8 +1,8 @@
+-%% 
++%%
+ %% %CopyrightBegin%
+-%% 
++%%
+ %% Copyright Ericsson AB 2004-2023. All Rights Reserved.
+-%% 
++%%
+ %% Licensed under the Apache License, Version 2.0 (the "License");
+ %% you may not use this file except in compliance with the License.
+ %% You may obtain a copy of the License at
+@@ -14,7 +14,7 @@
+ %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ %% See the License for the specific language governing permissions and
+ %% limitations under the License.
+-%% 
++%%
+ %% %CopyrightEnd%
+ %%
+ %% Contributor(s):
+@@ -37,7 +37,7 @@
+ %% XML declaration
+ -record(xmlDecl,{
+ 	  vsn,        % string() XML version
+-	  encoding,   % string() Character encoding 
++	  encoding,   % string() Character encoding
+ 	  standalone, % (yes | no)
+ 	  attributes  % [#xmlAttribute()] Other attributes than above
+ 	 }).
+@@ -188,7 +188,8 @@
+ 	  col = 1,
+ 	  line = 1,
+           common_data = [],
+-          allow_entities = true % If true entities are allowed in the document
++          allow_entities = true, % If true entities are allowed in the document
++          fetch_external_DTD = false % If true an external DTD is fetched
+ 	 }).
+ 
+ 
+@@ -238,6 +239,6 @@
+ -define(condstrip3,  {_, T3,  S3}  = condstrip(T2,S2,false)).
+ -define(condstrip4,  {_, T4,  S4}  = condstrip(T3,S3,false)).
+ 
+--define(bump_col(N), 
++-define(bump_col(N),
+ 	?dbg("bump_col(~p), US = ~p~n", [N, S0#xmerl_scanner.user_state]),
+ 	S = S0#xmerl_scanner{col = S0#xmerl_scanner.col + N}).
+diff --git a/lib/xmerl/src/xmerl_scan.erl b/lib/xmerl/src/xmerl_scan.erl
+index 4ad97019ab..9cdb888000 100644
+--- a/lib/xmerl/src/xmerl_scan.erl
++++ b/lib/xmerl/src/xmerl_scan.erl
+@@ -422,6 +422,8 @@ initial_state([{encoding, Enc}|T], S) ->
+     initial_state(T, S#xmerl_scanner{encoding = Enc});
+ initial_state([{allow_entities, F} |T], S) when F==true; F==false ->
+     initial_state(T, S#xmerl_scanner{allow_entities = F});
++initial_state([{fetch_external_DTD, F} |T], S) when F==true; F==false ->
++    initial_state(T, S#xmerl_scanner{fetch_external_DTD = F});
+ initial_state([], S=#xmerl_scanner{rules = undefined}) ->
+     Tab = ets:new(rules, [set, public]),
+     S#xmerl_scanner{rules = Tab};
+@@ -1287,12 +1289,15 @@ scan_doctype3(T, S, DTD) ->
+ 
+ fetch_DTD(undefined, S=#xmerl_scanner{doctype_DTD=URI}) when is_list(URI)->
+     %% allow to specify DTD name when it isn't available in xml stream
++    %% io:format("\n\nOption Provided DTD\n\n", []),
+     fetch_DTD({system,URI},S#xmerl_scanner{doctype_DTD=option_provided});
+ fetch_DTD(undefined, S) ->
+     S;
+-% fetch_DTD(_,S=#xmerl_scanner{validation=false}) ->
+-%     S;
+-fetch_DTD(DTDSpec, S)->
++fetch_DTD(_DTDSpec, S=#xmerl_scanner{doctype_DTD=URI, fetch_external_DTD=false}) when is_list(URI) ->
++    %% io:format("\n\nOption Used DTD\n\n", []),
++    fetch_DTD({system,URI},S#xmerl_scanner{doctype_DTD=option_provided});
++fetch_DTD(DTDSpec, S) ->
++    %% io:format("\n\nOptions: validation=~p fetch_external_DTD=~p doctype_DTD=~p\n\n", [S#xmerl_scanner.validation, S#xmerl_scanner.fetch_external_DTD, S#xmerl_scanner.doctype_DTD]),
+     case fetch_and_parse(DTDSpec,S,[{text_decl,true},
+ 				    {environment,{external,subset}}]) of
+ 	NewS when is_record(NewS,xmerl_scanner) ->
+@@ -1303,8 +1308,12 @@ fetch_DTD(DTDSpec, S)->
+ 
+ fetch_and_parse(ExtSpec,S=#xmerl_scanner{fetch_fun=Fetch,
+ 					 rules=Rules,
+-					 xmlbase = XMLBase},
+-		Options0) ->
++					 xmlbase = XMLBase,
++                                         doctype_DTD=DoctypeDTD,
++                                         fetch_external_DTD=FetchExternalDTD},
++                Options0) when (DoctypeDTD =:= option_provided) orelse
++                               FetchExternalDTD ->
++    %% io:format("Fetch: ~p:~p\n\n", [ExtSpec, DoctypeDTD]),
+     RetS =
+     case Fetch(ExtSpec, S) of
+ 	{ok, NewS} ->
+@@ -1325,7 +1334,8 @@ fetch_and_parse(ExtSpec,S=#xmerl_scanner{fetch_fun=Fetch,
+ 			rules_write_fun = Write,
+ 			validation = Valid,
+ 			quiet = Quiet,
+-			encoding = Charset
++			encoding = Charset,
++                        fetch_external_DTD=FetchDTD
+ 		       }} ->
+ 	    EvS = event_state(NewS),
+ 	    HoS = hook_state(NewS),
+@@ -1343,7 +1353,8 @@ fetch_and_parse(ExtSpec,S=#xmerl_scanner{fetch_fun=Fetch,
+ 				 {acc_fun, Acc},
+ 				 {validation,Valid},
+ 				 {quiet,Quiet},
+-				 {encoding,Charset}],
++				 {encoding,Charset},
++                                 {fetch_external_DTD, FetchDTD}],
+ 
+ 	    case DataRet of
+ 		{file, F} ->
+@@ -1362,7 +1373,11 @@ fetch_and_parse(ExtSpec,S=#xmerl_scanner{fetch_fun=Fetch,
+ 	    RetS#xmerl_scanner{text_decl=false,
+ 			       environment=S#xmerl_scanner.environment};
+ 	_ -> RetS
+-    end.
++    end;
++fetch_and_parse(_ExtSpec, S, _) ->
++    %% io:format("Skipped: ~p\n\n", [_ExtSpec]),
++    S.
++
+ 
+ 
+ fetch_not_parse(ExtSpec,S=#xmerl_scanner{fetch_fun=Fetch}) ->

diff --git a/otp-0035-erts-Fix-binary_to_term-for-reference-with-zero-id-w.patch b/otp-0035-erts-Fix-binary_to_term-for-reference-with-zero-id-w.patch
new file mode 100644
index 0000000..4a4e335
--- /dev/null
+++ b/otp-0035-erts-Fix-binary_to_term-for-reference-with-zero-id-w.patch
@@ -0,0 +1,41 @@
+From: Sverker Eriksson <sverker@erlang.org>
+Date: Wed, 28 Oct 2026 18:08:39 +0100
+Subject: [PATCH] erts: Fix binary_to_term for reference with zero id words
+
+CVE-2026-116293
+
+Could cause VM crash.
+
+Fixes CVE-2026-116293.
+
+(cherry picked from commit e5a9d3d141b8b5609803c3b78c8b420cd294ca82)
+
+[Backport to OTP 26: external.c change applied cleanly; binary_SUITE.erl
+test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
+index 32affb6b6c..f2c4eff79d 100644
+--- a/erts/emulator/beam/external.c
++++ b/erts/emulator/beam/external.c
+@@ -4658,8 +4658,7 @@ dec_term_atom_common:
+ 
+ 	    ref_ext_common:
+ 
+-		if (ref_words > ERTS_MAX_REF_NUMBERS)
+-		    goto error;
++                ASSERT(ref_words >= 1 && ref_words <= ERTS_MAX_REF_NUMBERS);
+ 
+ 		node = dec_get_node(sysname, cre, make_boxed(hp));
+ 		if(node == erts_this_node) {
+@@ -5887,7 +5886,7 @@ init_done:
+ 		CHKSIZE(2);
+ 		id_words = get_int16(ep);
+ 		    
+-		if (id_words > ERTS_MAX_REF_NUMBERS)
++                if (id_words < 1 || id_words > ERTS_MAX_REF_NUMBERS)
+ 		    goto error;
+ 
+ 		ep += 2;

diff --git a/otp-0036-erts-Fix-out-of-bounds-access-by-dec_term-FLOAT_EXT.patch b/otp-0036-erts-Fix-out-of-bounds-access-by-dec_term-FLOAT_EXT.patch
new file mode 100644
index 0000000..ce19c1d
--- /dev/null
+++ b/otp-0036-erts-Fix-out-of-bounds-access-by-dec_term-FLOAT_EXT.patch
@@ -0,0 +1,41 @@
+From: Sverker Eriksson <sverker@erlang.org>
+Date: Mon, 9 Nov 2026 15:59:03 +0100
+Subject: [PATCH] erts: Fix out of bounds access by dec_term FLOAT_EXT
+
+Make sure float string has a terminating zero for sys_chars_to_double().
+
+memcpy should be fine, FLOAT_EXT is very old
+and only encoded by term_to_binary(_, [{minor_version,0}])
+
+Fixes CVE-2026-120961.
+
+(cherry picked from commit 4b954b8aa0f601a0d8d45f0953c77585afb6f853)
+
+[Backport to OTP 26: external.c change applied cleanly; binary_SUITE.erl
+test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
+index f2c4eff79d..1d9911ad8b 100644
+--- a/erts/emulator/beam/external.c
++++ b/erts/emulator/beam/external.c
+@@ -4499,8 +4499,16 @@ dec_term_atom_common:
+ 	case FLOAT_EXT:
+ 	    {
+ 		FloatDef ff;
++                char float_buf[31+2];
+ 
+-		if (sys_chars_to_double((char*)ep, &ff.fd) != 0) {
++                // Ensure sys_chars_to_double() does not read (or even write)
++                // out of bounds. Append an invalid character to fail safely
++                // if original string was not zero terminated.
++                sys_memcpy(float_buf, ep, 31);
++                float_buf[31] = '!';
++                float_buf[32] = 0;
++
++                if (sys_chars_to_double(float_buf, &ff.fd) != 0) {
+ 		    goto error;
+ 		}
+ 		ep += 31;

diff --git a/otp-0037-erts-Remove-all-recursive-calls-to-dec_term.patch b/otp-0037-erts-Remove-all-recursive-calls-to-dec_term.patch
new file mode 100644
index 0000000..139bafe
--- /dev/null
+++ b/otp-0037-erts-Remove-all-recursive-calls-to-dec_term.patch
@@ -0,0 +1,121 @@
+From: Sverker Eriksson <sverker@erlang.org>
+Date: Mon, 9 Nov 2026 16:08:49 +0100
+Subject: [PATCH] erts: Remove all recursive calls to dec_term()
+
+Avoid exploiting stack exhaustion.
+
+Recursive calls done by EXPORT_EXT and NEW_FUN_EXT to decode integers.
+Use new dedicated dec_int32() instead.
+
+Fixes CVE-2026-117642.
+
+(cherry picked from commit 30269e60e42f7c8f19fa3a11c3ed0eba6cb9a076)
+
+[Backport to OTP 26: converted the recursive dec_term() calls the CVE names
+- the EXPORT_EXT Arity field and the NEW_FUN_EXT OldIndex/OldUniq fields - to
+the new non-recursive dec_int32(). OTP 26 already decodes the NEW_FUN_EXT
+creator pid iteratively via the next-pointer chain (funp->creator), not with a
+recursive dec_term() as later branches do, so OTP 26 keeps its funp/off_heap
+linking and needs no creator-pid change. Removed the now-unused Eterm temp;
+binary_SUITE.erl test additions were dropped.]
+
+Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/erts/emulator/beam/external.c b/erts/emulator/beam/external.c
+index 1d9911ad8b..0fd44147f4 100644
+--- a/erts/emulator/beam/external.c
++++ b/erts/emulator/beam/external.c
+@@ -3111,6 +3111,24 @@ dec_pid(ErtsDistExternal *edep, ErtsHeapFactory* factory, const byte* ep,
+     return ep;
+ }
+ 
++static const byte*
++dec_int32(const byte* ep, Sint32* val)
++{
++    switch (*ep++) {
++    case SMALL_INTEGER_EXT:
++        *val = get_int8(ep);
++        ep++;
++        break;
++    case INTEGER_EXT:
++        *val = get_int32(ep);
++        ep += 4;
++        break;
++    default:
++        return NULL;
++    }
++    return ep;
++}
++
+ 
+ #define ENC_TERM ((Eterm) 0)
+ #define ENC_ONE_CONS ((Eterm) 1)
+@@ -4890,8 +4908,7 @@ dec_term_atom_common:
+                 Export *export;
+                 Eterm mod;
+                 Eterm name;
+-                Eterm temp;
+-                Sint arity;
++                Sint32 arity;
+ 
+                 if ((ep = dec_atom(edep, ep, &mod, 0)) == NULL) {
+                     goto error;
+@@ -4900,15 +4917,9 @@ dec_term_atom_common:
+                     goto error;
+                 }
+                 factory->hp = hp;
+-                ep = dec_term(edep, factory, ep, &temp, NULL, 0);
+-                if (ep == NULL) {
+-                    goto error;
+-                }
+-                if (!is_small(temp)) {
+-                    goto error;
+-                }
+-                arity = signed_val(temp);
+-                if (arity < 0) {
++
++                ep = dec_int32(ep, &arity);
++                if (!ep || arity < 0 || arity > MAX_SMALL) {
+                     goto error;
+                 }
+                 if (edep && (edep->flags & ERTS_DIST_EXT_BTT_SAFE)) {
+@@ -4990,11 +5001,10 @@ dec_term_atom_common:
+ 		Eterm module;
+ 		const byte* uniq;
+ 		int index;
+-		Sint old_uniq;
+-		Sint old_index;
++                Sint32 old_uniq;
++                Sint32 old_index;
+ 		unsigned num_free;
+ 		int i;
+-		Eterm temp;
+ 
+ 		ep += 4;	/* Skip total size in bytes */
+ 		arity = *ep++;
+@@ -5016,22 +5026,14 @@ dec_term_atom_common:
+ 		}
+ 		factory->hp = hp;
+ 		/* Index */
+-		if ((ep = dec_term(edep, factory, ep, &temp, NULL, 0)) == NULL) {
+-		    goto error;
+-		}
+-		if (!is_small(temp)) {
++                if ((ep = dec_int32(ep, &old_index)) == NULL) {
+ 		    goto error;
+ 		}
+-		old_index = unsigned_val(temp);
+ 
+ 		/* Uniq */
+-		if ((ep = dec_term(edep, factory, ep, &temp, NULL, 0)) == NULL) {
+-		    goto error;
+-		}
+-		if (!is_small(temp)) {
++                if ((ep = dec_int32(ep, &old_uniq)) == NULL) {
+ 		    goto error;
+ 		}
+-		old_uniq = unsigned_val(temp);
+ 
+ 		/*
+ 		 * It is safe to link the fun into the fun list only when

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-26 16:07 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 16:07 [rpms/erlang] f43: Backported fixes from the OTP 27.3.4.20 security release Peter Lemenkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox