new file mode 100644
@@ -0,0 +1,147 @@
+From d8b5b05682280773040e53adc005d15b977b46a1 Mon Sep 17 00:00:00 2001
+From: Timothy Legge <timlegge@gmail.com>
+Date: Wed, 11 Nov 2026 00:40:45 +0000
+Subject: [PATCH 1/8] Fix CVE-2026-126540: cap INTEGER byte length to prevent
+ quadratic decode cost
+
+Add a max_int_len decode option that limits the number of content bytes
+accepted for any INTEGER or ENUMERATED value requiring big-integer handling
+(> 4 bytes / 32 bits). The default cap of 1025 bytes accommodates RSA-8192
+moduli (8192 bits + 1 leading sign byte) while blocking larger inputs.
+Set to 0 to disable; negative values are rejected as a hard error.
+
+ $asn->configure(decode => { max_int_len => 4096 }); # allow up to 32767-bit
+ $asn->configure(decode => { max_int_len => 0 }); # no limit (not recommended)
+
+CVE: CVE-2026-126540
+Upstream-Status: Backport [https://github.com/cpan-authors/perl-Convert-ASN1/commit/49b362c527e0af05fca9be1e97e4a340d95afa75]
+Signed-off-by: Omkar Patil <OmkarAbaji.Patil@windriver.com>
+---
+ lib/Convert/ASN1.pod | 12 +++++++
+ lib/Convert/ASN1/_decode.pm | 8 ++++-
+ t/20integer_max_len.t | 71 +++++++++++++++++++++++++++++++++++++
+ 3 files changed, 90 insertions(+), 1 deletion(-)
+ create mode 100644 t/20integer_max_len.t
+
+diff --git a/lib/Convert/ASN1.pod b/lib/Convert/ASN1.pod
+index 746b538..4eb4a5d 100644
+--- a/lib/Convert/ASN1.pod
++++ b/lib/Convert/ASN1.pod
+@@ -158,6 +158,18 @@ than 32 bits), they will be decoded into big integer objects. This option
+ controls the big integer class into which the objects will be blessed.
+ The default is to use Math::BigInt.
+
++=item max_int_len
++
++Maximum number of content bytes accepted for an INTEGER or ENUMERATED element
++greater than 32 bits before decoding is aborted with an error. Prevents a
++remote peer from causing quadratic CPU usage by sending a very large integer
++value. Defaults to C<1025> (enough for an RSA-8192 modulus, which requires a
++leading sign byte). Set to C<0> to disable the limit; negative values are
++rejected as invalid.
++
++ $asn->configure(decode => { max_int_len => 4096 }); # allow up to 32768-bit
++ $asn->configure(decode => { max_int_len => 0 }); # no limit (not recommended)
++
+ =item null
+
+ The value to decode ASN.1 NULL types into.
+diff --git a/lib/Convert/ASN1/_decode.pm b/lib/Convert/ASN1/_decode.pm
+index 766a3d6..3d10bb3 100644
+--- a/lib/Convert/ASN1/_decode.pm
++++ b/lib/Convert/ASN1/_decode.pm
+@@ -281,7 +281,13 @@ sub _dec_integer {
+ my $buf = substr($_[4],$_[5],$_[6]);
+ my $tmp = unpack("C",$buf) & 0x80 ? pack("C",255) : pack("C",0);
+ if ($_[6] > 4) {
+- $_[3] = os2ip($buf, $_[0]->{decode_bigint} || 'Math::BigInt');
++ my $max = ($_[0] && exists $_[0]->{decode_max_int_len})
++ ? $_[0]->{decode_max_int_len}
++ : 1025;
++ die "decode: max_int_len must not be negative\n" if $max < 0;
++ die "INTEGER too large (length $_[6] exceeds max_int_len $max)\n"
++ if $max && $_[6] > $max;
++ $_[3] = os2ip($buf, ($_[0] && $_[0]->{decode_bigint}) || 'Math::BigInt');
+ } else {
+ # N unpacks an unsigned value
+ $_[3] = unpack("l",pack("l",unpack("N", $tmp x (4-$_[6]) . $buf)));
+diff --git a/t/20integer_max_len.t b/t/20integer_max_len.t
+new file mode 100644
+index 0000000..06221ac
+--- /dev/null
++++ b/t/20integer_max_len.t
+@@ -0,0 +1,71 @@
++#!/usr/bin/perl
++# Tests for the max_int_len cap on INTEGER decode (F1 fix).
++
++use strict;
++use warnings;
++use lib 'lib';
++use Convert::ASN1 qw(asn_encode_length);
++BEGIN { require './t/funcs.pl' }
++
++print "1..11\n";
++
++# Build a minimal BER-encoded INTEGER from raw content bytes.
++sub make_integer {
++ my $content = shift;
++ return pack("C", 0x02) . asn_encode_length(length $content) . $content;
++}
++
++my ($asn, $ret, $ok);
++
++# --- schema used for all decode tests ---
++btest 1, $asn = Convert::ASN1->new or warn $asn->error;
++btest 2, $asn->prepare('n INTEGER') or warn $asn->error;
++
++# --- 3: a 5-byte INTEGER (> 4 bytes) passes the default 1024-byte cap ---
++$asn->configure(decode => { bigint => 'Math::BigInt' });
++my $five = make_integer("\x00" x 4 . "\x05");
++btest 3, $ret = $asn->decode($five) or warn $asn->error;
++
++# --- 4: a 1025-byte INTEGER is rejected by the default 1024-byte cap ---
++my $big = make_integer("\x00" x 1025);
++$asn->configure(decode => { bigint => 'Math::BigInt', max_int_len => 1024 });
++btest 4, !defined($asn->decode($big))
++ or print "# expected decode to fail on oversized INTEGER\n";
++
++# --- 5: the error message mentions max_int_len ---
++$asn->decode($big);
++btest 5, (defined $asn->error && $asn->error =~ /max_int_len/);
++
++# --- 6: exactly 1024 bytes is accepted by the default cap ---
++my $exact = make_integer("\x01" . "\x00" x 1023);
++btest 6, defined($asn->decode($exact)) or warn $asn->error;
++
++# --- 7: raising the cap to 2048 allows a 1025-byte INTEGER ---
++my $asn2 = Convert::ASN1->new;
++$asn2->prepare('n INTEGER');
++$asn2->configure(decode => { bigint => 'Math::BigInt', max_int_len => 2048 });
++btest 7, defined($asn2->decode($big)) or warn $asn2->error;
++
++# --- 8: setting max_int_len => 0 disables the cap entirely ---
++my $asn3 = Convert::ASN1->new;
++$asn3->prepare('n INTEGER');
++$asn3->configure(decode => { bigint => 'Math::BigInt', max_int_len => 0 });
++my $big2 = make_integer("\x01" . "\x00" x 1500);
++btest 8, defined($asn3->decode($big2)) or warn $asn3->error;
++
++# --- 9: cap of 10 rejects an 11-byte INTEGER ---
++my $asn4 = Convert::ASN1->new;
++$asn4->prepare('n INTEGER');
++$asn4->configure(decode => { bigint => 'Math::BigInt', max_int_len => 10 });
++my $eleven = make_integer("\x00" x 11);
++btest 9, !defined($asn4->decode($eleven));
++
++# --- 10: cap of 10 passes a 4-byte INTEGER (small native path, no os2ip) ---
++my $four = make_integer(pack "N", 0x7fffffff);
++btest 10, defined($asn4->decode($four)) or warn $asn4->error;
++
++# --- 11: negative max_int_len is a hard error ---
++my $asn5 = Convert::ASN1->new;
++$asn5->prepare('n INTEGER');
++$asn5->configure(decode => { bigint => 'Math::BigInt', max_int_len => -1 });
++btest 11, !defined($asn5->decode($five)) && ($asn5->error || '') =~ /max_int_len must not be negative/;
+--
+2.40.0
+
@@ -5,7 +5,9 @@ DESCRIPTION = "Convert::ASN1 is a perl library for encoding/decoding data using
LICENSE = "Artistic-1.0 | GPL-1.0-or-later"
LIC_FILES_CHKSUM = "file://README.md;beginline=91;endline=97;md5=ceff7fd286eb6d8e8e0d3d23e096a63f"
-SRC_URI = "${CPAN_MIRROR}/authors/id/T/TI/TIMLEGGE/Convert-ASN1-${PV}.tar.gz"
+SRC_URI = "${CPAN_MIRROR}/authors/id/T/TI/TIMLEGGE/Convert-ASN1-${PV}.tar.gz \
+ file://CVE-2026-126540.patch \
+ "
SRC_URI[sha256sum] = "a628d7c9d390568fb76359975fa03f626ce57f10dc17980e8e3587d7713e4ee7"
Convert::ASN1 versions before 0.37 for Perl allow CPU exhaustion via quadratic bigint loop in os2ip. Every INTEGER or ENUMERATED longer than four content octets reaches os2ip, which iterates over each content octet with $result = ($result * 256) + $octet. Each multiplication operates on a bigint that grows by one octet per step, so decoding an n-octet value takes O(n^2) bigint work. Nothing limits content length before this loop runs. An attacker who controls the decoded data can exhaust CPU with a single oversized INTEGER or ENUMERATED value. Reference: [https://nvd.nist.gov/vuln/detail/cve-2026-126540] Upstream patch: [https://github.com/cpan-authors/perl-Convert-ASN1/commit/49b362c527e0af05fca9be1e97e4a340d95afa75] Signed-off-by: Omkar Patil <OmkarAbaji.Patil@windriver.com> --- .../CVE-2026-126540.patch | 147 ++++++++++++++++++ .../perl/libconvert-asn1-perl_0.34.bb | 4 +- 2 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 meta/recipes-extended/perl/libconvert-asn1-perl/CVE-2026-126540.patch