summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch
diff options
context:
space:
mode:
authorAnil Dongare <adongare@cisco.com>2025-11-07 02:21:15 -0800
committerAnuj Mittal <anuj.mittal@oss.qualcomm.com>2025-11-12 11:28:54 +0530
commit07810b11ef35d12cdb2d77f07464562f6a2011ca (patch)
treec1803661fc4fe720c37e0c78f28e63f7215a651e /meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch
parente8a6ea8f4b8c9e7973a6e9e21afaa8eeb989fc35 (diff)
downloadmeta-openembedded-07810b11ef35d12cdb2d77f07464562f6a2011ca.tar.gz
python3-django 5.0.11: Fix CVE-2025-26699
Upstream Repository: https://github.com/django/django.git Bug Details: https://nvd.nist.gov/vuln/detail/CVE-2025-26699 Type: Security Fix CVE: CVE-2025-26699 Score: 7.5 Patch: https://github.com/django/django/commit/e88f7376fe68 Signed-off-by: Anil Dongare <adongare@cisco.com> Signed-off-by: Anuj Mittal <anuj.mittal@oss.qualcomm.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch')
-rw-r--r--meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch100
1 files changed, 100 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch b/meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch
new file mode 100644
index 0000000000..bba65eaee3
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-django/CVE-2025-26699.patch
@@ -0,0 +1,100 @@
1From 5fd7c868791b635ef20d2991cc028516b9021dd4 Mon Sep 17 00:00:00 2001
2From: Sarah Boyce <42296566+sarahboyce@users.noreply.github.com>
3Date: Tue, 25 Feb 2025 09:40:54 +0100
4Subject: [PATCH] [5.0.x] Fixed CVE-2025-26699 -- Mitigated potential DoS in
5 wordwrap template filter.
6
7Thanks sw0rd1ight for the report.
8
9Backport of 55d89e25f4115c5674cdd9b9bcba2bb2bb6d820b from main.
10
11CVE: CVE-2025-26699
12Upstream-Status: Backport [https://github.com/django/django/commit/e88f7376fe68]
13
14Backport Changes:
15- The fix has been adapted from the upstream Django v4.2.20 patch for
16 CVE-2025-26699, applied to the python3-django_5.0.11.bb recipe.
17
18- The upstream patch includes changes to a 4.2.20.txt release-note file.
19 This file does not exist in the Django 5.0.11 source tree, so it was
20 intentionally omitted from this backport.
21
22- Only the relevant code changes from the upstream patch were applied.
23 No functional differences exist in the vulnerable logic between
24 Django 4.2.x and 5.0.x.
25
26(cherry picked from commit e88f7376fe68dbf4ebaf11fad1513ce700b45860)
27Signed-off-by: Anil Dongare <adongare@cisco.com>
28---
29 django/utils/text.py | 28 +++++++------------
30 .../filter_tests/test_wordwrap.py | 11 ++++++++
31 2 files changed, 21 insertions(+), 18 deletions(-)
32
33diff --git a/django/utils/text.py b/django/utils/text.py
34index d992f80dd2..36ab6a9efc 100644
35--- a/django/utils/text.py
36+++ b/django/utils/text.py
37@@ -1,6 +1,7 @@
38 import gzip
39 import re
40 import secrets
41+import textwrap
42 import unicodedata
43 from gzip import GzipFile
44 from gzip import compress as gzip_compress
45@@ -97,24 +98,15 @@ def wrap(text, width):
46 ``width``.
47 """
48
49- def _generator():
50- for line in text.splitlines(True): # True keeps trailing linebreaks
51- max_width = min((line.endswith("\n") and width + 1 or width), width)
52- while len(line) > max_width:
53- space = line[: max_width + 1].rfind(" ") + 1
54- if space == 0:
55- space = line.find(" ") + 1
56- if space == 0:
57- yield line
58- line = ""
59- break
60- yield "%s\n" % line[: space - 1]
61- line = line[space:]
62- max_width = min((line.endswith("\n") and width + 1 or width), width)
63- if line:
64- yield line
65-
66- return "".join(_generator())
67+ wrapper = textwrap.TextWrapper(
68+ width=width,
69+ break_long_words=False,
70+ break_on_hyphens=False,
71+ )
72+ result = []
73+ for line in text.splitlines(True):
74+ result.extend(wrapper.wrap(line))
75+ return "\n".join(result)
76
77
78 def add_truncation_text(text, truncate=None):
79diff --git a/tests/template_tests/filter_tests/test_wordwrap.py b/tests/template_tests/filter_tests/test_wordwrap.py
80index 88fbd274da..4afa1dd234 100644
81--- a/tests/template_tests/filter_tests/test_wordwrap.py
82+++ b/tests/template_tests/filter_tests/test_wordwrap.py
83@@ -78,3 +78,14 @@ class FunctionTests(SimpleTestCase):
84 "this is a long\nparagraph of\ntext that\nreally needs\nto be wrapped\n"
85 "I'm afraid",
86 )
87+
88+ def test_wrap_long_text(self):
89+ long_text = (
90+ "this is a long paragraph of text that really needs"
91+ " to be wrapped I'm afraid " * 20_000
92+ )
93+ self.assertIn(
94+ "this is a\nlong\nparagraph\nof text\nthat\nreally\nneeds to\nbe wrapped\n"
95+ "I'm afraid",
96+ wordwrap(long_text, 10),
97+ )
98--
992.43.5
100