new file mode 100644
@@ -0,0 +1,190 @@
+From 95f4eb1da6ed1ec3d27777ad9fe9ad335e98019e Mon Sep 17 00:00:00 2001
+From: Timothy Legge <timlegge@gmail.com>
+Date: Tue, 17 Nov 2026 21:40:25 -0400
+Subject: [PATCH 7/8] Fix CVE-2026-131868: prevent huge allocations in asn_read
+ and asn_get
+
+Both functions passed the length declared by an element straight to
+sysread, and perl allocates a buffer of the requested size before
+reading. A 6-byte header declaring a 4GB length made the process
+reserve 4GB; where the allocation is refused, perl exits with "Out of
+memory", which eval cannot catch.
+
+Cap each sysread at 64KB. The existing loops already repeat until the
+element is complete, so memory now tracks the data actually received.
+Add t/27asn_read_length.t.
+
+CVE: CVE-2026-131868
+Upstream-Status: Backport [https://github.com/cpan-authors/perl-Convert-ASN1/commit/88bd86b5a3ce3430ebb8b78fe5307f234198bf16]
+Signed-off-by: Omkar Patil <OmkarAbaji.Patil@windriver.com>
+---
+ lib/Convert/ASN1/IO.pm | 15 ++++---
+ t/27asn_read_length.t | 88 ++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 98 insertions(+), 5 deletions(-)
+ create mode 100644 t/27asn_read_length.t
+
+diff --git a/lib/Convert/ASN1/IO.pm b/lib/Convert/ASN1/IO.pm
+index 5284d06..34f9964 100644
+--- a/lib/Convert/ASN1/IO.pm
++++ b/lib/Convert/ASN1/IO.pm
+@@ -12,6 +12,10 @@ BEGIN {
+ eval { require bytes } and 'bytes'->import
+ }
+
++# Largest single read, so the buffer perl allocates tracks the data
++# received and not the length an element declares
++my $MAX_READ = 65536;
++
+ sub asn_recv { # $socket, $buffer, $flags
+
+ my $peer;
+@@ -146,7 +150,7 @@ sub asn_read { # $fh, $buffer, $offset
+ $need = ($pos + ($depth * 2)) || 2;
+
+ while(($n = $need - length $_[1]) > 0) {
+- $e = sysread($_[0],$_[1],$n,length $_[1]) or
++ $e = sysread($_[0],$_[1],($n > $MAX_READ ? $MAX_READ : $n),length $_[1]) or
+ goto READ_ERR;
+ }
+
+@@ -157,7 +161,7 @@ sub asn_read { # $fh, $buffer, $offset
+ do {
+ $need++;
+ while(($n = $need - length $_[1]) > 0) {
+- $e = sysread($_[0],$_[1],$n,length $_[1]) or
++ $e = sysread($_[0],$_[1],($n > $MAX_READ ? $MAX_READ : $n),length $_[1]) or
+ goto READ_ERR;
+ }
+ $ch = unpack("C",substr($_[1],$pos++,1));
+@@ -167,7 +171,7 @@ sub asn_read { # $fh, $buffer, $offset
+ $need = $pos + 1;
+
+ while(($n = $need - length $_[1]) > 0) {
+- $e = sysread($_[0],$_[1],$n,length $_[1]) or
++ $e = sysread($_[0],$_[1],($n > $MAX_READ ? $MAX_READ : $n),length $_[1]) or
+ goto READ_ERR;
+ }
+
+@@ -181,7 +185,7 @@ sub asn_read { # $fh, $buffer, $offset
+ $need = $pos + $len;
+
+ while(($n = $need - length $_[1]) > 0) {
+- $e = sysread($_[0],$_[1],$n,length $_[1]) or
++ $e = sysread($_[0],$_[1],($n > $MAX_READ ? $MAX_READ : $n),length $_[1]) or
+ goto READ_ERR;
+ }
+
+@@ -201,7 +205,7 @@ sub asn_read { # $fh, $buffer, $offset
+ }
+
+ while(($n = $pos - length $_[1]) > 0) {
+- $e = sysread($_[0],$_[1],$n,length $_[1]) or
++ $e = sysread($_[0],$_[1],($n > $MAX_READ ? $MAX_READ : $n),length $_[1]) or
+ goto READ_ERR;
+ }
+
+@@ -246,6 +250,7 @@ sub asn_get { # $fh
+ }
+
+ my $get = $need > 1024 ? $need : 1024;
++ $get = $MAX_READ if $get > $MAX_READ;
+
+ sysread($_[0], $href->{'asn_buffer'}, $get, length $href->{'asn_buffer'})
+ or return undef;
+diff --git a/t/27asn_read_length.t b/t/27asn_read_length.t
+new file mode 100644
+index 0000000..1ede07c
+--- /dev/null
++++ b/t/27asn_read_length.t
+@@ -0,0 +1,88 @@
++#!/usr/bin/perl
++# asn_read and asn_get must not size their read buffer from the length an
++# element declares; memory should track the data actually received.
++
++use strict;
++use warnings;
++use lib 'lib';
++use File::Temp qw(tempfile);
++use Convert::ASN1 qw(:io);
++BEGIN { require './t/funcs.pl' }
++
++print "1..10\n";
++
++sub vmpeak {
++ open(my $fh, '<', '/proc/self/status') or return;
++ while (<$fh>) { return $1 if /^VmPeak:\s+(\d+)/ }
++ return;
++}
++
++# Return a read handle on a temporary file holding $data.
++sub handle_for {
++ my $data = shift;
++ my ($fh, $name) = tempfile(UNLINK => 1);
++ binmode $fh;
++ print $fh $data;
++ close $fh;
++ open(my $in, '<', $name) or die "open: $!";
++ binmode $in;
++ return $in;
++}
++
++sub mem_test {
++ my ($num, $before, $after) = @_;
++ if (defined $before && defined $after) {
++ btest $num, $after - $before < 64 * 1024; # kB
++ }
++ else {
++ print "ok $num # skip no /proc/self/status\n";
++ }
++}
++
++my $huge = "\x30\x84\x7f\xff\xff\xff" . ("A" x 100); # declares ~2GB, holds 100 bytes
++
++# --- 1-2: asn_read fails on the short input without a huge allocation ---
++{
++ my $in = handle_for($huge);
++ my $before = vmpeak();
++ my $buf;
++ my $ret = asn_read($in, $buf);
++ my $after = vmpeak();
++ btest 1, !defined $ret;
++ mem_test 2, $before, $after;
++}
++
++# --- 3-4: asn_get fails on the short input without a huge allocation ---
++{
++ my $in = handle_for($huge);
++ my $before = vmpeak();
++ my $ret = asn_get($in);
++ my $after = vmpeak();
++ btest 3, !defined $ret;
++ mem_test 4, $before, $after;
++}
++
++# An element larger than a single read, followed by a small one.
++my $big = "\x04\x83\x03\x0d\x40" . ("B" x 200_000);
++my $small = "\x30\x03\x02\x01\x05";
++
++# --- 5-7: asn_read returns exactly one element at a time ---
++{
++ my $in = handle_for($big . $small);
++ my $buf;
++ my $ret = asn_read($in, $buf);
++ btest 5, defined($ret) && $ret == length $big;
++ btest 6, $buf eq $big;
++ asn_read($in, $buf);
++ btest 7, $buf eq $small;
++}
++
++# --- 8-10: asn_get returns each element whole ---
++{
++ my $in = handle_for($big . $small);
++ my $ret = asn_get($in);
++ btest 8, defined($ret) && $ret eq $big;
++ $ret = asn_get($in);
++ btest 9, defined($ret) && $ret eq $small;
++ btest 10, !defined asn_get($in);
++}
+--
+2.40.0
+
@@ -12,6 +12,7 @@ SRC_URI = "${CPAN_MIRROR}/authors/id/T/TI/TIMLEGGE/Convert-ASN1-${PV}.tar.gz \
file://CVE-2026-126682.patch \
file://CVE-2026-126819.patch \
file://CVE-2026-126956.patch \
+ file://CVE-2026-131868.patch \
"
SRC_URI[sha256sum] = "a628d7c9d390568fb76359975fa03f626ce57f10dc17980e8e3587d7713e4ee7"
Convert::ASN1 versions before 0.37 contain a flaw in asn_read() and asn_get() that can lead to memory exhaustion (DoS). A specially crafted BER header can declare an extremely large element length, causing Perl to allocate a massive buffer before reading any data, potentially exhausting system memory and terminating the process. Reference: [https://nvd.nist.gov/vuln/detail/cve-2026-131868] Upstream patch: [https://github.com/cpan-authors/perl-Convert-ASN1/commit/88bd86b5a3ce3430ebb8b78fe5307f234198bf16] Signed-off-by: Omkar Patil <OmkarAbaji.Patil@windriver.com> --- .../CVE-2026-131868.patch | 190 ++++++++++++++++++ .../perl/libconvert-asn1-perl_0.34.bb | 1 + 2 files changed, 191 insertions(+) create mode 100644 meta/recipes-extended/perl/libconvert-asn1-perl/CVE-2026-131868.patch