import CS git python-idna-3.7-6.el10_2
This commit is contained in:
parent
dd871f25d5
commit
5d5ca98e78
134
CVE-2026-45409.patch
Normal file
134
CVE-2026-45409.patch
Normal file
@ -0,0 +1,134 @@
|
||||
From 487f90216c00097caa6c5f10eb1f843ec2d8a4b6 Mon Sep 17 00:00:00 2001
|
||||
From: Kim Davies <kim@cynosure.com.au>
|
||||
Date: Sun, 10 May 2026 08:47:22 -0700
|
||||
Subject: [PATCH 1/2] Merge commit from fork
|
||||
|
||||
---
|
||||
idna/core.py | 14 ++++++++++++++
|
||||
tests/test_idna.py | 13 +++++++++++++
|
||||
2 files changed, 27 insertions(+)
|
||||
|
||||
diff --git a/idna/core.py b/idna/core.py
|
||||
index 0dae61a..a549326 100644
|
||||
--- a/idna/core.py
|
||||
+++ b/idna/core.py
|
||||
@@ -340,6 +340,15 @@ def encode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool =
|
||||
raise IDNAError('should pass a unicode string to the function rather than a byte string.')
|
||||
if uts46:
|
||||
s = uts46_remap(s, std3_rules, transitional)
|
||||
+
|
||||
+ # Reject inputs that exceed the maximum DNS domain length up-front.
|
||||
+ # Each codepoint in a U-label contributes at least one octet to its
|
||||
+ # A-label form, so any input longer than the domain limit cannot
|
||||
+ # produce a valid A-domain. Short-circuiting here prevents per-label
|
||||
+ # validation from being driven into quadratic time
|
||||
+ if len(s) > 254:
|
||||
+ raise IDNAError("Domain too long")
|
||||
+
|
||||
trailing_dot = False
|
||||
result = []
|
||||
if strict:
|
||||
@@ -373,6 +382,11 @@ def decode(s: Union[str, bytes, bytearray], strict: bool = False, uts46: bool =
|
||||
raise IDNAError('Invalid ASCII in A-label')
|
||||
if uts46:
|
||||
s = uts46_remap(s, std3_rules, False)
|
||||
+ # See encode() for rationale; the same bound applies because every
|
||||
+ # legal A-domain is at most 254 octets and every codepoint of a
|
||||
+ # legal U-domain contributes at least one octet to its A-form.
|
||||
+ if len(s) > 254:
|
||||
+ raise IDNAError("Domain too long")
|
||||
trailing_dot = False
|
||||
result = []
|
||||
if not strict:
|
||||
diff --git a/tests/test_idna.py b/tests/test_idna.py
|
||||
index 81afb32..5001b48 100755
|
||||
--- a/tests/test_idna.py
|
||||
+++ b/tests/test_idna.py
|
||||
@@ -78,6 +78,19 @@ class IDNATests(unittest.TestCase):
|
||||
self.assertFalse(idna.valid_label_length('a' * 64))
|
||||
self.assertRaises(idna.IDNAError, idna.encode, 'a' * 64)
|
||||
|
||||
+ def test_oversized_input_rejected_promptly(self):
|
||||
+ # GHSA-65pc-fj4g-8rjx: encode/decode must reject inputs that
|
||||
+ # exceed the maximum DNS domain length before per-codepoint
|
||||
+ # validation runs, so labels dominated by CONTEXTO codepoints
|
||||
+ # cannot drive validation into quadratic time.
|
||||
+ import time
|
||||
+
|
||||
+ for payload in ("٠" * 8000, "・" * 8000 + "漢"):
|
||||
+ start = time.perf_counter()
|
||||
+ self.assertRaises(idna.IDNAError, idna.encode, payload)
|
||||
+ self.assertRaises(idna.IDNAError, idna.decode, payload)
|
||||
+ self.assertLess(time.perf_counter() - start, 1.0)
|
||||
+
|
||||
def test_check_bidi(self):
|
||||
|
||||
l = '\u0061'
|
||||
|
||||
From 219662569606146771ac69fac5939d3308159064 Mon Sep 17 00:00:00 2001
|
||||
From: metsw24-max <metsw24@gmail.com>
|
||||
Date: Mon, 11 May 2026 20:59:30 +0530
|
||||
Subject: [PATCH 2/2] Enforce early length limits in check_label
|
||||
|
||||
---
|
||||
idna/core.py | 11 +++++++++++
|
||||
tests/test_idna.py | 24 ++++++++++++++++++++++++
|
||||
2 files changed, 35 insertions(+)
|
||||
|
||||
diff --git a/idna/core.py b/idna/core.py
|
||||
index a549326..f863141 100644
|
||||
--- a/idna/core.py
|
||||
+++ b/idna/core.py
|
||||
@@ -230,6 +230,17 @@ def check_label(label: Union[str, bytes, bytearray]) -> None:
|
||||
label = label.decode('utf-8')
|
||||
if len(label) == 0:
|
||||
raise IDNAError('Empty Label')
|
||||
+ # Reject oversized labels before per-codepoint validation runs.
|
||||
+ # CONTEXTJ/CONTEXTO checks scan the whole label per codepoint, so an
|
||||
+ # uncapped label drives validation into quadratic time
|
||||
+ # (GHSA-65pc-fj4g-8rjx / CVE-2024-3651). encode()/decode() cap the
|
||||
+ # whole-domain length; this cap protects direct callers of
|
||||
+ # alabel/ulabel/check_label and the idna2008 incremental codec.
|
||||
+ # Use the whole-domain bound rather than the per-label DNS bound so
|
||||
+ # that UTS #46 lenient decoding of labels longer than 63 chars is
|
||||
+ # preserved.
|
||||
+ if not valid_string_length(label, trailing_dot=True):
|
||||
+ raise IDNAError('Label too long')
|
||||
|
||||
check_nfc(label)
|
||||
check_hyphen_ok(label)
|
||||
diff --git a/tests/test_idna.py b/tests/test_idna.py
|
||||
index 5001b48..2dc0892 100755
|
||||
--- a/tests/test_idna.py
|
||||
+++ b/tests/test_idna.py
|
||||
@@ -91,6 +91,30 @@ class IDNATests(unittest.TestCase):
|
||||
self.assertRaises(idna.IDNAError, idna.decode, payload)
|
||||
self.assertLess(time.perf_counter() - start, 1.0)
|
||||
|
||||
+ def test_oversized_label_rejected_promptly(self):
|
||||
+ # The whole-domain cap in encode()/decode() does not cover direct
|
||||
+ # callers of alabel/ulabel/check_label, nor the idna2008
|
||||
+ # incremental codec which calls alabel/ulabel per label. Without a
|
||||
+ # per-label cap, a single oversized CONTEXTO-heavy label still
|
||||
+ # drives validation into quadratic time.
|
||||
+ import codecs
|
||||
+ import time
|
||||
+
|
||||
+ import idna.codec # noqa: F401 (register the idna2008 codec)
|
||||
+
|
||||
+ payload = "・" * 8000 + "漢"
|
||||
+ start = time.perf_counter()
|
||||
+ self.assertRaises(idna.IDNAError, idna.check_label, payload)
|
||||
+ self.assertRaises(idna.IDNAError, idna.alabel, payload)
|
||||
+ self.assertRaises(idna.IDNAError, idna.ulabel, payload)
|
||||
+ self.assertRaises(
|
||||
+ idna.IDNAError,
|
||||
+ codecs.getincrementalencoder("idna2008")().encode,
|
||||
+ payload,
|
||||
+ True,
|
||||
+ )
|
||||
+ self.assertLess(time.perf_counter() - start, 1.0)
|
||||
+
|
||||
def test_check_bidi(self):
|
||||
|
||||
l = '\u0061'
|
||||
@ -1,8 +1,8 @@
|
||||
## START: Set by rpmautospec
|
||||
## (rpmautospec version 0.6.5)
|
||||
## (rpmautospec version 0.8.1)
|
||||
## RPMAUTOSPEC: autorelease, autochangelog
|
||||
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
|
||||
release_number = 4;
|
||||
release_number = 6;
|
||||
base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
|
||||
print(release_number + base_release_number - 1);
|
||||
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
|
||||
@ -18,6 +18,11 @@ Summary: Internationalized Domain Names in Applications (IDNA)
|
||||
License: BSD-3-Clause
|
||||
URL: https://github.com/kjd/idna
|
||||
Source0: https://pypi.io/packages/source/i/%{srcname}/%{srcname}-%{version}.tar.gz
|
||||
|
||||
# https://github.com/kjd/idna/commit/c0dda4501df5d91c3181ce6f962dc5de74e82cc1
|
||||
# https://github.com/kjd/idna/commit/e1cb465b6376f33306a26f467d197edbcd01c4b9
|
||||
Patch: CVE-2026-45409.patch
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
BuildRequires: python3-devel
|
||||
@ -71,6 +76,12 @@ rm -rf %{srcname}.egg-info
|
||||
|
||||
%changelog
|
||||
## START: Generated by rpmautospec
|
||||
* Mon Aug 10 2026 RHEL Packaging Agent <redhat-ymir-agent@redhat.com> - 3.7-6
|
||||
- Fix CVE-2026-45409: quadratic time complexity in IDNA validation
|
||||
|
||||
* Mon Nov 11 2024 Miro Hrončok <miro@hroncok.cz> - 3.7-5
|
||||
- rpminspect: Disable the unicode inspection
|
||||
|
||||
* Tue Oct 29 2024 Troy Dawson <tdawson@redhat.com> - 3.7-4
|
||||
- Bump release for October 2024 mass rebuild:
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user