public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/erlang] f43: Merge branch 'f44' into f43
@ 2026-11-26 16:07 Peter Lemenkov
  0 siblings, 0 replies; 3+ messages 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 : cc89e67c6242a72b290d63f1b226b0353234bc92
Author : Peter Lemenkov <lemenkov@gmail.com>
Date   : 2026-11-26T17:07:20+01:00
Stats  : +761/-4 in 9 file(s)
URL    : https://src.fedoraproject.org/rpms/erlang/c/cc89e67c6242a72b290d63f1b226b0353234bc92?branch=f43

Log:
Merge branch 'f44' into f43

---
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] 3+ messages in thread

* [rpms/erlang] f43: Merge branch 'f44' into f43
@ 2026-11-25 16:04 Peter Lemenkov
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Lemenkov @ 2026-11-25 16:04 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/erlang
Branch : f43
Commit : 652e72aac1369ea81c4d09a2797689854d7cb642
Author : Peter Lemenkov <lemenkov@gmail.com>
Date   : 2026-11-25T17:03:54+01:00
Stats  : +46/-1 in 2 file(s)
URL    : https://src.fedoraproject.org/rpms/erlang/c/652e72aac1369ea81c4d09a2797689854d7cb642?branch=f43

Log:
Merge branch 'f44' into f43

---
diff --git a/erlang.spec b/erlang.spec
index 83e0bcb..87bb97e 100644
--- a/erlang.spec
+++ b/erlang.spec
@@ -70,7 +70,7 @@
 
 Name:		erlang
 Version:	26.2.5.21
-Release:	11%{?dist}
+Release:	12%{?dist}
 Summary:	General-purpose programming language and runtime environment
 
 License:	Apache-2.0
@@ -128,6 +128,7 @@ Patch26: otp-0026-ssl-Check-message-type-for-extension-decoding.patch
 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
 # end of autogenerated patch tag list
 
 BuildRequires:	gcc
@@ -1976,6 +1977,9 @@ ERL_TOP=${ERL_TOP} make TARGET=${TARGET} release_tests
 
 
 %changelog
+* 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
+
 * Mon Nov  2 2026 Peter Lemenkov <lemenkov@gmail.com> - 26.2.5.21-11
 - CVE-2026-59696: bound integer parsing in uri_string, httpc, eldap, snmp
 - CVE-2026-94200: check message type when decoding TLS extensions

diff --git a/otp-0030-ssl-Make-anonymous-handling-stricter.patch b/otp-0030-ssl-Make-anonymous-handling-stricter.patch
new file mode 100644
index 0000000..6dc9fa3
--- /dev/null
+++ b/otp-0030-ssl-Make-anonymous-handling-stricter.patch
@@ -0,0 +1,41 @@
+From: Ingela Anderton Andin <ingela@erlang.org>
+Date: Tue, 9 Jun 2026 08:47:27 +0200
+Subject: [PATCH] ssl: Make anonymous handling stricter
+
+Only possibly affets legacy DHE_DSS
+
+Fixes CVE-2026-124286.
+
+(cherry picked from commit d9a931963d3d49c7f73ea509221c9c66737977c7)
+
+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
+--- a/lib/ssl/src/ssl_handshake.erl
++++ b/lib/ssl/src/ssl_handshake.erl
+@@ -422,9 +422,6 @@ verify_signature(?TLS_1_3, Msg, {_, eddsa}, Signature, {?'id-Ed448', PubKey, Pub
+ verify_signature(_, Msg, {HashAlgo, _SignAlg}, Signature,
+ 		 {?'id-ecPublicKey', PublicKey, PublicKeyParams}) ->
+     public_key:verify(Msg, HashAlgo, Signature, {PublicKey, PublicKeyParams});
+-verify_signature(Version, _Msg, {_HashAlgo, anon}, _Signature, _)
+-  when ?TLS_1_X(Version), ?TLS_LTE(Version, ?TLS_1_2) ->
+-    true;
+ verify_signature(Version, Msg, {HashAlgo, dsa}, Signature, {?'id-dsa', PublicKey, PublicKeyParams})
+   when ?TLS_1_X(Version), ?TLS_LTE(Version, ?TLS_1_2) ->
+     public_key:verify(Msg, HashAlgo, Signature, {PublicKey, PublicKeyParams}).
+@@ -2794,9 +2791,7 @@ dec_server_key_signature(Params, <<?BYTE(HashAlgo), ?BYTE(SignAlgo),
+   when ?TLS_GTE(Version, ?TLS_1_2) ->
+     HashSign = {ssl_cipher:hash_algorithm(HashAlgo), ssl_cipher:sign_algorithm(SignAlgo)},
+     {Params, HashSign, Signature};
+-dec_server_key_signature(Params, <<>>, _) ->
+-    {Params, {null, anon}, <<>>};
+-dec_server_key_signature(Params, <<?UINT16(0)>>, _) ->
++dec_server_key_signature(Params, <<>>, Version) when ?TLS_LTE(Version, ?TLS_1_2) ->
+     {Params, {null, anon}, <<>>};
+ dec_server_key_signature(Params, <<?UINT16(Len), Signature:Len/binary>>, _) ->
+     {Params, undefined, Signature};

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [rpms/erlang] f43: Merge branch 'f44' into f43
@ 2026-11-02 18:46 Peter Lemenkov
  0 siblings, 0 replies; 3+ messages in thread
From: Peter Lemenkov @ 2026-11-02 18:46 UTC (permalink / raw)
  To: git-commits

A new commit has been pushed.

Repo   : rpms/erlang
Branch : f43
Commit : 89c4184becef9b5db7aa83faa8badc23b29f50e9
Author : Peter Lemenkov <lemenkov@gmail.com>
Date   : 2026-11-02T19:45:54+01:00
Stats  : +2592/-1 in 5 file(s)
URL    : https://src.fedoraproject.org/rpms/erlang/c/89c4184becef9b5db7aa83faa8badc23b29f50e9?branch=f43

Log:
Merge branch 'f44' into f43

---
diff --git a/erlang.spec b/erlang.spec
index a89a705..83e0bcb 100644
--- a/erlang.spec
+++ b/erlang.spec
@@ -70,7 +70,7 @@
 
 Name:		erlang
 Version:	26.2.5.21
-Release:	10%{?dist}
+Release:	11%{?dist}
 Summary:	General-purpose programming language and runtime environment
 
 License:	Apache-2.0
@@ -124,6 +124,10 @@ Patch22: otp-0022-ssh-Limit-size-of-channel-cache-entries.patch
 Patch23: otp-0023-ssl-Reject-unsolicited-TLS-1.3-pre_shared_key-in-cli.patch
 Patch24: otp-0024-Avoid-signed-int-overflows.patch
 Patch25: otp-0025-inets-Canonicalize-request-path-before-mod_auth-dire.patch
+Patch26: otp-0026-ssl-Check-message-type-for-extension-decoding.patch
+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
 # end of autogenerated patch tag list
 
 BuildRequires:	gcc
@@ -1972,6 +1976,11 @@ ERL_TOP=${ERL_TOP} make TARGET=${TARGET} release_tests
 
 
 %changelog
+* Mon Nov  2 2026 Peter Lemenkov <lemenkov@gmail.com> - 26.2.5.21-11
+- CVE-2026-59696: bound integer parsing in uri_string, httpc, eldap, snmp
+- CVE-2026-94200: check message type when decoding TLS extensions
+- CVE-2026-105236: check SNI on TLS 1.2 session resumption
+
 * Wed Oct 14 2026 Peter Lemenkov <lemenkov@gmail.com> - 26.2.5.21-10
 - Fix FTBFS: drop OTP 27 -doc attribute from the CVE-2026-73270 backport
 

diff --git a/otp-0026-ssl-Check-message-type-for-extension-decoding.patch b/otp-0026-ssl-Check-message-type-for-extension-decoding.patch
new file mode 100644
index 0000000..5d50ee6
--- /dev/null
+++ b/otp-0026-ssl-Check-message-type-for-extension-decoding.patch
@@ -0,0 +1,460 @@
+From: Ingela Anderton Andin <ingela@erlang.org>
+Date: Thu, 24 Sep 2026 13:09:42 +0200
+Subject: [PATCH] ssl: Check message type for extension decoding
+
+This is especially importante for new_session_ticket message
+to avoid ticket poisning from malicus server.
+
+Fixes CVE-2026-94200.
+
+(cherry picked from commit cd0334854bf3ef56dc16f9fb728efe88fb05c4ac)
+
+[Backport to OTP 26: kept OTP 26's TLS 1.3-only supported_versions
+selected-version clause and added the message-type guard to it; dropped
+the unrelated log-level change in tls_server_connection_1_3.erl; kept
+OTP 26's test includes and test list, adding only the new test case.]
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl
+index 7e18803aa3..65f47eb963 100644
+--- a/lib/ssl/src/ssl_handshake.erl
++++ b/lib/ssl/src/ssl_handshake.erl
+@@ -2846,17 +2846,22 @@ decode_extensions(<<>>, _Version, _MessageType, Acc) ->
+     Acc;
+ decode_extensions(<<?UINT16(?ALPN_EXT), ?UINT16(ExtLen), ?UINT16(Len),
+                     ExtensionData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
+-  when Len + 2 =:= ExtLen ->
++  when Len + 2 =:= ExtLen,
++       (MessageType == client_hello orelse
++        MessageType == server_hello orelse
++        MessageType == encrypted_extensions) ->
+     ALPN = #alpn{extension_data = ExtensionData},
+     assert_unique_extension(alpn, Acc),
+     decode_extensions(Rest, Version, MessageType, Acc#{alpn => ALPN});
+ decode_extensions(<<?UINT16(?NEXTPROTONEG_EXT), ?UINT16(Len),
+-                    ExtensionData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    ExtensionData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
++  when MessageType == client_hello; MessageType == server_hello ->
+     NextP = #next_protocol_negotiation{extension_data = ExtensionData},
+     assert_unique_extension(next_protocol_negotiation, Acc),
+     decode_extensions(Rest, Version, MessageType, Acc#{next_protocol_negotiation => NextP});
+ decode_extensions(<<?UINT16(?RENEGOTIATION_EXT), ?UINT16(Len),
+-                    Info:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    Info:Len/binary, Rest/binary>>, Version, MessageType, Acc)
++  when MessageType == client_hello; MessageType == server_hello ->
+     RenegotiateInfo = case Len of
+ 			  1 ->  % Initial handshake
+ 			      Info; % should be <<0>> will be matched in handle_renegotiation_info
+@@ -2873,13 +2878,15 @@ decode_extensions(<<?UINT16(?RENEGOTIATION_EXT), ?UINT16(Len),
+ 
+ decode_extensions(<<?UINT16(?SRP_EXT), ?UINT16(Len), ?BYTE(SRPLen),
+                     SRP:SRPLen/binary, Rest/binary>>, Version, MessageType, Acc)
+-  when Len == SRPLen + 1 ->
++  when Len == SRPLen + 1, MessageType == client_hello ->
+     assert_unique_extension(srp, Acc),
+     decode_extensions(Rest, Version, MessageType, Acc#{srp => #srp{username = SRP}});
+ 
+ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
+-  when ?TLS_LT(Version, ?TLS_1_2) ->
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
++  when ?TLS_LT(Version, ?TLS_1_2),
++       (MessageType == client_hello orelse
++        MessageType == certificate_request) ->
+     SignAlgoListLen = Len - 2,
+     <<?UINT16(SignAlgoListLen), SignAlgoList/binary>> = ExtData,
+     HashSignAlgos = [{ssl_cipher:hash_algorithm(Hash), ssl_cipher:sign_algorithm(Sign)} ||
+@@ -2890,7 +2897,8 @@ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+                                #hash_sign_algos{hash_sign_algos =
+                                                     HashSignAlgos}});
+ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, ?TLS_1_2=Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, ?TLS_1_2 = Version, MessageType, Acc) when
++      MessageType == client_hello; MessageType == certificate_request->
+     SignSchemeListLen = Len - 2,
+     <<?UINT16(SignSchemeListLen), SignSchemeList/binary>> = ExtData,
+     HashSigns = decode_sign_alg(Version, SignSchemeList),
+@@ -2900,7 +2908,8 @@ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+                                #hash_sign_algos{
+                                   hash_sign_algos = HashSigns}});
+ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, ?TLS_1_3=Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, ?TLS_1_3 = Version, MessageType, Acc) when
++      MessageType == client_hello; MessageType == certificate_request ->
+     SignSchemeListLen = Len - 2,
+     <<?UINT16(SignSchemeListLen), SignSchemeList/binary>> = ExtData,
+     SignSchemes = decode_sign_alg(Version, SignSchemeList),
+@@ -2931,7 +2940,8 @@ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_EXT), ?UINT16(Len),
+                                   signature_scheme_list = SignSchemes}});
+ 
+ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_CERT_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when
++      MessageType == client_hello; MessageType == certificate_request ->
+     SignSchemeListLen = Len - 2,
+     <<?UINT16(SignSchemeListLen), SignSchemeList/binary>> = ExtData,
+     %% Ignore unknown signature algorithms
+@@ -2950,21 +2960,24 @@ decode_extensions(<<?UINT16(?SIGNATURE_ALGORITHMS_CERT_EXT), ?UINT16(Len),
+                       Acc#{signature_algs_cert =>
+                                #signature_algorithms_cert{
+                                   signature_scheme_list = SignSchemes}});
+-
+ decode_extensions(<<?UINT16(?USE_SRTP_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
+-    <<?UINT16(ProfilesLen), ProfilesBin:ProfilesLen/binary, ?BYTE(MKILen), MKI:MKILen/binary>> = ExtData,
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when
++      MessageType == client_hello; MessageType == server_hello;
++      MessageType == encrypted_extensions->
++    <<?UINT16(ProfilesLen), ProfilesBin:ProfilesLen/binary,
++      ?BYTE(MKILen), MKI:MKILen/binary>> = ExtData,
+     Profiles = [P || <<P:2/binary>> <= ProfilesBin],
+     assert_unique_extension(use_srtp, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{use_srtp =>
+-                              #use_srtp{
+-                                 protection_profiles = Profiles,
+-                                 mki = MKI}});
+-
++                               #use_srtp{
++                                  protection_profiles = Profiles,
++                                  mki = MKI}});
+ decode_extensions(<<?UINT16(?ELLIPTIC_CURVES_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
+-  when ?TLS_LT(Version, ?TLS_1_3) ->
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc)
++  when ?TLS_LT(Version, ?TLS_1_3),
++       (MessageType == client_hello orelse
++        MessageType == server_hello) ->
+     <<?UINT16(_), EllipticCurveList/binary>> = ExtData,
+     %% Ignore unknown curves
+     Pick = fun(Enum) ->
+@@ -2981,9 +2994,10 @@ decode_extensions(<<?UINT16(?ELLIPTIC_CURVES_EXT), ?UINT16(Len),
+                       Acc#{elliptic_curves =>
+                                #elliptic_curves{elliptic_curve_list =
+                                                     EllipticCurves}});
+-
+ decode_extensions(<<?UINT16(?ELLIPTIC_CURVES_EXT), ?UINT16(Len),
+-		       ExtData:Len/binary, Rest/binary>>, ?TLS_1_3=Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, ?TLS_1_3 = Version, MessageType, Acc) when
++      MessageType == client_hello;
++      MessageType == encrypted_extensions->
+     <<?UINT16(_), GroupList/binary>> = ExtData,
+     %% Ignore unknown curves
+     Pick = fun(Enum) ->
+@@ -3000,9 +3014,9 @@ decode_extensions(<<?UINT16(?ELLIPTIC_CURVES_EXT), ?UINT16(Len),
+                       Acc#{elliptic_curves =>
+                                #supported_groups{supported_groups =
+                                                      SupportedGroups}});
+-
+ decode_extensions(<<?UINT16(?EC_POINT_FORMATS_EXT), ?UINT16(Len),
+-                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when
++      MessageType == client_hello; MessageType == server_hello ->
+     <<?BYTE(_), ECPointFormatList/binary>> = ExtData,
+     ECPointFormats = binary_to_list(ECPointFormatList),
+     assert_unique_extension(ec_point_formats, Acc),
+@@ -3010,27 +3024,39 @@ decode_extensions(<<?UINT16(?EC_POINT_FORMATS_EXT), ?UINT16(Len),
+                       Acc#{ec_point_formats =>
+                                #ec_point_formats{ec_point_format_list =
+                                                      ECPointFormats}});
+-
+ decode_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len),
+-                    Rest/binary>>, Version, MessageType, Acc) when Len == 0 ->
++                    Rest/binary>>, Version, MessageType, Acc) when
++      Len == 0,
++      (MessageType == server_hello orelse
++       MessageType == encrypted_extensions) ->
+     assert_unique_extension(sni, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{sni => #sni{hostname = ""}}); %% Server may send an empty SNI
+ 
+ decode_extensions(<<?UINT16(?SNI_EXT), ?UINT16(Len),
+-                ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when
++      MessageType == client_hello;
++      MessageType == server_hello;
++      MessageType == encrypted_extensions ->
+     <<?UINT16(_), NameList/binary>> = ExtData,
+     assert_unique_extension(sni, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{sni => dec_sni(NameList)});
+ 
+-decode_extensions(<<?UINT16(?MAX_FRAGMENT_LENGTH_EXT), ?UINT16(1), ?BYTE(MaxFragEnum), Rest/binary>>,
+-                  Version, MessageType, Acc) ->
++decode_extensions(<<?UINT16(?MAX_FRAGMENT_LENGTH_EXT), ?UINT16(1),
++                    ?BYTE(MaxFragEnum), Rest/binary>>,
++                  Version, MessageType, Acc) when MessageType == client_hello;
++                                                  MessageType == server_hello;
++                                                  MessageType == encrypted_extensions ->
+     %% RFC 6066 Section 4
+     assert_unique_extension(max_frag_enum, Acc),
+     decode_extensions(Rest, Version, MessageType, Acc#{max_frag_enum => #max_frag_enum{enum = MaxFragEnum}});
+ decode_extensions(<<?UINT16(?SUPPORTED_VERSIONS_EXT), ?UINT16(Len),
+-                       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) when Len > 2 ->
++                    ExtData:Len/binary, Rest/binary>>, Version,
++                  MessageType, Acc) when Len > 2,
++                                         (MessageType == client_hello orelse
++                                          MessageType == server_hello orelse
++                                          MessageType == hello_retry_request) ->
+     <<?BYTE(_),Versions/binary>> = ExtData,
+     assert_unique_extension(client_hello_versions, Acc),
+     decode_extensions(Rest, Version, MessageType,
+@@ -3039,15 +3065,18 @@ decode_extensions(<<?UINT16(?SUPPORTED_VERSIONS_EXT), ?UINT16(Len),
+                                   versions = decode_versions(Versions)}});
+ 
+ decode_extensions(<<?UINT16(?SUPPORTED_VERSIONS_EXT), ?UINT16(Len),
+-                       ?UINT16(SelectedVersion), Rest/binary>>, Version, MessageType, Acc)
+-  when Len =:= 2, SelectedVersion =:= 16#0304 ->
++                    ?UINT16(SelectedVersion), Rest/binary>>, Version, MessageType, Acc)
++  when Len =:= 2, SelectedVersion =:= 16#0304,
++       (MessageType == client_hello orelse
++        MessageType == server_hello orelse
++        MessageType == hello_retry_request) ->
+     assert_unique_extension(server_hello_selected_version, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{server_hello_selected_version =>
+                                #server_hello_selected_version{selected_version = ?TLS_1_3}});
+ 
+ decode_extensions(<<?UINT16(?KEY_SHARE_EXT), ?UINT16(Len),
+-                       ExtData:Len/binary, Rest/binary>>,
++                    ExtData:Len/binary, Rest/binary>>,
+                   Version, MessageType = client_hello, Acc) ->
+     <<?UINT16(_),ClientShares/binary>> = ExtData,
+     assert_unique_extension(key_share, Acc),
+@@ -3079,7 +3108,8 @@ decode_extensions(<<?UINT16(?KEY_SHARE_EXT), ?UINT16(Len),
+                                   selected_group = tls_v1:enum_to_group(Group)}});
+ 
+ decode_extensions(<<?UINT16(?PSK_KEY_EXCHANGE_MODES_EXT), ?UINT16(Len),
+-                       ExtData:Len/binary, Rest/binary>>, Version, MessageType, Acc) ->
++                    ExtData:Len/binary, Rest/binary>>,
++                  Version, MessageType, Acc) when MessageType == client_hello ->
+     <<?BYTE(PLen),KEModes:PLen/binary>> = ExtData,
+     assert_unique_extension(psk_key_exchange_modes, Acc),
+     decode_extensions(Rest, Version, MessageType,
+@@ -3088,7 +3118,7 @@ decode_extensions(<<?UINT16(?PSK_KEY_EXCHANGE_MODES_EXT), ?UINT16(Len),
+                                   ke_modes = decode_psk_key_exchange_modes(KEModes)}});
+ 
+ decode_extensions(<<?UINT16(?PRE_SHARED_KEY_EXT), ?UINT16(Len),
+-                       ExtData:Len/binary, Rest/binary>>,
++                    ExtData:Len/binary, Rest/binary>>,
+                   Version, MessageType = client_hello, Acc) ->
+     <<?UINT16(IdLen),Identities:IdLen/binary,?UINT16(BLen),Binders:BLen/binary>> = ExtData,
+     assert_unique_extension(pre_shared_key, Acc),
+@@ -3101,7 +3131,7 @@ decode_extensions(<<?UINT16(?PRE_SHARED_KEY_EXT), ?UINT16(Len),
+                                   binder_length = BLen + 2}}
+                      );
+ decode_extensions(<<?UINT16(?PRE_SHARED_KEY_EXT), ?UINT16(Len),
+-                       ExtData:Len/binary, Rest/binary>>,
++                    ExtData:Len/binary, Rest/binary>>,
+                   Version, MessageType = server_hello, Acc) ->
+     <<?UINT16(Identity)>> = ExtData,
+     assert_unique_extension(pre_shared_key, Acc),
+@@ -3113,7 +3143,9 @@ decode_extensions(<<?UINT16(?PRE_SHARED_KEY_EXT), ?UINT16(Len),
+ decode_extensions(<<?UINT16(?COOKIE_EXT), ?UINT16(Len), ?UINT16(CookieLen),
+                     Cookie:CookieLen/binary, Rest/binary>>,
+                   Version, MessageType, Acc)
+-  when Len == CookieLen + 2 ->
++  when Len == CookieLen + 2,
++       (MessageType == client_hello orelse
++        MessageType == hello_retry_request) ->
+     assert_unique_extension(cookie, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{cookie => #cookie{cookie = Cookie}});
+@@ -3123,8 +3155,12 @@ decode_extensions(<<?UINT16(?COOKIE_EXT), ?UINT16(Len), ?UINT16(CookieLen),
+ %% with empty "extension_data" in the extended server hello.
+ decode_extensions(<<?UINT16(?STATUS_REQUEST), ?UINT16(Len),
+                     _ExtensionData:Len/binary, Rest/binary>>, Version,
+-                    MessageType = server_hello, Acc)
+-  when Len =:= 0 ->
++                  MessageType, Acc)
++  when Len =:= 0,
++       (MessageType == client_hello orelse
++        MessageType == server_hello orelse
++        MessageType == certificate_request orelse
++        MessageType == certificate) ->
+     assert_unique_extension(status_request, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{status_request => undefined});
+@@ -3133,34 +3169,36 @@ decode_extensions(<<?UINT16(?STATUS_REQUEST), ?UINT16(Len),
+ %% RFC6066.
+ decode_extensions(<<?UINT16(?STATUS_REQUEST), ?UINT16(Len),
+                     CertStatus:Len/binary, Rest/binary>>, Version,
+-                    MessageType, Acc) ->
++                  MessageType, Acc) ->
+     case CertStatus of
+         <<?BYTE(?CERTIFICATE_STATUS_TYPE_OCSP),
+           ?UINT24(OCSPLen),
+           ASN1OCSPResponse:OCSPLen/binary>> ->
+             assert_unique_extension(status_request, Acc),
+             decode_extensions(Rest, Version, MessageType,
+-                      Acc#{status_request => #certificate_status{response = ASN1OCSPResponse}});
++                              Acc#{status_request => #certificate_status{response = ASN1OCSPResponse}});
+         _Other ->
+             decode_extensions(Rest, Version, MessageType, Acc)
+     end;
+ 
+ decode_extensions(<<?UINT16(?EARLY_DATA_EXT), ?UINT16(0), Rest/binary>>,
+-                  Version, MessageType, Acc) ->
++                  Version, MessageType, Acc) when MessageType == client_hello;
++                                                  MessageType == encrypted_extensions ->
+     assert_unique_extension(early_data, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{early_data => #early_data_indication{}});
+ 
+ decode_extensions(<<?UINT16(?EARLY_DATA_EXT), ?UINT16(4), ?UINT32(MaxSize),
+                     Rest/binary>>,
+-                  Version, MessageType, Acc) ->
++                  Version, new_session_ticket = MessageType, Acc) ->
+     assert_unique_extension(early_data, Acc),
+     decode_extensions(Rest, Version, MessageType,
+                       Acc#{early_data =>
+                                #early_data_indication_nst{indication = MaxSize}});
+ decode_extensions(<<?UINT16(?CERTIFICATE_AUTHORITIES_EXT), ?UINT16(Len), 
+                     CertAutsExt:Len/binary, Rest/binary>>,
+-                  Version, MessageType, Acc) ->
++                  Version, MessageType, Acc) when MessageType == client_hello;
++                                                  MessageType == certificate_request ->
+     CertAutsLen = Len - 2,
+     <<?UINT16(CertAutsLen), EncCertAuts/binary>> = CertAutsExt,
+     assert_unique_extension(certificate_authorities, Acc),
+diff --git a/lib/ssl/src/tls_handshake_1_3.erl b/lib/ssl/src/tls_handshake_1_3.erl
+index 58adef4161..0182a43ee6 100644
+--- a/lib/ssl/src/tls_handshake_1_3.erl
++++ b/lib/ssl/src/tls_handshake_1_3.erl
+@@ -648,7 +648,7 @@ decode_handshake(?NEW_SESSION_TICKET, <<?UINT32(LifeTime), ?UINT32(Age),
+                                         ?BYTE(NonceSize), Nonce:NonceSize/binary,
+                                         ?UINT16(TicketSize), Ticket:TicketSize/binary,
+                                         ?UINT16(BinExtSize), BinExts:BinExtSize/binary>>) ->
+-    Exts = decode_extensions(BinExts, encrypted_extensions),
++    Exts = decode_extensions(BinExts, new_session_ticket),
+     #new_session_ticket{ticket_lifetime = LifeTime,
+                         ticket_age_add = Age,
+                         ticket_nonce = Nonce,
+diff --git a/lib/ssl/test/property_test/ssl_eqc_handshake.erl b/lib/ssl/test/property_test/ssl_eqc_handshake.erl
+index dface49f82..818798f5d9 100644
+--- a/lib/ssl/test/property_test/ssl_eqc_handshake.erl
++++ b/lib/ssl/test/property_test/ssl_eqc_handshake.erl
+@@ -484,7 +484,24 @@ extensions(?TLS_1_3 = Version, encrypted_extensions) ->
+ server_name() ->
+   ?LET(ServerName, sni(),
+        ServerName).
+-    %% sni().
++
++max_fragment_length() ->
++    ?LET(Enum, elements([1,2,3,4]), #max_frag_enum{enum = Enum}).
++
++status_request(client_hello) ->
++    undefined; %% Should extend this as part of OCSP enhancement
++status_request(server_hello) ->
++    "".
++
++early_data_indication() ->
++    %% In ClientHello and EncryptedExtensions the early_data extension is
++    %% empty (RFC 8446/9846 4.2.10). The max_early_data_size form
++    %% (#early_data_indication_nst{}) is only valid in NewSessionTicket.
++    #early_data_indication{}.
++
++cookie() ->
++    %% Can be bigger, but value is not important here.
++    #cookie{cookie = rand:bytes(20)}.
+ 
+ signature_algs_cert() ->
+     ?LET(List,  sig_scheme_list(),
+diff --git a/lib/ssl/test/ssl_handshake_SUITE.erl b/lib/ssl/test/ssl_handshake_SUITE.erl
+index 48acb6f5ea..cf44268ae0 100644
+--- a/lib/ssl/test/ssl_handshake_SUITE.erl
++++ b/lib/ssl/test/ssl_handshake_SUITE.erl
+@@ -30,6 +30,7 @@
+ -include("ssl_internal.hrl").
+ -include("ssl_record.hrl").
+ -include("tls_handshake.hrl").
++-include("tls_handshake_1_3.hrl").
+ -include_lib("public_key/include/public_key.hrl").
+ 
+ %% Common test
+@@ -53,7 +54,8 @@
+          select_proper_tls_1_2_rsa_default_hashsign/1,
+          ignore_hassign_extension_pre_tls_1_2/1,
+          signature_algorithms/1,
+-         drop_unassigned_signature_algorithms/1]).
++         drop_unassigned_signature_algorithms/1,
++         decode_early_data_extension_by_message_type/1]).
+ 
+ %%--------------------------------------------------------------------
+ %% Common Test interface functions -----------------------------------
+@@ -68,7 +70,8 @@ all() -> [decode_hello_handshake,
+ 	  select_proper_tls_1_2_rsa_default_hashsign,
+ 	  ignore_hassign_extension_pre_tls_1_2,
+ 	  signature_algorithms,
+-      drop_unassigned_signature_algorithms].
++      drop_unassigned_signature_algorithms,
++      decode_early_data_extension_by_message_type].
+ 
+ %%--------------------------------------------------------------------
+ init_per_suite(Config) ->
+@@ -138,7 +141,7 @@ decode_hello_handshake(_Config) ->
+ 
+ decode_single_hello_extension_correctly(_Config) -> 
+     Renegotiation = <<?UINT16(?RENEGOTIATION_EXT), ?UINT16(1), 0>>,
+-    Extensions = ssl_handshake:decode_extensions(Renegotiation, ?TLS_1_2, undefined),
++    Extensions = ssl_handshake:decode_extensions(Renegotiation, ?TLS_1_2, client_hello),
+     #{renegotiation_info := #renegotiation_info{renegotiated_connection = <<0>>}} = Extensions.
+ 
+ decode_supported_elliptic_curves_hello_extension_correctly(_Config) ->
+@@ -180,6 +183,54 @@ decode_empty_server_sni_correctly(_Config) ->
+     #{sni := #sni{hostname = ""}} = Decoded.
+ 
+ 
++decode_early_data_extension_by_message_type(_Config) ->
++    %% RFC 9846 §4.2: the early_data extension has two wire forms and the
++    %% form permitted depends on the handshake message it rides in:
++    %%   - empty (0-length) in ClientHello / EncryptedExtensions
++    %%     -> #early_data_indication{}
++    %%   - 4-byte max_early_data_size in NewSessionTicket
++    %%     -> #early_data_indication_nst{}
++    %% The decoder must enforce this per message type. Regression test for the
++    %% NST early_data DoS: a malicious server's NewSessionTicket carrying a
++    %% 0-length early_data was previously decoded to #early_data_indication{}
++    %% and stored in the node-global tls_client_ticket_store; a later
++    %% auto-resume then crashed the store with a case_clause in
++    %% get_max_early_data/1 (only undefined/#early_data_indication_nst{} are
++    %% handled there). The fix guards the 0-length form to CH/EE only, so a
++    %% 0-length early_data in an NST is ignored (never stored, never crashes).
++
++    EmptyEarlyData = <<?UINT16(?EARLY_DATA_EXT), ?UINT16(0)>>,
++    NstEarlyData   = <<?UINT16(?EARLY_DATA_EXT), ?UINT16(4), ?UINT32(16384)>>,
++
++    %% Legitimate empty form in ClientHello / EncryptedExtensions is accepted.
++    #{early_data := #early_data_indication{}} =
++        ssl_handshake:decode_extensions(EmptyEarlyData, ?TLS_1_3, client_hello),
++    #{early_data := #early_data_indication{}} =
++        ssl_handshake:decode_extensions(EmptyEarlyData, ?TLS_1_3, encrypted_extensions),
++
++    %% Legitimate 4-byte form in NewSessionTicket is accepted.
++    #{early_data := #early_data_indication_nst{indication = 16384}} =
++        ssl_handshake:decode_extensions(NstEarlyData, ?TLS_1_3, new_session_ticket),
++
++    %% DoS closure: a 0-length early_data in a NewSessionTicket is NOT a valid
++    %% NST form, so it is ignored (no early_data key) rather than stored as
++    %% #early_data_indication{}. Before the fix this returned
++    %% #{early_data => #early_data_indication{}} and poisoned the ticket store.
++    NoEarlyDataNst = ssl_handshake:decode_extensions(EmptyEarlyData, ?TLS_1_3,
++                                                     new_session_ticket),
++    false = maps:is_key(early_data, NoEarlyDataNst),
++
++    %% Symmetric guard: the 4-byte NST form is not valid in ClientHello /
++    %% EncryptedExtensions and is likewise ignored.
++    NoEarlyDataCh = ssl_handshake:decode_extensions(NstEarlyData, ?TLS_1_3,
++                                                    client_hello),
++    false = maps:is_key(early_data, NoEarlyDataCh),
++    NoEarlyDataEe = ssl_handshake:decode_extensions(NstEarlyData, ?TLS_1_3,
++                                                    encrypted_extensions),
++    false = maps:is_key(early_data, NoEarlyDataEe),
++    ok.
++
++
+ select_proper_tls_1_2_rsa_default_hashsign(_Config) ->
+     % RFC 5246 section 7.4.1.4.1 tells to use {sha1,rsa} as default signature_algorithm for RSA key exchanges
+     {sha, rsa} = ssl_handshake:select_hashsign_algs(undefined, ?rsaEncryption, ?TLS_1_2),

diff --git a/otp-0027-inets-stdlib-eldap-Bound-integer-parsing-to-mitigate.patch b/otp-0027-inets-stdlib-eldap-Bound-integer-parsing-to-mitigate.patch
new file mode 100644
index 0000000..5dbc5db
--- /dev/null
+++ b/otp-0027-inets-stdlib-eldap-Bound-integer-parsing-to-mitigate.patch
@@ -0,0 +1,749 @@
+From: Konrad Pietrzak <konrad@erlang.org>
+Date: Thu, 25 Jun 2026 13:51:22 +0200
+Subject: [PATCH] inets,stdlib,eldap: Bound integer parsing to mitigate DoS
+
+inets (httpc):
+- Add per-request max_header_size and max_body_size options
+- Enforce cumulative header byte count during parsing; reject with
+  {error, {header_too_long, {max, MaxSize}}} when exceeded
+- Default max_header_size is 10240 (same as httpd)
+- Validate Content-Length contains only digits before storing,
+  preventing badarg crashes on malformed responses
+- Update limits from new request options on connection reuse
+- Catch validation throws in handler, return clean errors to caller
+- Document new options in request/4,5 docstring
+
+stdlib (uri_string):
+- Bound port component digit count in uri_string:parse/1
+
+eldap:
+- Bound port digit count in referral URL parsing
+
+snmp:
+- Bound INTEGER value to max 32-bit value as in SMI-MIB
+- Bound Counter32/Gauge32/TimeTicks to 5 bytes (32-bit + sign)
+- Bound Counter64 to 9 bytes (64-bit + sign)
+
+Mitigates GHSA-8qw4-2chm-mvj2.
+
+Fixes CVE-2026-59696.
+
+(cherry picked from commit aba0fe8c2d700bf4ac94607cf7f00e53bbe4042d)
+
+[Backport to OTP 26: dropped the -doc attribute for httpc:request/5
+(OTP 26 has XML docs). The headers_conflict_chunked_with_length test
+conflict was adapted to OTP 26 call syntax: the new throw handler in
+httpc_handler now reports {headers_conflict, _} instead of
+{could_not_parse_as_http, _}, as upstream.]
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/eldap/src/eldap.erl b/lib/eldap/src/eldap.erl
+index 7edd012263..eea66896f8 100644
+--- a/lib/eldap/src/eldap.erl
++++ b/lib/eldap/src/eldap.erl
+@@ -1422,10 +1422,12 @@ parse_hostport(Str) ->
+ 		   parse_port(Rest,Sport)}}
+     end.
+ 
+-parse_port(Rest,Sport) ->
++parse_port(Rest,Sport) when length(Sport) =< 5 ->
+     try	list_to_integer(Sport)
+     catch _:_ -> parse_error(parsing_port,Rest)
+-    end.
++    end;
++parse_port(Rest, _) ->
++    parse_error(parsing_port, Rest).
+ 
+ parse_host(Rest,Shost) ->
+     case catch validate_host(Shost) of
+diff --git a/lib/inets/src/http_client/httpc.erl b/lib/inets/src/http_client/httpc.erl
+index 953f19bc5a..23ca981431 100644
+--- a/lib/inets/src/http_client/httpc.erl
++++ b/lib/inets/src/http_client/httpc.erl
+@@ -156,7 +156,9 @@ request(Url, Profile) ->
+                         | {headers_as_is, boolean()}
+                         | {socket_opts, [SocketOpt]}
+                         | {receiver, Receiver}
+-                        | {ipv6_host_with_brackets, boolean()},
++                        | {ipv6_host_with_brackets, boolean()}
++                        | {max_header_size, MaxSize}
++                        | {max_body_size, MaxSize},
+       StreamTo :: none | self | {self, once} | file:name_all(),
+       SocketOpt :: term(),
+       BodyFormat  :: string | binary,
+@@ -165,6 +167,7 @@ request(Url, Profile) ->
+                   | { ReceiverModule::atom()
+                     , ReceiverFunction::atom()
+                     , ReceiverArgs::list()},
++      MaxSize :: non_neg_integer() | nolimit,
+       Result :: { StatusLine , [HttpHeader], HttpBodyResult}
+               | { StatusCode, HttpBodyResult}
+               | RequestId
+@@ -218,7 +221,9 @@ request(Method, Request, HttpOptions, Options) ->
+                      | {headers_as_is, boolean()}
+                      | {socket_opts, [SocketOpt]}
+                      | {receiver, Receiver}
+-                     | {ipv6_host_with_brackets, boolean()},
++                     | {ipv6_host_with_brackets, boolean()}
++                     | {max_header_size, MaxSize}
++                     | {max_body_size, MaxSize},
+       StreamTo :: none | self | {self, once} | file:name_all(),
+       BodyFormat  :: string | binary,
+       SocketOpt :: term(),
+@@ -227,6 +232,7 @@ request(Method, Request, HttpOptions, Options) ->
+                   | { ReceiverModule::atom()
+                     , ReceiverFunction::atom()
+                     , ReceiverArgs::list()},
++      MaxSize :: non_neg_integer() | nolimit,
+       Profile :: atom() | pid(),
+       HttpVersion :: string(),
+       Result :: {StatusLine
+@@ -927,7 +933,9 @@ maybe_format_body(BinBody, Options) ->
+                         | {headers_as_is, boolean()}
+                         | {socket_opts, [SocketOpt]}
+                         | {receiver, Receiver}
+-                        | {ipv6_host_with_brackets, boolean()},
++                        | {ipv6_host_with_brackets, boolean()}
++                        | {max_header_size,         MaxSize}
++                        | {max_body_size,           MaxSize},
+       BodyFormat  :: string | binary,
+       StreamTo :: none | self | {self, once} | file:name_all(),
+       SocketOpt :: term(),
+@@ -935,7 +943,8 @@ maybe_format_body(BinBody, Options) ->
+                   | fun((term()) -> term())
+                   | { ReceiverModule::atom()
+                     , ReceiverFunction::atom()
+-                    , ReceiverArgs::list()}.
++                    , ReceiverArgs::list()},
++      MaxSize :: non_neg_integer() | nolimit.
+ %% This options is a workaround for http servers that do not follow the 
+ %% http standard and have case sensitive header parsing. Should only be
+ %% used if there is no other way to communicate with the server or for
+@@ -1120,16 +1129,26 @@ request_options_defaults() ->
+ 
+     VerifyBrackets = VerifyBoolean,
+ 
++    VerifyIntegerNoLimit =
++        fun(nolimit) ->
++                ok;
++           (Value) when
++                  is_integer(Value), Value > 0 ->
++                ok
++        end,
++
+     [
+-     {sync,                    true,      VerifySync}, 
+-     {stream,                  none,      VerifyStream},
+-     {body_format,             string,    VerifyBodyFormat},
+-     {full_result,             true,      VerifyFullResult},
+-     {headers_as_is,           false,     VerifyHeaderAsIs},
+-     {receiver,                alias(),    VerifyReceiver},
+-     {socket_opts,             undefined, VerifySocketOpts},
+-     {ipv6_host_with_brackets, false,     VerifyBrackets}
+-    ]. 
++     {sync,                    true,                       VerifySync},
++     {stream,                  none,                       VerifyStream},
++     {body_format,             string,                     VerifyBodyFormat},
++     {full_result,             true,                       VerifyFullResult},
++     {headers_as_is,           false,                      VerifyHeaderAsIs},
++     {receiver,                alias(),                    VerifyReceiver},
++     {socket_opts,             undefined,                  VerifySocketOpts},
++     {ipv6_host_with_brackets, false,                      VerifyBrackets},
++     {max_header_size,         ?HTTP_MAX_HEADER_SIZE,      VerifyIntegerNoLimit},
++     {max_body_size,           ?HTTP_MAX_BODY_SIZE,        VerifyIntegerNoLimit}
++    ].
+ 
+ request_options(Options) ->
+     Defaults = request_options_defaults(), 
+@@ -1175,7 +1194,9 @@ request_options([{Key, DefaultVal, Verify} | Defaults], Options, Acc) ->
+                      | {headers_as_is, boolean()}
+                      | {socket_opts, [SocketOpt]}
+                      | {receiver, Receiver}
+-                     | {ipv6_host_with_brackets, boolean()},
++                     | {ipv6_host_with_brackets, boolean()}
++                     | {max_header_size, MaxSize}
++                     | {max_body_size, MaxSize},
+       StreamTo :: none | self | {self, once} | file:name_all(),
+       BodyFormat  :: string | binary,
+       SocketOpt :: term(),
+@@ -1184,7 +1205,8 @@ request_options([{Key, DefaultVal, Verify} | Defaults], Options, Acc) ->
+                   | fun((term()) -> term())
+                   | { ReceiverModule::atom()
+                     , ReceiverFunction::atom()
+-                    , ReceiverArgs::list()}.
++                    , ReceiverArgs::list()},
++      MaxSize :: non_neg_integer() | nolimit.
+ request_options_sanity_check(Opts) ->
+     case proplists:get_value(sync, Opts) of
+ 	Sync when (Sync =:= true) ->
+diff --git a/lib/inets/src/http_client/httpc_handler.erl b/lib/inets/src/http_client/httpc_handler.erl
+index 1d91fe1479..a10d3bd565 100644
+--- a/lib/inets/src/http_client/httpc_handler.erl
++++ b/lib/inets/src/http_client/httpc_handler.erl
+@@ -224,17 +224,23 @@ init([Parent, Request, Options, ProfileName]) ->
+     handle_verbose(Options#options.verbose),
+     ProxyOptions = handle_proxy_options(Request#request.scheme, Options),
+     Address = handle_proxy(Request#request.address, ProxyOptions),
++    MaxHeaderSize = proplists:get_value(max_header_size, Request#request.request_options),
++    MaxBodySize = proplists:get_value(max_body_size, Request#request.request_options),
+     {ok, State} =
+         %% #state.once should initially be 'inactive' because we
+         %% activate the socket at first regardless of the state.
+         case {Address /= Request#request.address, Request#request.scheme} of
+             {true, https} ->
+                 connect_and_send_upgrade_request(Address, Request,
+-                                                 #state{options = Options,
++                                                 #state{max_header_size = MaxHeaderSize,
++                                                        max_body_size = MaxBodySize,
++                                                        options = Options,
+                                                         profile_name = ProfileName});
+             {_, _} ->
+                 connect_and_send_first_request(Address, Request,
+-                                   #state{options = Options,
++                                   #state{max_header_size = MaxHeaderSize,
++                                          max_body_size = MaxBodySize,
++                                          options = Options,
+                                           profile_name = ProfileName})
+         end,
+     gen_server:enter_loop(?MODULE, [], State).
+@@ -248,6 +254,20 @@ init([Parent, Request, Options, ProfileName]) ->
+ %%          {stop, Reason, State}            (terminate/2 is called)
+ %% Description: Handling call messages
+ %%--------------------------------------------------------------------
++handle_call(Request, From, State0) when
++      is_record(Request, request) ->
++    MaxHeaderSize = proplists:get_value(max_header_size, Request#request.request_options),
++    MaxBodySize = proplists:get_value(max_body_size, Request#request.request_options),
++    State = State0#state{max_header_size = MaxHeaderSize,
++                         max_body_size = MaxBodySize},
++    try do_handle_call(Request, From, State) of
++        Result ->
++            Result
++    catch
++        Class:Reason:ST ->
++            {stop, {shutdown, {{Class, Reason}, ST}}, State}
++    end;
++
+ handle_call(Request, From, State) ->
+     try do_handle_call(Request, From, State) of 
+ 	Result ->
+@@ -538,6 +558,10 @@ do_handle_info({Proto, _Socket, Data},
+ 	    activate_once(Session),
+ 	    {noreply, State#state{mfa = NewMFA}}
+     catch
++        throw:{error, Err}:_ ->
++            ClientErrMsg = httpc_response:error(Request, Err),
++            NewState = answer_request(Request, ClientErrMsg, State),
++            {stop, normal, NewState};
+ 	Class:Reason:ST ->
+ 	    ClientReason = {could_not_parse_as_http, Data}, 
+ 	    ClientErrMsg = httpc_response:error(Request, ClientReason),
+diff --git a/lib/inets/src/http_client/httpc_response.erl b/lib/inets/src/http_client/httpc_response.erl
+index 603cd64ea8..246ab88d55 100644
+--- a/lib/inets/src/http_client/httpc_response.erl
++++ b/lib/inets/src/http_client/httpc_response.erl
+@@ -56,9 +56,9 @@ parse_reason_phrase([Bin, Rest, Phrase, MaxHeaderSize, Result, Relaxed]) ->
+     parse_reason_phrase(<<Rest/binary, Bin/binary>>, Phrase, 
+ 			MaxHeaderSize, Result, Relaxed).
+ 
+-parse_headers([Bin, Rest,Header, Headers, MaxHeaderSize, Result, Relaxed]) ->
++parse_headers([Bin, Rest,Header, Headers, MaxHeaderSize, CurrentSize, Result, Relaxed]) ->
+     parse_headers(<<Rest/binary, Bin/binary>>, Header, Headers, 
+-		  MaxHeaderSize, Result, Relaxed).
++		  MaxHeaderSize, CurrentSize, Result, Relaxed).
+     
+ whole_body(Body, Length) when is_binary(Body)->
+     case byte_size(Body) of
+@@ -195,7 +195,7 @@ parse_status_code(<<?LF>>, StatusCodeStr,
+ 
+ parse_status_code(<<?CR, ?LF, Rest/binary>>, StatusCodeStr, 
+ 		  MaxHeaderSize, Result, true) ->
+-    parse_headers(Rest, [], [], MaxHeaderSize,
++    parse_headers(Rest, [], [], MaxHeaderSize, 0,
+  		  [" ", list_to_integer(lists:reverse(
+                                           string:trim(StatusCodeStr)))
+ 		   | Result], true); 
+@@ -245,7 +245,7 @@ parse_reason_phrase(<<?LF, Rest/binary>>, Phrase,
+ 			MaxHeaderSize, Result, Relaxed);
+ parse_reason_phrase(<<?CR, ?LF, Rest/binary>>, Phrase, 
+  		    MaxHeaderSize, Result, Relaxed) ->
+-    parse_headers(Rest, [], [], MaxHeaderSize,
++    parse_headers(Rest, [], [], MaxHeaderSize, 0,
+  		  [lists:reverse(Phrase) | Result], Relaxed); 
+ parse_reason_phrase(<<?LF>>, Phrase, MaxHeaderSize, Result, Relaxed) ->
+     %% If ?CR is is missing RFC2616 section-19.3 
+@@ -259,100 +259,96 @@ parse_reason_phrase(<<Octet, Rest/binary>>, Phrase, MaxHeaderSize, Result,
+     parse_reason_phrase(Rest, [Octet | Phrase], MaxHeaderSize, 
+ 			Result, Relaxed).
+ 
+-parse_headers(<<>>, Header, Headers, MaxHeaderSize, Result, Relaxed) -> 
+-    {?MODULE, parse_headers, [<<>>, Header, Headers, MaxHeaderSize, Result,
++parse_headers(<<>>, Header, Headers, MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    {?MODULE, parse_headers, [<<>>, Header, Headers, MaxHeaderSize, CurrentSize, Result,
+ 			      Relaxed]};
+ 
+ parse_headers(<<?CR,?LF,?LF,Body/binary>>, Header, Headers,
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    %% If ?CR is is missing RFC2616 section-19.3 
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    %% If ?CR is is missing RFC2616 section-19.3
+     parse_headers(<<?CR,?LF,?CR,?LF,Body/binary>>, Header, Headers,
+-		  MaxHeaderSize, Result, Relaxed);
++                  MaxHeaderSize, CurrentSize, Result, Relaxed);
+ 
+ parse_headers(<<?LF,?LF,Body/binary>>, Header, Headers,
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    %% If ?CR is is missing RFC2616 section-19.3 
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    %% If ?CR is is missing RFC2616 section-19.3
+     parse_headers(<<?CR,?LF,?CR,?LF,Body/binary>>, Header, Headers,
+-		  MaxHeaderSize, Result, Relaxed);
++                  MaxHeaderSize, CurrentSize, Result, Relaxed);
+ 
+ parse_headers(<<?CR,?LF,?CR,?LF,Body/binary>>, Header, Headers,
+-	      MaxHeaderSize, Result, Relaxed) ->
++	      _MaxHeaderSize, _CurrentSize, Result, Relaxed) ->
+     HTTPHeaders = [lists:reverse(Header) | Headers],
+-    Length = lists:foldl(fun(H, Acc) -> length(H) + Acc end,
+-			   0, HTTPHeaders),
+-    case ((Length =< MaxHeaderSize) or (MaxHeaderSize == nolimit)) of
+- 	true ->   
+-	    ResponseHeaderRcord = 
+-		http_response:headers(HTTPHeaders, #http_response_h{}),
+-
+-            %% RFC7230, Section 3.3.3
+-            %% If a message is received with both a Transfer-Encoding and a
+-            %% Content-Length header field, the Transfer-Encoding overrides the
+-            %% Content-Length. Such a message might indicate an attempt to
+-            %% perform request smuggling (Section 9.5) or response splitting
+-            %% (Section 9.4) and ought to be handled as an error. A sender MUST
+-            %% remove the received Content-Length field prior to forwarding such
+-            %% a message downstream.
+-            case ResponseHeaderRcord#http_response_h.'transfer-encoding' of
+-                undefined ->
++    ResponseHeaderRcord =
++        http_response:headers(HTTPHeaders, #http_response_h{}),
++
++    %% RFC7230, Section 3.3.3
++    %% If a message is received with both a Transfer-Encoding and a
++    %% Content-Length header field, the Transfer-Encoding overrides the
++    %% Content-Length. Such a message might indicate an attempt to
++    %% perform request smuggling (Section 9.5) or response splitting
++    %% (Section 9.4) and ought to be handled as an error. A sender MUST
++    %% remove the received Content-Length field prior to forwarding such
++    %% a message downstream.
++    case ResponseHeaderRcord#http_response_h.'transfer-encoding' of
++        undefined ->
++            {ok, list_to_tuple(
++                   lists:reverse([Body, ResponseHeaderRcord | Result]))};
++        Value ->
++            TransferEncoding = string:lowercase(Value),
++            ContentLength = ResponseHeaderRcord#http_response_h.'content-length',
++            if
++                %% Respond without error but remove Content-Length field in relaxed mode
++                (Relaxed =:= true)
++                andalso (TransferEncoding =:= "chunked")
++                andalso (ContentLength =/= "-1") ->
++                    ResponseHeaderRcordFixed =
++                        ResponseHeaderRcord#http_response_h{'content-length' = "-1"},
++                    {ok, list_to_tuple(
++                           lists:reverse([Body, ResponseHeaderRcordFixed | Result]))};
++                %% Respond with error in default (not relaxed) mode
++                (Relaxed =:= false)
++                andalso (TransferEncoding =:= "chunked")
++                andalso (ContentLength =/= "-1") ->
++                    throw({error, {headers_conflict, {'content-length',
++                                                      'transfer-encoding'}}});
++                true  ->
+                     {ok, list_to_tuple(
+-                           lists:reverse([Body, ResponseHeaderRcord | Result]))};
+-                Value ->
+-                    TransferEncoding = string:lowercase(Value),
+-                    ContentLength = ResponseHeaderRcord#http_response_h.'content-length',
+-                    if
+-                        %% Respond without error but remove Content-Length field in relaxed mode
+-                        (Relaxed =:= true)
+-                        andalso (TransferEncoding =:= "chunked")
+-                        andalso (ContentLength =/= "-1") ->
+-                            ResponseHeaderRcordFixed =
+-                                ResponseHeaderRcord#http_response_h{'content-length' = "-1"},
+-                            {ok, list_to_tuple(
+-                                   lists:reverse([Body, ResponseHeaderRcordFixed | Result]))};
+-                        %% Respond with error in default (not relaxed) mode
+-                        (Relaxed =:= false)
+-                        andalso (TransferEncoding =:= "chunked")
+-                        andalso (ContentLength =/= "-1") ->
+-                            throw({error, {headers_conflict, {'content-length',
+-                                                              'transfer-encoding'}}});
+-                        true  ->
+-                            {ok, list_to_tuple(
+-                                   lists:reverse([Body, ResponseHeaderRcord | Result]))}
+-                    end
+-            end;
+- 	false ->
+-	    throw({error, {header_too_long, MaxHeaderSize, 
+-			   MaxHeaderSize-Length}})
++                           lists:reverse([Body, ResponseHeaderRcord | Result]))}
++            end
+     end;
+-parse_headers(<<?CR,?LF,?CR>> = Data, Header, Headers, 
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    {?MODULE, parse_headers, [Data, Header, Headers, 
+-			      MaxHeaderSize, Result, Relaxed]};
+-parse_headers(<<?CR,?LF>> = Data, Header, Headers, 
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    {?MODULE, parse_headers, [Data, Header, Headers, MaxHeaderSize, 
+-			      Result, Relaxed]};
++parse_headers(<<?CR,?LF,?CR>> = Data, Header, Headers,
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    {?MODULE, parse_headers, [Data, Header, Headers,
++                              MaxHeaderSize, CurrentSize, Result, Relaxed]};
++parse_headers(<<?CR,?LF>> = Data, Header, Headers,
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    {?MODULE, parse_headers, [Data, Header, Headers, MaxHeaderSize, CurrentSize,
++                              Result, Relaxed]};
+ parse_headers(<<?CR,?LF, Octet, Rest/binary>>, Header, Headers,
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    parse_headers(Rest, [Octet], 
+-		  [lists:reverse(Header) | Headers], MaxHeaderSize, 
+-		  Result, Relaxed);
+-parse_headers(<<?CR>> = Data, Header, Headers, 
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    {?MODULE, parse_headers, [Data, Header, Headers, MaxHeaderSize, 
+-			      Result, Relaxed]};
+-
+-parse_headers(<<?LF>>, Header, Headers, 
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    %% If ?CR is is missing RFC2616 section-19.3 
+-    parse_headers(<<?CR, ?LF>>, Header, Headers, 
+-		  MaxHeaderSize, Result, Relaxed);
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    parse_headers(Rest, [Octet],
++                  [lists:reverse(Header) | Headers], MaxHeaderSize, CurrentSize + 3,
++                  Result, Relaxed);
++parse_headers(<<?CR>> = Data, Header, Headers,
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    {?MODULE, parse_headers, [Data, Header, Headers, MaxHeaderSize, CurrentSize,
++                              Result, Relaxed]};
++
++parse_headers(<<?LF>>, Header, Headers,
++              MaxHeaderSize, CurrentSize, Result, Relaxed) ->
++    %% If ?CR is is missing RFC2616 section-19.3
++    parse_headers(<<?CR, ?LF>>, Header, Headers,
++                  MaxHeaderSize, CurrentSize, Result, Relaxed);
+ 
+ parse_headers(<<Octet, Rest/binary>>, Header, Headers,
+-	      MaxHeaderSize, Result, Relaxed) ->
+-    parse_headers(Rest, [Octet | Header], Headers, MaxHeaderSize, 
+-		  Result, Relaxed).
+-
++              MaxHeaderSize, CurrentSize, Result, Relaxed)
++  when (is_integer(MaxHeaderSize) andalso CurrentSize < MaxHeaderSize);
++       MaxHeaderSize =:= nolimit ->
++    parse_headers(Rest, [Octet | Header], Headers, MaxHeaderSize,
++                  CurrentSize + 1, Result, Relaxed);
++parse_headers(<<_Octet, _Rest/binary>>, _UnfinalizedHeader, _Headers,
++              MaxHeaderSize, _CurrentSize, _Result, _Relaxed) ->
++    throw({error, {header_too_long, {max, MaxHeaderSize}}}).
+ 
+ %% RFC2616, Section 10.1.1
+ %% Note:
+diff --git a/lib/inets/src/http_lib/http_response.erl b/lib/inets/src/http_lib/http_response.erl
+index cbdea82523..2d616dddc9 100644
+--- a/lib/inets/src/http_lib/http_response.erl
++++ b/lib/inets/src/http_lib/http_response.erl
+@@ -125,7 +125,10 @@ headers("content-encoding", Value, Headers) ->
+ headers("content-language", Value, Headers) ->
+     Headers#http_response_h{'content-language' = Value};
+ headers("content-length", Value, Headers) ->
+-    Headers#http_response_h{'content-length' = Value};
++    case is_valid_content_length(Value) of
++        true -> Headers#http_response_h{'content-length' = Value};
++        false -> throw({error, {invalid_content_length, Value}})
++    end;
+ headers("content-location", Value, Headers) ->
+     Headers#http_response_h{'content-location' = Value};
+ headers("content-md5", Value, Headers) ->
+@@ -221,3 +224,8 @@ key_value_tuple(_, undefined) ->
+     undefined;
+ key_value_tuple(Key, Value) ->
+     {Key, Value}.
++
++is_valid_content_length("") ->
++    false;
++is_valid_content_length(Value) ->
++    lists:all(fun(C) -> C >= $0 andalso C =< $9 end, Value).
+diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl
+index b31f5d9eec..9de9eccda6 100644
+--- a/lib/inets/test/httpc_SUITE.erl
++++ b/lib/inets/test/httpc_SUITE.erl
+@@ -157,7 +157,7 @@ real_requests_esi() ->
+ 
+ simulated_unix_socket() ->
+     [unix_domain_socket,
+-    invalid_ipfamily_unix_socket].
++     invalid_ipfamily_unix_socket].
+ 
+ only_simulated() ->
+     [
+@@ -209,7 +209,10 @@ only_simulated() ->
+      get_space,
+      delete_no_body,
+      post_with_content_type,
+-     stream_fun_server_close
++     stream_fun_server_close,
++     abnormal_header_size,
++     invalid_content_length,
++     abnormal_trailer_size
+     ].
+ 
+ server_closing_connection() ->
+@@ -1361,7 +1364,7 @@ headers_conflict_chunked_with_length(doc) ->
+ headers_conflict_chunked_with_length(Config) when is_list(Config) ->
+     Request = {url(group_name(Config), "/headers_conflict_chunked_with_length.html", Config), []},
+     RequestOpts = proplists:get_value(request_opts, Config, []),
+-    {error, {could_not_parse_as_http, _}} = httpc:request(get, Request, [{relaxed, false}, ?SSL_NO_VERIFY], RequestOpts),
++    {error, {headers_conflict, _}} = httpc:request(get, Request, [{relaxed, false}, ?SSL_NO_VERIFY], RequestOpts),
+     {ok,{{_,200,_},_,_}} = httpc:request(get, Request, [{relaxed, true}, ?SSL_NO_VERIFY], RequestOpts),
+     ok.
+ 
+@@ -2080,6 +2083,104 @@ def_ssl_opt(_Config) ->
+     ok.
+ 
+ %%-------------------------------------------------------------------------
++abnormal_header_size() ->
++    [{doc, "httpc has two options to protect against unreasonable amounts of"
++           "data to be parsed; namely max_header_size and max_body_size which"
++           "default to 10240 and nolimit"}].
++abnormal_header_size(Config) ->
++    RequestNormal = {url(group_name(Config), "/normal_header_size_restricted.html", Config), []},
++    RequestAbnormal = {url(group_name(Config), "/abnormal_header_size.html", Config), []},
++    RequestBoundary = {url(group_name(Config), "/boundary_header_size.html", Config), []},
++    RequestNormalBigBody = {url(group_name(Config), "/nomal_header_size_big_body.html", Config), []},
++    Profile = ?profile(Config),
++
++    %% Normal response passes with explicit max_header_size
++    {ok, {{_, 200, _}, _Headers, _Body}} =
++        httpc:request(get, RequestNormal,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, 4096}],
++                      Profile),
++    %% Rejected when max_header_size is artificially low
++    {error, {header_too_long, {max, 16}}} =
++        httpc:request(get, RequestNormal,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, 16}],
++                      Profile),
++    %% Abnormal response (>10240 total header bytes) rejected with default limit
++    {error, {header_too_long, {max, ?HTTP_MAX_HEADER_SIZE}}} =
++        httpc:request(get, RequestAbnormal,
++                      [?SSL_NO_VERIFY],
++                      [],
++                      Profile),
++    %% Boundary: one byte under limit fails, exactly at limit passes
++    {error, {header_too_long, _}} =
++        httpc:request(get, RequestBoundary,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, 135}],
++                      Profile),
++    {ok, {{_, 200, _}, _, _}} =
++        httpc:request(get, RequestBoundary,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, 136}],
++                      Profile),
++
++    %% max_body_size rejects oversized body
++    {error, body_too_big} =
++        httpc:request(get, RequestNormalBigBody,
++                      [?SSL_NO_VERIFY],
++                      [{max_body_size, 1000}],
++                      Profile),
++
++%% nolimit bypasses the check (backward compatibility)
++    {ok, {{_, 200, _}, _, _}} =
++        httpc:request(get, RequestAbnormal,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, nolimit},
++                       {body_format, binary}],
++                      Profile),
++    ok.
++
++%%-------------------------------------------------------------------------
++invalid_content_length() ->
++    [{doc, "Malformed Content-Length value is rejected during header parsing"}].
++invalid_content_length(Config) ->
++    Request = {url(group_name(Config), "/invalid_content_length.html", Config),
++               [{"connection", "close"}]},
++    Profile = ?profile(Config),
++    {error, {invalid_content_length, _}} =
++        httpc:request(get, Request, [?SSL_NO_VERIFY], [], Profile),
++    ok.
++
++%%-------------------------------------------------------------------------
++abnormal_trailer_size() ->
++    [{doc, "Chunked trailers are bounded by the same max_header_size option"}].
++abnormal_trailer_size(Config) ->
++    RequestNormal = {url(group_name(Config), "/chunked_trailer_normal.html", Config), []},
++    RequestAbnormal = {url(group_name(Config), "/chunked_trailer_abnormal.html", Config), []},
++    Profile = ?profile(Config),
++
++    %% Normal chunked response with small trailers passes
++    {ok, {{_, 200, _}, _Headers, _Body}} =
++        httpc:request(get, RequestNormal,
++                      [?SSL_NO_VERIFY],
++                      [],
++                      Profile),
++
++    %% Chunked response with oversized trailers rejected
++    {error, {header_too_long, {max, _}}} =
++        httpc:request(get, RequestAbnormal,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, 64}],
++                      Profile),
++
++    %% Same oversized trailers pass with nolimit
++    {ok, {{_, 200, _}, _, _}} =
++        httpc:request(get, RequestAbnormal,
++                      [?SSL_NO_VERIFY],
++                      [{max_header_size, nolimit}],
++                      Profile),
++    ok.
++
+ remote_socket_close_parallel() ->
+     [{doc,
+       "Verify remote socket closure (related tickets: OTP-18509, OTP-18545,"
+@@ -3166,6 +3267,62 @@ handle_uri(_,"/delete_no_body.html", _,Headers,_, DefaultResponse) ->
+ 	not_found ->
+ 	    DefaultResponse
+     end;
++handle_uri(_, "/normal_header_size_restricted.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Content-Length:150\r\n" ++
++    "Connection:close\r\n" ++
++    "\r\n" ++
++    lists:flatten(["OK " || _ <- lists:seq(1,50)]);
++
++handle_uri(_, "/boundary_header_size.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Content-Length:2\r\n" ++
++    "Connection:close\r\n" ++
++    "X-Pad:" ++ lists:duplicate(94, $A) ++ "\r\n" ++
++    "\r\n" ++
++    "OK";
++
++handle_uri(_, "/abnormal_header_size.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Content-Length:23\r\n" ++
++    "X-Pad:" ++ lists:duplicate(10241, $0) ++ "\r\n" ++
++    "Connection: close\r\n" ++
++    "\r\n" ++
++    "This should not be read";
++handle_uri(_, "/nomal_header_size_big_body.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Content-Length:20000\r\n" ++
++    "Connection:close\r\n" ++
++    "\r\n" ++
++    lists:duplicate(20000, $A);
++
++handle_uri(_, "/invalid_content_length.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Content-Length:abc\r\n" ++
++    "Connection:close\r\n" ++
++    "\r\n" ++
++    "body";
++
++handle_uri(_, "/chunked_trailer_normal.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Transfer-Encoding: chunked\r\n" ++
++    "Connection:close\r\n" ++
++    "\r\n" ++
++    "5\r\nhello\r\n" ++
++    "0\r\n" ++
++    "X-Checksum: abc123\r\n" ++
++    "\r\n";
++
++handle_uri(_, "/chunked_trailer_abnormal.html", _, _, _, _) ->
++    "HTTP/1.1 200 OK\r\n" ++
++    "Transfer-Encoding: chunked\r\n" ++
++    "Connection:close\r\n" ++
++    "\r\n" ++
++    "5\r\nhello\r\n" ++
++    "0\r\n" ++
++    "X-Huge:" ++ lists:duplicate(200, $B) ++ "\r\n" ++
++    "\r\n";
++
+ handle_uri(_,_,_,_,_,DefaultResponse) ->
+     DefaultResponse.
+ 
+diff --git a/lib/snmp/src/misc/snmp_pdus.erl b/lib/snmp/src/misc/snmp_pdus.erl
+index 1967c7078d..3f8c352974 100644
+--- a/lib/snmp/src/misc/snmp_pdus.erl
++++ b/lib/snmp/src/misc/snmp_pdus.erl
+@@ -265,7 +265,7 @@ dec_value([5,0 | T]) ->
+ 
+ %% INTEGER
+ dec_value([2 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes),
++    {Value, Rest} = dec_integer_notag(Bytes, 4), %% SMI INTEGER is 32-bit
+     {{'INTEGER', Value}, Rest};
+ 
+ %% OCTET STRING
+@@ -282,7 +282,7 @@ dec_value([64 | Bytes]) ->
+ dec_value([65 | Bytes]) ->
+     %% Counter32 is an unsigned 32 but is actually encoded as 
+     %% a signed integer 32 (INTEGER).
+-    {Value, Rest} = dec_integer_notag(Bytes),
++    {Value, Rest} = dec_integer_notag(Bytes, 5),
+     Value2 = 
+     	if
+     	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -298,7 +298,7 @@ dec_value([65 | Bytes]) ->
+ 
+ %% Unsigned32
+ dec_value([66 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes),
++    {Value, Rest} = dec_integer_notag(Bytes, 5),
+     Value2 = 
+ 	if 
+ 	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -312,7 +312,7 @@ dec_value([66 | Bytes]) ->
+ 
+ %% TimeTicks
+ dec_value([67 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes),
++    {Value, Rest} = dec_integer_notag(Bytes, 5),
+     Value2 = 
+ 	if
+ 	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -333,7 +333,7 @@ dec_value([68 | Bytes]) ->
+ dec_value([70 | Bytes]) ->
+     %% Counter64 is an unsigned 64 but is actually encoded as 
+     %% a signed integer 64.
+-    {Value, Rest} = dec_integer_notag(Bytes),
++    {Value, Rest} = dec_integer_notag(Bytes, 9),
+     Value2 = 
+     	if
+     	    (Value >= 0) andalso (Value < 16#8000000000000000) ->
+diff --git a/lib/stdlib/src/uri_string.erl b/lib/stdlib/src/uri_string.erl
+index 7d24a0dba9..c88ad981fc 100644
+--- a/lib/stdlib/src/uri_string.erl
++++ b/lib/stdlib/src/uri_string.erl
+@@ -1364,12 +1364,14 @@ calculate_parsed_query_fragment(Input, Unparsed) ->
+ 
+ get_port(<<>>) ->
+     undefined;
+-get_port(B) ->
++get_port(B) when byte_size(B) =< 5 ->
+     try binary_to_integer(B)
+     catch
+         error:badarg ->
+             throw({error, invalid_uri, B})
+-    end.
++    end;
++get_port(B) ->
++    throw({error, invalid_uri, B}).
+ 
+ 
+ %% Strip last char if it is in list

diff --git a/otp-0028-snmp-Bound-integer-parsing-in-the-BER-decoder.patch b/otp-0028-snmp-Bound-integer-parsing-in-the-BER-decoder.patch
new file mode 100644
index 0000000..73688e0
--- /dev/null
+++ b/otp-0028-snmp-Bound-integer-parsing-in-the-BER-decoder.patch
@@ -0,0 +1,672 @@
+From: Konrad Pietrzak <konrad@erlang.org>
+Date: Wed, 30 Sep 2026 15:06:20 +0200
+Subject: [PATCH] snmp: Bound integer parsing in the BER decoder
+
+Bounding the varbind value types was only half the job. Every
+dec_int_tag/1 call site was still unbounded, so the v3 header fields, the
+USM security parameters and all PDU integer fields accepted an arbitrary
+number of BER content octets and built a bignum from them.
+msgAuthoritativeEngineBoots and msgAuthoritativeEngineTime are parsed
+before the message is authenticated, so that input is reachable pre-auth.
+
+Give every integer field the content octet limit its type implies, named
+after the type rather than spelled as a literal: four octets for the
+INTEGER (0..2147483647) and Integer32 fields, five for the unsigned 32-bit
+types, nine for Counter64. Remove the unlimited dec_int_tag/1 and
+dec_integer_notag/1 wrappers so no call site can silently omit a limit,
+and with them the infinity clause of dec_integer_notag/2, which is
+unreachable once every caller passes a limit.
+
+Signal a violation with exit rather than throw. All callers wrap decoding
+in (catch ...) and match {'EXIT', Reason}; a thrown term is returned bare
+and matched neither clause, so an over-long integer produced a case_clause
+in snmpa_mpd instead of a discarded packet and an snmpInASNParseErrs
+increment. Fields that re-tag the failure keep the {Size, Limit} pair and
+use a distinct _bytesize suffix, so a length violation cannot be confused
+with the value rejections from chk_msg_id/1 and friends.
+
+dec_Counter64/2 had a second, separate signalling bug: it reported an
+over-long Counter64 as throw({exit, {bad_counter64_length, BadSize}}), a
+term no caller can match on either count. It now exits with the same
+{bad_integer, {Size, Limit}} reason as every other integer field.
+
+The chk_msg_id/1, chk_msg_max_size/1 and chk_msg_sec_model/1 range checks
+are kept alongside the new limits. An octet cap is not a range check: four
+legal octets still encode a negative msgID, and one octet still encodes a
+msgMaxSize below the RFC 3412 floor of 484.
+
+Related: GHSA-8qw4-2chm-mvj2
+Aux Id: OTP-20346
+
+Part of the fix for CVE-2026-59696.
+
+(cherry picked from commit 2cf26f2238c904f5e7a621b971442e2c7b77db1a)
+
+[Backport to OTP 26: OTP 26 has no dec_Counter64/snmp_pdus_basic codec
+and decodes Counter64 inline, so the dec_Counter64/2 change is replaced
+by using ?UINT64_MAX_OCTETS for the inline Counter64 limit added by the
+previous commit. All other hunks ported as-is.]
+
+Co-Authored-By: Claude Opus 5.5 <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 3f8c352974..2d12e1c31b 100644
+--- a/lib/snmp/src/misc/snmp_pdus.erl
++++ b/lib/snmp/src/misc/snmp_pdus.erl
+@@ -26,6 +26,16 @@
+ -define(VMODULE,"PDUS").
+ -include("snmp_verbosity.hrl").
+ 
++%% Maximum number of content octets accepted for a BER-encoded integer.
++%% Each value is the minimal BER length of the largest legal value of the
++%% type. Unsigned types need one octet more than their width, for the
++%% leading zero that keeps the value positive.
++-define(INT32_MAX_OCTETS,   4).  %% ASN.1 INTEGER / Integer32 and every
++                                 %% INTEGER (0..2147483647) field
++-define(UINT32_MAX_OCTETS,  5).  %% Counter32, Gauge32/Unsigned32, TimeTicks
++-define(UINT64_MAX_OCTETS,  9).  %% Counter64
++-define(VERSION_MAX_OCTETS, 10). %% msgVersion -- deliberately generous
++
+ %% See RFC1155, RFC1157, RFC1901, RFC1902, RFC1905, RFC2272
+ 
+ 
+@@ -67,11 +77,11 @@ dec_message_only([48 | Bytes]) ->
+     end.
+ 
+ dec_snmp_version(Bytes) ->
+-    case (catch dec_int_tag(Bytes, 10)) of
+-	{error, {bad_integer, BadInt}} ->
+-	    exit({bad_version, BadInt});
++    case (catch dec_int_tag(Bytes, ?VERSION_MAX_OCTETS)) of
+ 	{SNMPversion, Rest} when is_integer(SNMPversion) andalso is_list(Rest) ->
+ 	    {dec_snmp_ver(SNMPversion), Rest};
++        {'EXIT', {error, {bad_integer, BadInt}}} ->
++	    exit({bad_version, BadInt});
+ 	{'EXIT', Reason} ->
+ 	    exit(Reason)
+     end.
+@@ -99,12 +109,18 @@ dec_rest_v3_msg_only([48 | Bytes]) -> % starts with header data sequence
+     {Size, Tail} = dec_len(Bytes),
+     {HBytes, Bytes1} = split_at(Tail, Size, []),
+     %% Decode HeaderData
+-    {MsgID, HBytes1} = dec_int_tag(HBytes),
++    {MsgID, HBytes1} = try dec_int_tag(HBytes, ?INT32_MAX_OCTETS)
++                       catch exit:{error, {bad_integer, BadSizeMsgId}} -> exit({bad_msg_id_bytesize, BadSizeMsgId})
++                       end,
+     chk_msg_id(MsgID),
+-    {MsgMaxSize, HBytes2} = dec_int_tag(HBytes1),
++    {MsgMaxSize, HBytes2} = try dec_int_tag(HBytes1, ?INT32_MAX_OCTETS)
++                            catch exit:{error, {bad_integer, BadSizeMaxSize}} -> exit({bad_msg_max_size_bytesize, BadSizeMaxSize})
++                            end,
+     chk_msg_max_size(MsgMaxSize),
+     {MsgFlags, HBytes3} = dec_oct_str_tag(HBytes2),
+-    {MsgSecurityModel, []} = dec_int_tag(HBytes3),
++    {MsgSecurityModel, []} = try dec_int_tag(HBytes3, ?INT32_MAX_OCTETS)
++                             catch exit:{error, {bad_integer, BadSizeSecModel}} -> exit({bad_sec_model_bytesize, BadSizeSecModel})
++                             end,
+     chk_msg_sec_model(MsgSecurityModel),
+     %% Continue with Message
+ %    {MsgSecurityParameters, Bytes2} = dec_oct_str_tag(Bytes1),
+@@ -176,8 +192,8 @@ dec_pdu([164 | Bytes]) ->      % It's a trap
+     Bytes2 = get_data_bytes(Bytes),
+     {Enterprise, Rest1} = dec_oid_tag(Bytes2),
+     {{'IpAddress', [_, _, _, _] = AgentAddr}, Rest2} = dec_value(Rest1),
+-    {GenericTrap, Rest3} = dec_int_tag(Rest2),
+-    {SpecificTrap, Rest4} = dec_int_tag(Rest3),
++    {GenericTrap, Rest3} = dec_int_tag(Rest2, ?INT32_MAX_OCTETS),
++    {SpecificTrap, Rest4} = dec_int_tag(Rest3, ?INT32_MAX_OCTETS),
+     {{'TimeTicks', TimeStamp}, VBBytes} = dec_value(Rest4),
+     VBs = dec_VBs(VBBytes),
+     #trappdu{enterprise = Enterprise, agent_addr = AgentAddr,
+@@ -186,9 +202,9 @@ dec_pdu([164 | Bytes]) ->      % It's a trap
+ 
+ dec_pdu([165 | Bytes]) ->    % Bulk
+     Bytes2 = get_data_bytes(Bytes),
+-    {RequestID, Rest1} = dec_int_tag(Bytes2),
+-    {NonRepeaters, Rest2} = dec_int_tag(Rest1),
+-    {MaxRepetitions,VBbytes} = dec_int_tag(Rest2),
++    {RequestID, Rest1} = dec_int_tag(Bytes2, ?INT32_MAX_OCTETS),
++    {NonRepeaters, Rest2} = dec_int_tag(Rest1, ?INT32_MAX_OCTETS),
++    {MaxRepetitions,VBbytes} = dec_int_tag(Rest2, ?INT32_MAX_OCTETS),
+     VBs = dec_VBs(VBbytes),
+     #pdu{type = 'get-bulk-request', request_id = RequestID,
+ 	 error_status = NonRepeaters, error_index = MaxRepetitions,
+@@ -197,15 +213,15 @@ dec_pdu([165 | Bytes]) ->    % Bulk
+ dec_pdu([PduTag | Bytes]) ->
+     Type = dec_pdu_tag(PduTag),
+     Bytes2 = get_data_bytes(Bytes),
+-    {RequestID, Rest1} = dec_int_tag(Bytes2),
+-    {ErrStat, Rest2} = dec_int_tag(Rest1),
++    {RequestID, Rest1} = dec_int_tag(Bytes2, ?INT32_MAX_OCTETS),
++    {ErrStat, Rest2} = dec_int_tag(Rest1, ?INT32_MAX_OCTETS),
+     ErrStatus = case lists:keysearch(ErrStat, 2, errMsgs()) of
+ 		    {value, {ErrStatName, _ErrStat}} ->
+ 			ErrStatName;
+ 		    false ->
+ 			ErrStat
+ 		end,
+-    {ErrIndex, VarbindsBytes} = dec_int_tag(Rest2),
++    {ErrIndex, VarbindsBytes} = dec_int_tag(Rest2, ?INT32_MAX_OCTETS),
+     VBs = dec_VBs(VarbindsBytes),
+     #pdu{type = Type, request_id = RequestID, error_status = ErrStatus,
+ 	 error_index = ErrIndex, varbinds = VBs}.
+@@ -231,8 +247,14 @@ dec_individual_VBs([48 | Bytes], OrgIndex, AccVBs) ->
+ dec_usm_security_parameters([48 | Bytes1]) ->
+     {_Len, Bytes2} = dec_len(Bytes1),
+     {MsgAuthEngineID, Bytes3} = dec_oct_str_tag(Bytes2),
+-    {MsgAuthEngineBoots, Bytes4} = dec_int_tag(Bytes3),
+-    {MsgAuthEngineTime, Bytes5} = dec_int_tag(Bytes4),
++    {MsgAuthEngineBoots, Bytes4} = try dec_int_tag(Bytes3, ?INT32_MAX_OCTETS)
++                                   catch
++                                           exit:{error, {bad_integer, SizeBoots}} -> exit({bad_engine_boots_bytesize, SizeBoots})
++                                   end,
++    {MsgAuthEngineTime, Bytes5} = try dec_int_tag(Bytes4, ?INT32_MAX_OCTETS)
++                                  catch
++                                        exit:{error, {bad_integer, SizeTime}} -> exit({bad_engine_time_bytesize, SizeTime})
++                                  end,
+     {MsgUserName, Bytes6} = dec_oct_str_tag(Bytes5),
+     {MsgAuthParams, Bytes7} = dec_oct_str_tag(Bytes6),
+     {MsgPrivParams, []} = dec_oct_str_tag(Bytes7),
+@@ -265,7 +287,7 @@ dec_value([5,0 | T]) ->
+ 
+ %% INTEGER
+ dec_value([2 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes, 4), %% SMI INTEGER is 32-bit
++    {Value, Rest} = dec_integer_notag(Bytes, ?INT32_MAX_OCTETS), %% SMI INTEGER is 32-bit
+     {{'INTEGER', Value}, Rest};
+ 
+ %% OCTET STRING
+@@ -282,7 +304,7 @@ dec_value([64 | Bytes]) ->
+ dec_value([65 | Bytes]) ->
+     %% Counter32 is an unsigned 32 but is actually encoded as 
+     %% a signed integer 32 (INTEGER).
+-    {Value, Rest} = dec_integer_notag(Bytes, 5),
++    {Value, Rest} = dec_integer_notag(Bytes, ?UINT32_MAX_OCTETS),
+     Value2 = 
+     	if
+     	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -298,7 +320,7 @@ dec_value([65 | Bytes]) ->
+ 
+ %% Unsigned32
+ dec_value([66 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes, 5),
++    {Value, Rest} = dec_integer_notag(Bytes, ?UINT32_MAX_OCTETS),
+     Value2 = 
+ 	if 
+ 	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -312,7 +334,7 @@ dec_value([66 | Bytes]) ->
+ 
+ %% TimeTicks
+ dec_value([67 | Bytes]) ->
+-    {Value, Rest} = dec_integer_notag(Bytes, 5),
++    {Value, Rest} = dec_integer_notag(Bytes, ?UINT32_MAX_OCTETS),
+     Value2 = 
+ 	if
+ 	    (Value >= 0) andalso (Value =< 16#ffffffff) ->
+@@ -333,7 +355,7 @@ dec_value([68 | Bytes]) ->
+ dec_value([70 | Bytes]) ->
+     %% Counter64 is an unsigned 64 but is actually encoded as 
+     %% a signed integer 64.
+-    {Value, Rest} = dec_integer_notag(Bytes, 9),
++    {Value, Rest} = dec_integer_notag(Bytes, ?UINT64_MAX_OCTETS),
+     Value2 = 
+     	if
+     	    (Value >= 0) andalso (Value < 16#8000000000000000) ->
+@@ -375,22 +397,16 @@ split_at([H|T], N, Acc) ->
+ %% All decoding routines return: {Data, RestBytes}
+ %%----------------------------------------------------------------------
+ 
+-dec_int_tag([2 | Bytes]) ->
+-    dec_integer_notag(Bytes).
+ dec_int_tag([2 | Bytes], SizeLimit) ->
+     dec_integer_notag(Bytes, SizeLimit).
+ 
+-dec_integer_notag(Ints) ->
+-    dec_integer_notag(Ints, infinity).
+ dec_integer_notag(Ints, SizeLimit) ->
+     case dec_len(Ints) of
+-	{Size, Ints2} when SizeLimit =:= infinity ->
+-	    do_dec_integer_notag(Size, Ints2);
+ 	{Size, Ints2} when (is_integer(SizeLimit) andalso 
+ 			    (Size =< SizeLimit)) ->
+ 	    do_dec_integer_notag(Size, Ints2);
+ 	{BadSize, _BadInts2} ->
+-	    throw({error, {bad_integer, {BadSize, SizeLimit}}})
++	    exit({error, {bad_integer, {BadSize, SizeLimit}}})
+     end.
+ 
+ do_dec_integer_notag(Size, Ints) ->
+diff --git a/lib/snmp/test/snmp_pdus_SUITE.erl b/lib/snmp/test/snmp_pdus_SUITE.erl
+index d70e7aebd0..37b2f73f5e 100644
+--- a/lib/snmp/test/snmp_pdus_SUITE.erl
++++ b/lib/snmp/test/snmp_pdus_SUITE.erl
+@@ -29,6 +29,7 @@
+ %%----------------------------------------------------------------------
+ -include_lib("common_test/include/ct.hrl").
+ -include("snmp_test_lib.hrl").
++-define(SNMP_USE_V3, true).
+ -include_lib("snmp/include/snmp_types.hrl").
+ 
+ 
+@@ -45,7 +46,13 @@
+ 	 otp7575/1,
+ 	 otp8563/1, 
+ 	 otp9022/1, 
+-	 otp10132/1
++	 otp10132/1,
++
++         dec_value_int_size_limits/1,
++         dec_pdu_int_size_limits/1,
++         dec_v3_hdr_int_size_limits/1,
++         dec_v3_hdr_value_checks/1,
++         dec_usm_sec_params_int_size_limits/1
+ 	]).
+ 
+ 
+@@ -57,10 +64,12 @@ suite() ->
+     [{ct_hooks, [ts_install_cth]}].
+ 
+ all() -> 
+-    [{group, tickets}].
++    [{group, tickets},
++     {group, ber_limits}].
+ 
+ groups() -> 
+-    [{tickets, [], tickets_cases()}].
++    [{tickets,    [], tickets_cases()},
++     {ber_limits, [], ber_limits_cases()}].
+ 
+ tickets_cases() ->
+     [
+@@ -70,6 +79,15 @@ tickets_cases() ->
+      otp10132
+     ].
+ 
++ber_limits_cases() ->
++    [
++     dec_value_int_size_limits,
++     dec_pdu_int_size_limits,
++     dec_v3_hdr_int_size_limits,
++     dec_v3_hdr_value_checks,
++     dec_usm_sec_params_int_size_limits
++    ].
++
+ 
+ %%
+ %% -----
+@@ -387,6 +405,287 @@ otp10132(Config) when is_list(Config) ->
+     ok.
+ 
+ 
++%%======================================================================
++%% BER integer content octet limits
++%%======================================================================
++
++%% snmp_pdus caps the number of BER content octets accepted for every
++%% integer-valued field (?INT32_MAX_OCTETS and friends). The cases below
++%% pin, for each field, the largest accepted encoding and the rejection of
++%% one octet more.
++%%
++%% They also pin that the rejection is an *exit*. It used to be a throw,
++%% which slipped through the (catch ...) wrappers in snmpa_mpd -- e.g.
++%% around dec_scoped_pdu/1 in v3_proc/6 -- and produced a case_clause
++%% instead of a discarded packet. dec_class/1 reports the exception class,
++%% so a regression back to throw fails the case instead of passing
++%% silently.
++
++dec_value_int_size_limits(suite) -> [];
++dec_value_int_size_limits(doc) ->
++    ["Content octet limits for the integer types decoded by dec_value/1"];
++dec_value_int_size_limits(Config) when is_list(Config) ->
++    %% {Type, BER tag, max content octets}. The unsigned types allow one
++    %% octet more than their width, for the leading zero that keeps the
++    %% value positive.
++    Types = [{'INTEGER',    2,  4},
++             {'Counter32',  65, 5},
++             {'Unsigned32', 66, 5},
++             {'TimeTicks',  67, 5},
++             {'Counter64',  70, 9}],
++    lists:foreach(
++      fun({Type, Tag, Max}) ->
++              ?IPRINT("~w: ~w content octets is accepted", [Type, Max]),
++              case snmp_pdus:dec_value(padded_value(Tag, Max)) of
++                  {{Type, 1}, []} ->
++                      ok;
++                  UnexpectedOk ->
++                      exit({unexpected_decode_result, Type, Max, UnexpectedOk})
++              end,
++
++              ?IPRINT("~w: ~w content octets is rejected", [Type, Max + 1]),
++              case dec_class(fun() ->
++                                     snmp_pdus:dec_value(
++                                       padded_value(Tag, Max + 1))
++                             end) of
++                  {exit, {error, {bad_integer, {Bad, Max}}}} when Bad =:= Max + 1 ->
++                      ok;
++                  Unexpected ->
++                      exit({unexpected_decode_result, Type, Max + 1, Unexpected})
++              end
++      end, Types),
++    ?IPRINT("done"),
++    ok.
++
++
++dec_pdu_int_size_limits(suite) -> [];
++dec_pdu_int_size_limits(doc) ->
++    ["Content octet limits for the integer fields of PDU, BulkPDU and TrapPDU"];
++dec_pdu_int_size_limits(Config) when is_list(Config) ->
++    %% RFC 3416: request-id is INTEGER (-2147483648..2147483647) and
++    %% error-index, non-repeaters and max-repetitions are
++    %% INTEGER (0..max-bindings) with max-bindings = 2147483647 -- so four
++    %% content octets each.
++    ?IPRINT("get-request: a well formed PDU decodes"),
++    #pdu{type         = 'get-request',
++         request_id   = 1,
++         error_status = noError,
++         error_index  = 0,
++         varbinds     = []} =
++        snmp_pdus:dec_pdu(pdu(160, [int_tlv(1, 4),
++                                    int_tlv(0, 1),
++                                    int_tlv(0, 1)])),
++
++    ?IPRINT("get-request: request-id with 5 content octets is rejected"),
++    expect_bad_integer(request_id, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(pdu(160, [int_tlv(1, 5),
++                                                           int_tlv(0, 1),
++                                                           int_tlv(0, 1)]))
++                       end),
++
++    %% error-status is an enumerated INTEGER (noError(0)..inconsistentName(18)),
++    %% so one content octet carries every legal value. The exact cap is not
++    %% pinned here -- only that a grossly oversized encoding is rejected --
++    %% because unrecognised values are deliberately passed through by
++    %% dec_pdu/1 and the cap may be tightened without changing behaviour.
++    ?IPRINT("get-request: error-status with 8 content octets is rejected"),
++    case dec_class(fun() ->
++                           snmp_pdus:dec_pdu(pdu(160, [int_tlv(1, 1),
++                                                       int_tlv(0, 8),
++                                                       int_tlv(0, 1)]))
++                   end) of
++        {exit, {error, {bad_integer, {8, _}}}} ->
++            ok;
++        UnexpectedErrStatus ->
++            exit({unexpected_decode_result, error_status, UnexpectedErrStatus})
++    end,
++
++    ?IPRINT("get-request: error-index with 5 content octets is rejected"),
++    expect_bad_integer(error_index, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(pdu(160, [int_tlv(1, 1),
++                                                           int_tlv(0, 1),
++                                                           int_tlv(0, 5)]))
++                       end),
++
++    ?IPRINT("get-bulk-request: a well formed PDU decodes"),
++    #pdu{type         = 'get-bulk-request',
++         request_id   = 1,
++         error_status = 0,
++         error_index  = 10,
++         varbinds     = []} =
++        snmp_pdus:dec_pdu(pdu(165, [int_tlv(1, 4),
++                                    int_tlv(0, 1),
++                                    int_tlv(10, 1)])),
++
++    ?IPRINT("get-bulk-request: non-repeaters with 5 content octets is rejected"),
++    expect_bad_integer(non_repeaters, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(pdu(165, [int_tlv(1, 1),
++                                                           int_tlv(0, 5),
++                                                           int_tlv(0, 1)]))
++                       end),
++
++    ?IPRINT("get-bulk-request: max-repetitions with 5 content octets is rejected"),
++    expect_bad_integer(max_repetitions, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(pdu(165, [int_tlv(1, 1),
++                                                           int_tlv(0, 1),
++                                                           int_tlv(0, 5)]))
++                       end),
++
++    ?IPRINT("trap: a well formed TrapPDU decodes"),
++    #trappdu{generic_trap  = 6,
++             specific_trap = 1,
++             time_stamp    = 0,
++             varbinds      = []} =
++        snmp_pdus:dec_pdu(trap_pdu(int_tlv(6, 1), int_tlv(1, 4))),
++
++    ?IPRINT("trap: generic-trap with 5 content octets is rejected"),
++    expect_bad_integer(generic_trap, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(
++                                 trap_pdu(int_tlv(6, 5), int_tlv(1, 1)))
++                       end),
++
++    ?IPRINT("trap: specific-trap with 5 content octets is rejected"),
++    expect_bad_integer(specific_trap, {5, 4},
++                       fun() ->
++                               snmp_pdus:dec_pdu(
++                                 trap_pdu(int_tlv(6, 1), int_tlv(1, 5)))
++                       end),
++
++    ?IPRINT("done"),
++    ok.
++
++
++dec_v3_hdr_int_size_limits(suite) -> [];
++dec_v3_hdr_int_size_limits(doc) ->
++    ["Content octet limits for the v3 header data integer fields"];
++dec_v3_hdr_int_size_limits(Config) when is_list(Config) ->
++    %% RFC 3412: msgID and msgMaxSize are INTEGER (0..2147483647) and
++    %% msgSecurityModel is INTEGER (1..2147483647) -- four content octets.
++    ?IPRINT("the largest legal msgID is accepted"),
++    #message{version = 'version-3',
++             vsn_hdr = #v3_hdr{msgID            = 2147483647,
++                               msgMaxSize       = 484,
++                               msgSecurityModel = 3}} =
++        snmp_pdus:dec_message_only(v3_msg([raw_int_tlv([127, 255, 255, 255]),
++                                           v3_msg_max_size_tlv(),
++                                           v3_msg_flags_tlv(),
++                                           v3_sec_model_tlv()])),
++
++    ?IPRINT("msgID with 5 content octets is rejected"),
++    expect_exit(msg_id, {bad_msg_id_bytesize, {5, 4}},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([int_tlv(1, 5),
++                                  v3_msg_max_size_tlv(),
++                                  v3_msg_flags_tlv(),
++                                  v3_sec_model_tlv()]))
++                end),
++
++    ?IPRINT("msgMaxSize with 5 content octets is rejected"),
++    expect_exit(msg_max_size, {bad_msg_max_size_bytesize, {5, 4}},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([int_tlv(1, 1),
++                                  int_tlv(1, 5),
++                                  v3_msg_flags_tlv(),
++                                  v3_sec_model_tlv()]))
++                end),
++
++    ?IPRINT("msgSecurityModel with 5 content octets is rejected"),
++    expect_exit(msg_sec_model, {bad_sec_model_bytesize, {5, 4}},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([int_tlv(1, 1),
++                                  v3_msg_max_size_tlv(),
++                                  v3_msg_flags_tlv(),
++                                  int_tlv(1, 5)]))
++                end),
++
++    ?IPRINT("done"),
++    ok.
++
++
++dec_v3_hdr_value_checks(suite) -> [];
++dec_v3_hdr_value_checks(doc) ->
++    ["Range checks on the v3 header data integer fields are applied in "
++     "addition to the content octet limits"];
++dec_v3_hdr_value_checks(Config) when is_list(Config) ->
++    %% A content octet limit is not a range check: four octets still encode
++    %% 16#80000000, and one octet still encodes a msgMaxSize below the
++    %% RFC 3412 floor of 484. chk_msg_id/1, chk_msg_max_size/1 and
++    %% chk_msg_sec_model/1 must keep rejecting those.
++    ?IPRINT("a negative msgID is rejected"),
++    expect_exit(msg_id, {bad_msg_id, -2147483648},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([raw_int_tlv([128, 0, 0, 0]),
++                                  v3_msg_max_size_tlv(),
++                                  v3_msg_flags_tlv(),
++                                  v3_sec_model_tlv()]))
++                end),
++
++    ?IPRINT("a msgMaxSize below 484 is rejected"),
++    expect_exit(msg_max_size, {bad_msg_max_size, 100},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([int_tlv(1, 1),
++                                  int_tlv(100, 1),
++                                  v3_msg_flags_tlv(),
++                                  v3_sec_model_tlv()]))
++                end),
++
++    ?IPRINT("a negative msgSecurityModel is rejected"),
++    expect_exit(msg_sec_model, {bad_msg_sec_model, -1},
++                fun() ->
++                        snmp_pdus:dec_message_only(
++                          v3_msg([int_tlv(1, 1),
++                                  v3_msg_max_size_tlv(),
++                                  v3_msg_flags_tlv(),
++                                  raw_int_tlv([255])]))
++                end),
++
++    ?IPRINT("done"),
++    ok.
++
++
++dec_usm_sec_params_int_size_limits(suite) -> [];
++dec_usm_sec_params_int_size_limits(doc) ->
++    ["Content octet limits for msgAuthoritativeEngineBoots and "
++     "msgAuthoritativeEngineTime"];
++dec_usm_sec_params_int_size_limits(Config) when is_list(Config) ->
++    %% RFC 3414: both fields are INTEGER (0..2147483647) -- four content
++    %% octets. They are parsed before the message is authenticated, so an
++    %% unbounded encoding here is reachable pre-auth.
++    ?IPRINT("well formed security parameters decode"),
++    #usmSecurityParameters{msgAuthoritativeEngineID    = "",
++                           msgAuthoritativeEngineBoots = 1,
++                           msgAuthoritativeEngineTime  = 2} =
++        snmp_pdus:dec_usm_security_parameters(usm_params(int_tlv(1, 4),
++                                                        int_tlv(2, 4))),
++
++    ?IPRINT("msgAuthoritativeEngineBoots with 5 content octets is rejected"),
++    expect_exit(engine_boots, {bad_engine_boots_bytesize, {5, 4}},
++                fun() ->
++                        snmp_pdus:dec_usm_security_parameters(
++                          usm_params(int_tlv(1, 5), int_tlv(2, 1)))
++                end),
++
++    ?IPRINT("msgAuthoritativeEngineTime with 5 content octets is rejected"),
++    expect_exit(engine_time, {bad_engine_time_bytesize, {5, 4}},
++                fun() ->
++                        snmp_pdus:dec_usm_security_parameters(
++                          usm_params(int_tlv(1, 1), int_tlv(2, 5)))
++                end),
++
++    ?IPRINT("done"),
++    ok.
++
++
+ %%======================================================================
+ %% Internal functions
+ %%======================================================================
+@@ -394,3 +693,86 @@ otp10132(Config) when is_list(Config) ->
+ dec_message(B) when is_binary(B) ->
+     L = binary_to_list(B),
+     snmp_pdus:dec_message(L).
++
++
++%% -----
++%% Exception helpers
++%%
++%% dec_class/1 reports the exception class alongside the reason, so that a
++%% throw cannot pass for an exit.
++
++dec_class(Fun) ->
++    try Fun() of
++        Result ->
++            {ok, Result}
++    catch
++        Class:Reason ->
++            {Class, Reason}
++    end.
++
++expect_exit(Field, Reason, Fun) ->
++    case dec_class(Fun) of
++        {exit, Reason} ->
++            ok;
++        Unexpected ->
++            exit({unexpected_decode_result, Field, Reason, Unexpected})
++    end.
++
++expect_bad_integer(Field, SizeAndLimit, Fun) ->
++    expect_exit(Field, {error, {bad_integer, SizeAndLimit}}, Fun).
++
++
++%% -----
++%% BER encoding helpers
++%%
++%% All lengths stay below 128, so a single octet length is always enough.
++
++%% INTEGER TLV carrying Value in exactly Size content octets, zero padded.
++%% Padding is what the content octet limits exist to bound, so these
++%% encodings are intentionally non-minimal.
++int_tlv(Value, Size) when is_integer(Value), Value >= 0, Value < 128,
++                         is_integer(Size), Size >= 1 ->
++    raw_int_tlv(lists:duplicate(Size - 1, 0) ++ [Value]).
++
++raw_int_tlv(Octets) ->
++    [2, length(Octets) | Octets].
++
++%% TLV for one of the integer valued application types: Size content
++%% octets encoding the value 1.
++padded_value(Tag, Size) when is_integer(Size), Size >= 1 ->
++    [Tag, Size | lists:duplicate(Size - 1, 0) ++ [1]].
++
++%% Minimal v3 message for dec_message_only/1: version, a header data
++%% sequence built from the supplied TLVs, and empty msgSecurityParameters.
++v3_msg(HdrDataTLVs) ->
++    HdrData = lists:append(HdrDataTLVs),
++    HdrSeq  = [48, length(HdrData) | HdrData],
++    Content = raw_int_tlv([3]) ++ HdrSeq ++ [4, 0],
++    [48, length(Content) | Content].
++
++v3_msg_max_size_tlv() ->
++    raw_int_tlv([1, 228]).                      % 484, the RFC 3412 minimum
++
++v3_msg_flags_tlv() ->
++    [4, 1, 4].                                  % reportable, noAuthNoPriv
++
++v3_sec_model_tlv() ->
++    raw_int_tlv([3]).                           % USM
++
++%% USM security parameters with an empty engine ID, user name, and
++%% authentication and privacy parameters.
++usm_params(BootsTLV, TimeTLV) ->
++    Content = [4, 0] ++ BootsTLV ++ TimeTLV ++ [4, 0] ++ [4, 0] ++ [4, 0],
++    [48, length(Content) | Content].
++
++%% PDU with the three supplied integer TLVs and an empty varbind list.
++pdu(Tag, IntTLVs) ->
++    Content = lists:append(IntTLVs) ++ [48, 0],
++    [Tag, length(Content) | Content].
++
++%% TrapPDU with enterprise 1.3, agent-addr 127.0.0.1, time-stamp 0 and an
++%% empty varbind list.
++trap_pdu(GenericTLV, SpecificTLV) ->
++    Content = [6, 1, 43] ++ [64, 4, 127, 0, 0, 1] ++
++              GenericTLV ++ SpecificTLV ++ [67, 1, 0] ++ [48, 0],
++    [164, length(Content) | Content].

diff --git a/otp-0029-ssl-Check-SNI-in-TLS-1.2-session-reuse.patch b/otp-0029-ssl-Check-SNI-in-TLS-1.2-session-reuse.patch
new file mode 100644
index 0000000..fd4b68d
--- /dev/null
+++ b/otp-0029-ssl-Check-SNI-in-TLS-1.2-session-reuse.patch
@@ -0,0 +1,701 @@
+From: Ingela Anderton Andin <ingela@erlang.org>
+Date: Wed, 7 Oct 2026 15:28:54 +0200
+Subject: [PATCH] ssl: Check SNI in TLS-1.2 session reuse
+
+Fixes CVE-2026-105236.
+
+(cherry picked from commit 10ee925d0fee8413f1170cc21bfcf123c8d22454)
+
+[Backport to OTP 26: OTP 26 has no tls_dtls_server_connection.erl; the
+server-side session registration lives in tls_dtls_connection.erl, so
+the SNI hostname is recorded there instead (the private
+handle_session/6 is renamed maybe_register_session/7, as upstream, to
+avoid clashing with the exported handle_session/7). select_session/9
+becomes select_session/10 since OTP 26 still passes Compressions.
+Dropped the unrelated DTLS ClientHello version-decoding change in
+dtls_handshake:decode_handshake/3 and the session_server_restart test
+case, which does not exist in OTP 26. Without that DTLS change OTP 26
+cannot negotiate rsa_pss_rsae-only signature algorithms over DTLS 1.2,
+so openssl_sni_SUITE keeps forcing them for TLS only and runs the new
+sni_cross_ca_no_session_reuse case in the tlsv1.2 group only (upstream
+ssl_session_SUITE likewise skips it for DTLS).]
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/lib/ssl/src/dtls_handshake.erl b/lib/ssl/src/dtls_handshake.erl
+index a93adb5287..710dde572d 100644
+--- a/lib/ssl/src/dtls_handshake.erl
++++ b/lib/ssl/src/dtls_handshake.erl
+@@ -198,7 +198,7 @@ handle_client_hello(Version,
+ 	    {Type, #session{cipher_suite = CipherSuite,
+                             own_certificates = [OwnCert |_]} = Session1}
+ 		= ssl_handshake:select_session(SugesstedId, CipherSuites, 
+-                                               AvailableHashSigns, Compressions,
++                                               AvailableHashSigns, Compressions, HelloExt,
+ 					       SessIdTracker, Session0#session{ecc = ECCCurve}, TLSVersion,
+ 					       SslOpts, CertKeyPairs),
+ 	    case CipherSuite of
+diff --git a/lib/ssl/src/ssl_handshake.erl b/lib/ssl/src/ssl_handshake.erl
+index 65f47eb963..59611e50c4 100644
+--- a/lib/ssl/src/ssl_handshake.erl
++++ b/lib/ssl/src/ssl_handshake.erl
+@@ -70,7 +70,7 @@
+ 
+ %% Cipher suites handling
+ -export([available_suites/2, available_signature_algs/2,  available_signature_algs/3,
+-         cipher_suites/3, select_session/9,
++         cipher_suites/3, select_session/10,
+          premaster_secret/2, premaster_secret/3, premaster_secret/4]).
+ 
+ %% Extensions handling
+@@ -1067,10 +1067,12 @@ cipher_suites(Suites, false) ->
+ cipher_suites(Suites, true) ->
+     Suites.
+ 
+-select_session(SuggestedSessionId, CipherSuites, HashSigns, Compressions, SessIdTracker, Session0, Version, SslOpts, CertKeyAlts) ->
++select_session(SuggestedSessionId, CipherSuites, HashSigns, Compressions, HelloExt,
++               SessIdTracker, Session0, Version, SslOpts, CertKeyAlts) ->
+     CertKeyPairs = ssl_certificate:available_cert_key_pairs(CertKeyAlts, Version),
+-    {SessionId, Resumed} = ssl_session:server_select_session(Version, SessIdTracker, SuggestedSessionId,
+-                                                             SslOpts, CertKeyPairs),
++    {SessionId, Resumed} =
++        ssl_session:server_select_session(Version, SessIdTracker, SuggestedSessionId,
++                                          HelloExt, SslOpts, CertKeyPairs),
+     case Resumed of
+         undefined ->
+             %% Select Cert
+diff --git a/lib/ssl/src/ssl_handshake.hrl b/lib/ssl/src/ssl_handshake.hrl
+index ada0c774d5..857c3b3443 100644
+--- a/lib/ssl/src/ssl_handshake.hrl
++++ b/lib/ssl/src/ssl_handshake.hrl
+@@ -51,7 +51,8 @@
+                   time_stamp,
+                   ecc,                   %% TLS 1.3 Group
+                   sign_alg,              %% TLS 1.3 Signature Algorithm
+-                  dh_public_value        %% TLS 1.3 DH Public Value from peer
++                  dh_public_value,       %% TLS 1.3 DH Public Value from peer
++                  sni                    %% SNI hostname
+                  }).
+ 
+ -define(EMPTY_ID, <<>>).
+diff --git a/lib/ssl/src/ssl_session.erl b/lib/ssl/src/ssl_session.erl
+index 721a9ef4d5..078a4537de 100644
+--- a/lib/ssl/src/ssl_session.erl
++++ b/lib/ssl/src/ssl_session.erl
+@@ -33,7 +33,7 @@
+ %% Internal application API
+ -export([is_new/2,
+          client_select_session/5,
+-         server_select_session/5,
++         server_select_session/6,
+          valid_session/2,
+          legacy_session_id/1]).
+ 
+@@ -107,16 +107,16 @@ client_select_session({_, _, #{versions := Versions,
+     end.
+ 
+ %%--------------------------------------------------------------------
+--spec server_select_session(ssl_record:ssl_version(), pid(), ssl:session_id(), map(),
++-spec server_select_session(ssl_record:ssl_version(), pid(), ssl:session_id(), map(), map(),
+                             list())  -> {binary(), #session{} | undefined}.
+ %%
+ %% Description: Should be called by the server side to get an id
+ %%              for the client hello message.
+ %%--------------------------------------------------------------------
+-server_select_session(_, SessIdTracker, ?EMPTY_ID, _SslOpts, _CertKeyPairs) ->
++server_select_session(_, SessIdTracker, ?EMPTY_ID, _HelloExt, _SslOpts, _CertKeyPairs) ->
+     {ssl_server_session_cache:new_session_id(SessIdTracker), undefined};
+-server_select_session(_, SessIdTracker, SuggestedId, Options, CertKeyPairs) ->
+-    case is_resumable(SuggestedId, SessIdTracker, Options, CertKeyPairs)
++server_select_session(_, SessIdTracker, SuggestedId, HelloExt, Options, CertKeyPairs) ->
++    case is_resumable(SuggestedId, SessIdTracker, Options, HelloExt, CertKeyPairs)
+     of
+ 	{true, Resumed} ->
+ 	    {SuggestedId, Resumed};
+@@ -193,10 +193,10 @@ select_session(Sessions, #{ciphers := Ciphers}, CertKeyPairs) ->
+ 	[Session | _] -> Session
+     end.
+ 
+-is_resumable(_, _, #{reuse_sessions := false}, _) ->
++is_resumable(_, _, #{reuse_sessions := false}, _, _) ->
+     {false, undefined};
+ is_resumable(SuggestedSessionId, SessIdTracker,
+-             #{reuse_session := ReuseFun} = Options,  OwnCertKeyPairs) ->
++             #{reuse_session := ReuseFun} = Options,  HelloExt, OwnCertKeyPairs) ->
+     case ssl_server_session_cache:reuse_session(SessIdTracker, SuggestedSessionId) of
+ 	#session{cipher_suite = CipherSuite,
+                  own_certificates =  [SessionOwnCert | _],
+@@ -205,7 +205,7 @@ is_resumable(SuggestedSessionId, SessIdTracker,
+ 		 peer_certificate = PeerCert} = Session ->
+ 	    case resumable(IsResumable)
+ 		andalso is_owncert(SessionOwnCert, OwnCertKeyPairs)
+-		andalso reusable_options(Options, Session)
++                andalso reusable_options(Options, HelloExt, Session)
+ 		andalso ReuseFun(SuggestedSessionId, PeerCert,
+ 				 Compression, CipherSuite)
+ 	    of
+@@ -229,10 +229,23 @@ resumable(IsResumable) ->
+     IsResumable.
+ 
+ reusable_options(#{fail_if_no_peer_cert := true,
+-                   verify := verify_peer}, Session) ->
+-    (Session#session.peer_certificate =/= undefined);
+-reusable_options(_,_) ->
+-    true.
++                   verify := verify_peer}, _, #session{peer_certificate = undefined}) ->
++    %% Can not resume session without a peer cert if current negotiation requires one.
++    false;
++reusable_options(_Opts, HelloExt, #session{sni = SessionSNI}) ->
++    %% RFC 6066 3: a server that implements SNI MUST NOT resume a session
++    %% if the server_name of the resumption request differs from the one
++    %% that established the session; it must do a full handshake instead.
++    %% Comparing the established server_name (rather than the server
++    %% certificate) also covers the case where several SNI names share
++    %% one certificate but have different client-authentication trust.
++    %% A request without SNI only matches a session established without
++    %% SNI, so ordinary (non-SNI) resumption is unaffected.
++    RequestSNI = case maps:get(sni, HelloExt, undefined) of
++                     #sni{hostname = Host} -> Host;
++                     undefined -> undefined
++                 end,
++    RequestSNI =:= SessionSNI.
+ 
+ record_cb(tls) ->
+     tls_record;
+diff --git a/lib/ssl/src/tls_dtls_connection.erl b/lib/ssl/src/tls_dtls_connection.erl
+index d4da62de28..e945e00f71 100644
+--- a/lib/ssl/src/tls_dtls_connection.erl
++++ b/lib/ssl/src/tls_dtls_connection.erl
+@@ -597,6 +597,7 @@ cipher(internal, #finished{verify_data = Data} = Finished,
+                                        port = Port,
+                                        trackers = Trackers},
+               handshake_env = #handshake_env{tls_handshake_history = Hist,
++                                             sni_hostname = SNIHostname,
+                                              expecting_finished = true} = HsEnv,
+               connection_env = #connection_env{negotiated_version = Version},
+ 	      session = #session{master_secret = MasterSecret}
+@@ -608,7 +609,8 @@ cipher(internal, #finished{verify_data = Data} = Finished,
+ 					 get_current_prf(ConnectionStates0, read),
+ 					 MasterSecret, Hist) of
+         verified ->
+-	    Session = handle_session(Role, SslOpts, Host, Port, Trackers, Session0),
++	    Session = maybe_register_session(Role, SslOpts, SNIHostname, Host, Port,
++                                             Trackers, Session0),
+ 	    cipher_role(Role, Data, Session,
+ 			State#state{handshake_env = HsEnv#handshake_env{expecting_finished = false}});
+         #alert{} = Alert ->
+@@ -1578,16 +1580,17 @@ session_handle_params(#server_ecdh_params{curve = ECCurve}, Session) ->
+ session_handle_params(_, Session) ->
+     Session.
+ 
+-handle_session(server, #{reuse_sessions := true}, 
++maybe_register_session(server, #{reuse_sessions := true}, SNIHostname,
+                _Host, _Port, Trackers, #session{is_resumable = false} = Session) ->
+     Tracker = proplists:get_value(session_id_tracker, Trackers),
+-    server_register_session(Tracker, Session#session{is_resumable = true});
+-handle_session(Role = client, #{verify := verify_peer,
+-                                reuse_sessions := Reuse} = SslOpts,
++    server_register_session(Tracker, Session#session{is_resumable = true,
++                                                     sni = SNIHostname});
++maybe_register_session(Role = client, #{verify := verify_peer,
++                                reuse_sessions := Reuse} = SslOpts, _SNIHostname,
+                Host, Port, _, #session{is_resumable = false} = Session) when Reuse =/= false ->
+     client_register_session(host_id(Role, Host, SslOpts), Port, Session#session{is_resumable = true}, 
+                             reg_type(Reuse));
+-handle_session(_,_,_,_,_, Session) ->
++maybe_register_session(_,_,_,_,_,_, Session) ->
+     Session.
+ 
+ reg_type(save) ->
+diff --git a/lib/ssl/src/tls_handshake.erl b/lib/ssl/src/tls_handshake.erl
+index 2431a2ec4d..3d4503002a 100644
+--- a/lib/ssl/src/tls_handshake.erl
++++ b/lib/ssl/src/tls_handshake.erl
+@@ -347,7 +347,7 @@ handle_client_hello(Version,
+ 	    {Type, #session{cipher_suite = CipherSuite,
+                             own_certificates = [OwnCert |_]} = Session1}
+ 		= ssl_handshake:select_session(SugesstedId, CipherSuites,
+-                                               AvailableHashSigns, Compressions,
++                                               AvailableHashSigns, Compressions, HelloExt,
+ 					       SessIdTracker, Session0#session{ecc = ECCCurve},
+                                                Version, SslOpts, CertKeyPairs),
+ 	    case CipherSuite of
+diff --git a/lib/ssl/test/openssl_sni_SUITE.erl b/lib/ssl/test/openssl_sni_SUITE.erl
+index a5ebbb35c4..7de6bf5776 100644
+--- a/lib/ssl/test/openssl_sni_SUITE.erl
++++ b/lib/ssl/test/openssl_sni_SUITE.erl
+@@ -38,7 +38,9 @@
+          sni_no_match/1,
+          sni_no_match_fun/1,
+          sni_no_header/1,
+-         sni_no_header_fun/1
++         sni_no_header_fun/1,
++         sni_cross_ca_no_session_reuse/0,
++         sni_cross_ca_no_session_reuse/1
+         ]).
+ 
+ %% Apply exports
+@@ -75,7 +77,7 @@ groups() ->
+      case ssl_test_lib:openssl_sane_dtls() of 
+          true ->
+              [{'tlsv1.3', [], sni_tests()},
+-              {'tlsv1.2', [], sni_tests()},
++              {'tlsv1.2', [], sni_tests() ++ tls_1_2_tests()},
+               {'tlsv1.1', [], sni_tests()},
+               {'tlsv1', [], sni_tests()},
+               {'dtlsv1.2', [], sni_tests()},
+@@ -83,7 +85,7 @@ groups() ->
+              ];
+         false ->
+              [{'tlsv1.3', [], sni_tests()},
+-              {'tlsv1.2', [], sni_tests()},
++              {'tlsv1.2', [], sni_tests() ++ tls_1_2_tests()},
+               {'tlsv1.1', [], sni_tests()},
+               {'tlsv1', [], sni_tests()}
+              ]
+@@ -97,6 +99,10 @@ sni_tests() ->
+      sni_no_header,
+      sni_no_header_fun].
+ 
++%% Session-id based resumption only exists pre TLS-1.3.
++tls_1_2_tests() ->
++    [sni_cross_ca_no_session_reuse].
++
+ init_per_suite(Config0) ->
+     Config1 = ssl_test_lib:init_per_suite(Config0, openssl),
+     Config2 = check_openssl_sni_support(Config1),
+@@ -188,6 +194,90 @@ sni_no_match_fun(Config) when is_list(Config) ->
+                                                proplists:get_value(client_local_opts, Config)], Config),
+     sni_test(ServerNode, ServerOptions, ClientOptions, Config).
+ 
++sni_cross_ca_no_session_reuse() ->
++    ["Two SNI names share the same server
++    certificate but trust different CAs. A client that
++    trusts the lower-trust name must NOT be able to resume
++    that TLS-1.2 session at the higher-trust name."].
++
++sni_cross_ca_no_session_reuse(Config) when is_list(Config) ->
++    {_, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
++    Version = ssl_test_lib:protocol_version(Config),
++    PrivDir = proplists:get_value(priv_dir, Config),
++    {ServerConf, ServerCACertFile, LowCACertFile, HighCACertFile,
++     LowClientCert, LowClientKey} = ssl_test_lib:make_cross_ca_pems(PrivDir),
++
++    LowSNI = "low.test",
++    HighSNI = "high.test",
++    SigAlgOpts = maybe_add_sigalgs(Version, []),
++    SniBase = SigAlgOpts ++ ServerConf,
++    SniFun =
++        fun(SNI) when SNI =:= LowSNI ->
++                [{verify, verify_peer}, {fail_if_no_peer_cert, true},
++                 {reuse_sessions, true},
++                 {cacertfile, LowCACertFile} | SniBase];
++           (SNI) when SNI =:= HighSNI ->
++                [{verify, verify_peer}, {fail_if_no_peer_cert, true},
++                 {reuse_sessions, true},
++                 {cacertfile, HighCACertFile} | SniBase];
++           (_) ->
++                unrecognized
++        end,
++
++    ServerOptions = [{verify, verify_none},
++                     {versions, [Version]},
++                     {sni_fun, SniFun} | SniBase],
++
++    SessFile = filename:join(PrivDir, "otp20445_low.sess"),
++    file:delete(SessFile),
++
++    %% One persistent listener for both connections so the pre-TLS-1.3
++    %% session cache (which is per listen socket) is shared.
++    Server = ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
++                                        {from, self()},
++                                        {mfa, {?MODULE, send_and_hostname, []}},
++                                        {options, ServerOptions}]),
++    Port0 = ssl_test_lib:inet_port(Server),
++
++    ClientBase = maybe_add_openssl_sigalgs(Version) ++
++        [{hostname, Hostname}, {port, Port0},
++         {cacertfile, ServerCACertFile},
++         {certfile, LowClientCert}, {keyfile, LowClientKey}],
++
++    %% 1. Establish and save a session at the low-trust name. The server
++    %% reports the SNI name it served, proving the low client is
++    %% authenticated against the low CA.
++    Low = ssl_test_lib:start_client(openssl,
++                                    [{server_name_indication, LowSNI},
++                                     {versions, [Version]},
++                                     {session_args, ["-sess_out", SessFile]}
++                                     | ClientBase],
++                                    Config),
++    ssl_test_lib:check_result(Server, LowSNI),
++    ssl_test_lib:close_port(Low),
++
++    %% The session file must have been written for the attack to be
++    %% meaningful.
++    true = filelib:is_regular(SessFile),
++
++    %% Re-arm the same listener for the next connection.
++    Server ! {listen, {mfa, {?MODULE, send_and_hostname, []}}},
++
++    %% 2. Attempt to resume that session at the high-trust name using
++    %% the same low-trust client certificate. The verify_peer service
++    %% must force a full handshake and reject the low-trust cert with an
++    %% unknown_ca alert, instead of silently resuming (which would let
++    %% the low-trust client reach the high-trust authority).
++    High = ssl_test_lib:start_client(openssl,
++                                     [{server_name_indication, HighSNI},
++                                      {versions, [Version]},
++                                      {session_args, ["-sess_in", SessFile]}
++                                      | ClientBase],
++                                     Config),
++    ssl_test_lib:check_server_alert(Server, unknown_ca),
++    ssl_test_lib:close_port(High),
++    ssl_test_lib:close(Server),
++    ok.
+ 
+ %%--------------------------------------------------------------------
+ %% Callback functions  ------------------------------------------------
+@@ -260,17 +350,21 @@ maybe_add_openssl_sigalgs(Version) when Version == 'tlsv1.3';
+     case ssl_test_lib:portable_cmd("openssl", ["version"]) of
+         "OpenSSL 1.0" ++  _ ->
+             [];
++        "OpenSSL 1.1" ++  _ ->
++            openssl_add_sigalgs("rsa_pkcs1_sha256:rsa_pss_rsae_sha256");
+         _ ->
+-            HelpText = ssl_test_lib:portable_cmd("openssl", ["s_client", "--help"]),
+-            case string:str(HelpText, "-sigalgs") of
+-                0 ->
+-                    [];
+-                _ ->
+-                    [{sigalgs, "rsa_pss_rsae_sha512:rsa_pss_rsae_sha384:rsa_pss_rsae_sha256"}]
+-            end
++            openssl_add_sigalgs("rsa_pss_rsae_sha512:rsa_pss_rsae_sha384:rsa_pss_rsae_sha256")
+     end;
+ maybe_add_openssl_sigalgs(_) ->
+     [].
++openssl_add_sigalgs(Sigalgs) ->
++    HelpText = ssl_test_lib:portable_cmd("openssl", ["s_client", "--help"]),
++    case string:str(HelpText, "-sigalgs") of
++        0 ->
++            [];
++        _ ->
++            [{sigalgs, Sigalgs}]
++    end.
+ 
+ check_openssl_sni_support(Config) ->
+     HelpText = ssl_test_lib:portable_cmd("openssl", ["s_client", "--help"]),
+diff --git a/lib/ssl/test/ssl_session_SUITE.erl b/lib/ssl/test/ssl_session_SUITE.erl
+index 549939fad6..75430f34d6 100644
+--- a/lib/ssl/test/ssl_session_SUITE.erl
++++ b/lib/ssl/test/ssl_session_SUITE.erl
+@@ -61,7 +61,9 @@
+          server_max_session_table/0,
+          server_max_session_table/1, 
+          session_table_stable_size_on_tcp_close/0,
+-         session_table_stable_size_on_tcp_close/1
++         session_table_stable_size_on_tcp_close/1,
++         sni_cross_ca_no_session_reuse/0,
++         sni_cross_ca_no_session_reuse/1
+         ]).
+ 
+ -define(SLEEP, 500).
+@@ -83,7 +85,6 @@ all() ->
+ groups() ->
+     [{'dtlsv1.2', [], session_tests()},
+      {'dtlsv1', [], session_tests()},
+-     {'tlsv1.3', [], session_tests() ++ tls_session_tests()},
+      {'tlsv1.2', [], session_tests() ++ tls_session_tests()},
+      {'tlsv1.1', [], session_tests() ++ tls_session_tests()},
+      {'tlsv1', [], session_tests() ++ tls_session_tests()}
+@@ -98,20 +99,20 @@ session_tests() ->
+      no_reuses_session_server_restart_new_cert,
+      no_reuses_session_server_restart_new_cert_file,
+      client_max_session_table,
+-     server_max_session_table
++     server_max_session_table,
++     sni_cross_ca_no_session_reuse
+     ].
+ 
+ tls_session_tests() ->
+        [session_table_stable_size_on_tcp_close].
+ 
+ init_per_suite(Config0) ->
+-    catch crypto:stop(),
+-    try crypto:start() of
++    case application:ensure_started(crypto) of
+ 	ok ->
+ 	    ssl_test_lib:clean_start(),
+             Config = ssl_test_lib:make_rsa_cert(Config0),
+-            ssl_test_lib:make_rsa_1024_cert(Config)
+-    catch _:_ ->
++            ssl_test_lib:make_rsa_1024_cert(Config);
++        {error, _} ->
+ 	    {skip, "Crypto did not start"}
+     end.
+ 
+@@ -125,6 +126,30 @@ init_per_group(GroupName, Config) ->
+ end_per_group(GroupName, Config) ->
+   ssl_test_lib:end_per_group(GroupName, Config).
+ 
++init_per_testcase(sni_cross_ca_no_session_reuse, Config) ->
++    %% The cross-SNI session-reuse fix applies to pre-TLS-1.3 TLS and
++    %% DTLS alike (see ssl_session:reusable_options/3, threaded via
++    %% tls_handshake and dtls_handshake). This end-to-end test is however
++    %% TLS-only: over DTLS the ssl_test_lib run_server/listen re-arm does
++    %% not reliably route a second, brand-new UDP peer to the re-armed
++    %% transport_accept, so the test hangs. The DTLS code path is covered
++    %% by the generic reuse_session test. See OTP-20445 backlog note on
++    %% making the DTLS re-accept harness robust for a dedicated DTLS case.
++    case proplists:get_value(protocol, Config, tls) of
++        dtls ->
++            {skip, "cross-SNI reuse end-to-end test is TLS-only; "
++             "DTLS code path covered by reuse_session"};
++        _ ->
++            Versions = ssl_test_lib:protocol_version(Config),
++            ssl:stop(),
++            application:load(ssl),
++            ssl_test_lib:clean_env(),
++            ssl_test_lib:set_protocol_versions(Versions),
++            ssl:start(),
++            ssl_test_lib:ct_log_supported_protocol_versions(Config),
++            ct:timetrap({seconds, 5}),
++            Config
++    end;
+ init_per_testcase(TestCase, Config)  when TestCase == reuse_session_expired;
+                                           TestCase == explicit_session_reuse_expired ->
+     Versions = ssl_test_lib:protocol_version(Config),
+@@ -348,7 +373,6 @@ explicit_session_reuse(Config) when is_list(Config) ->
+ 
+ 
+ %%--------------------------------------------------------------------
+-
+ explicit_session_reuse_expired() ->
+     [{doc,"Test to reuse a session that has expired and make sure server session table is correctly handled"}].
+ explicit_session_reuse_expired(Config) when is_list(Config) ->
+@@ -459,6 +483,91 @@ explicit_session_reuse_expired(Config) when is_list(Config) ->
+     2 = SessionCacheCb3:size(SessionCacheDb3).
+ 
+ 
++%%--------------------------------------------------------------------
++sni_cross_ca_no_session_reuse() ->
++    ["Two SNI names share the same server
++    certificate but trust different CAs. A client that
++    trusts the lower-trust name must NOT be able to resume
++    that TLS-1.2 session at the higher-trust name."].
++
++sni_cross_ca_no_session_reuse(Config) when is_list(Config) ->
++    process_flag(trap_exit, true),
++    {ClientNode, ServerNode, Hostname} = ssl_test_lib:run_where(Config),
++    PrivDir = proplists:get_value(priv_dir, Config),
++    {ServerConf, CACertFile, LowCACertFile, HighCACertFile,
++     ClientCert, ClientKey} = ssl_test_lib:make_cross_ca_pems(PrivDir),
++
++    LowSNI = "low.test",
++    HighSNI = "high.test",
++
++    SniFun =
++        fun(SNI) when SNI =:= LowSNI ->
++                [{verify, verify_peer}, {fail_if_no_peer_cert, true},
++                 {reuse_sessions, true},
++                 {cacertfile, LowCACertFile} | ServerConf];
++           (SNI) when SNI =:= HighSNI ->
++                [{verify, verify_peer}, {fail_if_no_peer_cert, true},
++                 {reuse_sessions, true},
++                 {cacertfile, HighCACertFile} | ServerConf];
++           (_) ->
++                unrecognized
++        end,
++
++    ServerOpts = ssl_test_lib:ssl_options([{sni_fun, SniFun} | ServerConf], Config),
++    ClientOpts = ssl_test_lib:ssl_options([], Config),
++
++    Server =
++	ssl_test_lib:start_server([{node, ServerNode}, {port, 0},
++                                   {from, self()},
++                                   {mfa, {ssl_test_lib, no_result, []}},
++                                   {options, [{reuse_sessions, true},
++                                              {sni_fun, SniFun}| ServerOpts]}]),
++    Port = ssl_test_lib:inet_port(Server),
++
++    %% 1. Establish a session at the lower-trust name and capture its
++    %% id + data so it can be explicitly re-offered later, regardless of
++    %% SNI (equivalent to openssl s_client -sess_out/-sess_in). Using the
++    %% client session cache would not work here: the client keys cached
++    %% sessions by SNI and would not offer the low.test session on a
++    %% high.test connection, so the server resumption decision would
++    %% never be exercised.
++    {Client0, Client0Sock} =
++	ssl_test_lib:start_client([{node, ClientNode},
++                                   {port, Port}, {host, Hostname},
++                                   {mfa, {ssl_test_lib, no_result, []}},
++                                   {from, self()},
++                                   {options, [{reuse_sessions, save},
++                                              {cacertfile, CACertFile},
++                                              {certfile, ClientCert},
++                                              {keyfile, ClientKey},
++                                              {server_name_indication, LowSNI} | ClientOpts]},
++                                   return_socket
++                                  ]),
++
++    {ok, [{session_id, ID}, {session_data, SessData}]} =
++        ssl:connection_information(Client0Sock, [session_id, session_data]),
++
++    ssl_test_lib:close(Client0),
++
++    Server ! listen,
++
++    %% 2. Explicitly re-offer the low.test session on a high.test
++    %% connection, presenting the same client certificate. high.test
++    %% trusts a different client CA, so the server must refuse to resume
++    %% across the SNI boundary and fall back to a full handshake, which
++    %% then rejects the client certificate with unknown_ca. Silent
++    %% resumption would let the lower-trust client reach the higher-trust
++    %% service without being validated against its CA.
++    ssl_test_lib:start_client_error([{node, ClientNode},
++                                     {port, Port}, {host, Hostname},
++                                     {mfa, {ssl_test_lib, no_result, []}},
++                                     {from, self()},
++                                     {options, [{reuse_session, {ID, SessData}},
++                                                {cacertfile, CACertFile},
++                                                {certfile, ClientCert}, {keyfile, ClientKey},
++                                                {server_name_indication, HighSNI}]}]),
++    ssl_test_lib:check_server_alert(Server, unknown_ca).
++
+ %%--------------------------------------------------------------------
+ no_reuses_session_server_restart_new_cert() ->
+     [{doc,"Check that a session is not reused if the server is restarted with a new cert."}].
+@@ -582,6 +691,7 @@ no_reuses_session_server_restart_new_cert_file(Config) when is_list(Config) ->
+     ssl_test_lib:close(Server1),
+     ssl_test_lib:close(Client1).
+ 
++%%--------------------------------------------------------------------
+ 
+ client_max_session_table() ->
+       [{doc, "Check that max session table limit is not exceeded, set max to 2 in init_per_testcase"}].
+@@ -597,7 +707,8 @@ client_max_session_table(Config) when is_list(Config)->
+     State = ssl_test_lib:state(Prop),
+     ClientCache = element(2, State),	
+     2 = ?CLIENT_CB:size(ClientCache).
+-    
++
++%%--------------------------------------------------------------------
+ server_max_session_table() ->
+       [{doc, "Check that max session table limit exceeded, set max to 2 in init_per_testcase"}].
+ 
+@@ -615,6 +726,8 @@ server_max_session_table(Config) when is_list(Config)->
+     N = SessionCacheCb:size(SessionCacheDb),
+     true = N == 2.
+ 
++
++%%--------------------------------------------------------------------
+ session_table_stable_size_on_tcp_close() ->
+       [{doc, "Check that new sessions are cleanup when connection is closed abruptly during first handshake"}].
+ 
+diff --git a/lib/ssl/test/ssl_sni_SUITE.erl b/lib/ssl/test/ssl_sni_SUITE.erl
+index 6b20025636..f6c617aec4 100644
+--- a/lib/ssl/test/ssl_sni_SUITE.erl
++++ b/lib/ssl/test/ssl_sni_SUITE.erl
+@@ -91,11 +91,11 @@ groups() ->
+     ].
+ 
+ sni_tests() ->
+-    [no_sni_ext, 
+-     sni_match, 
++    [no_sni_ext,
++     sni_match,
+      sni_no_match,
+-     no_sni_ext_fun, 
+-     sni_match_fun, 
++     no_sni_ext_fun,
++     sni_match_fun,
+      sni_no_match_fun,
+      dns_name,
+      ip_fallback,
+@@ -144,7 +144,7 @@ init_per_testcase(_TestCase, Config) ->
+     ct:timetrap(?TIMEOUT),
+     Config.
+ 
+-end_per_testcase(_TestCase, Config) ->     
++end_per_testcase(_TestCase, Config) ->
+     Config.
+ 
+ %%--------------------------------------------------------------------
+diff --git a/lib/ssl/test/ssl_test_lib.erl b/lib/ssl/test/ssl_test_lib.erl
+index f30219b18b..639c17e7f5 100644
+--- a/lib/ssl/test/ssl_test_lib.erl
++++ b/lib/ssl/test/ssl_test_lib.erl
+@@ -182,6 +182,7 @@
+          make_rsa_1024_cert/1,
+          make_rsa_pss_pem/4,
+          make_rsa_sni_configs/0,
++         make_cross_ca_pems/1,
+          pss_params/1,
+          gen_conf/4,
+          make_mix_cert/1,
+@@ -1709,6 +1710,65 @@ make_sni_conf(HostName, Sha) ->
+                                       peer => [{digest, Sha},
+                                                {key, hardcode_rsa_key(6)}]}}).
+ 
++%% Build PEM material for the cross-CA SNI test:
++%%  - one shared server certificate presented for both SNI names
++%%  - two independent client CAs (low / high)
++%%  - a client certificate signed by the low CA
++%% The server certificate carries both SNI names as SANs so that the
++%% same certificate legitimately serves low.test and high.test, which
++%% is what makes the pre-TLS-1.3 session cache's is_owncert check pass.
++make_cross_ca_pems(PrivDir) ->
++    Sha = sha256,
++    SNIExt = [#'Extension'{extnID = ?'id-ce-subjectAltName',
++                           extnValue = [{dNSName, "low.test"},
++                                        {dNSName, "high.test"}],
++                           critical = false}],
++    %% Call 1: shared server + low client CA.
++    Data1 = public_key:pkix_test_data(
++              #{server_chain =>
++                    #{root => [{digest, Sha}, {key, ssl_test_lib:hardcode_rsa_key(1)}],
++                      intermediates => [[{digest, Sha},
++                                         {key, ssl_test_lib:hardcode_rsa_key(2)}]],
++                      peer => [{digest, Sha}, {extensions, SNIExt},
++                               {key, ssl_test_lib:hardcode_rsa_key(3)}]},
++                client_chain =>
++                    #{root => [{digest, Sha}, {key, ssl_test_lib:hardcode_rsa_key(4)}],
++                      intermediates => [[{digest, Sha},
++                                         {key, ssl_test_lib:hardcode_rsa_key(5)}]],
++                      peer => [{digest, Sha},
++                               {key, ssl_test_lib:hardcode_rsa_key(6)}]}}),
++    [{server_config, SharedServerConf},
++     {client_config, LowClientConf}] =
++        x509_test:gen_pem_config_files(
++          Data1,
++          filename:join(PrivDir, "otp20445_low"),
++          filename:join(PrivDir, "otp20445_shared")),
++
++    %% Call 2: throwaway server + an independent high client CA. Only
++    %% the client (high) CA file is used from this call.
++    Data2 = public_key:pkix_test_data(
++              #{server_chain =>
++                    #{root => [{digest, Sha}], intermediates => [[{digest, Sha}]],
++                      peer => [{digest, Sha}]},
++                client_chain =>
++                    #{root => [{digest, Sha}], intermediates => [[{digest, Sha}]],
++                      peer => [{digest, Sha}]}}),
++    [{server_config, _}, {client_config, HighClientConf}] =
++        x509_test:gen_pem_config_files(
++          Data2,
++          filename:join(PrivDir, "otp20445_high"),
++          filename:join(PrivDir, "otp20445_throwaway")),
++
++    ServerConf = [{certfile, proplists:get_value(certfile, SharedServerConf)},
++                  {keyfile, proplists:get_value(keyfile, SharedServerConf)}],
++    ServerCACertFile = proplists:get_value(cacertfile, SharedServerConf),
++    LowCACertFile = proplists:get_value(cacertfile, LowClientConf),
++    HighCACertFile = proplists:get_value(cacertfile, HighClientConf),
++    LowClientCert = proplists:get_value(certfile, LowClientConf),
++    LowClientKey = proplists:get_value(keyfile, LowClientConf),
++    {ServerConf, ServerCACertFile, LowCACertFile, HighCACertFile,
++     LowClientCert, LowClientKey}.
++
+ gen_conf(ClientChainType, ServerChainType, UserClient, UserServer) ->
+     gen_conf(ClientChainType, ServerChainType, UserClient, UserServer, ?DEFAULT_CURVE).
+ %%

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-26 16:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-26 16:07 [rpms/erlang] f43: Merge branch 'f44' into f43 Peter Lemenkov
  -- strict thread matches above, loose matches on Subject: below --
2026-11-25 16:04 Peter Lemenkov
2026-11-02 18:46 Peter Lemenkov

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