VYPR
Medium severityOSV Advisory· Published Jan 20, 2026· Updated Apr 15, 2026

CVE-2025-15282

CVE-2025-15282

Description

User-controlled data URLs parsed by urllib.request.DataHandler allow injecting headers through newlines in the data URL mediatype.

Affected products

1

Patches

6
a35ca3be5842

[3.13] gh-143925: Reject control characters in data: URL mediatypes (#144111)

https://github.com/python/cpythonSeth Michael LarsonJan 25, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -12,6 +12,7 @@
     from test.support import os_helper
     from test.support import socket_helper
     from test.support import warnings_helper
    +from test.support import control_characters_c0
     from test.support.testcase import ExtraAssertions
     import os
     try:
    @@ -677,6 +678,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1636,6 +1636,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    
4ed11d3cd288

[3.12] gh-143925: Reject control characters in data: URL mediatypes (#144113)

https://github.com/python/cpythonSeth Michael LarsonJan 25, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -12,6 +12,7 @@
     from test.support import os_helper
     from test.support import socket_helper
     from test.support import warnings_helper
    +from test.support import control_characters_c0
     import os
     try:
         import ssl
    @@ -688,6 +689,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1655,6 +1655,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    
3f396ca9d7bb

[3.11] gh-143925: Reject control characters in data: URL mediatypes (#144114)

https://github.com/python/cpythonSeth Michael LarsonJan 25, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -12,6 +12,7 @@
     from test.support import os_helper
     from test.support import socket_helper
     from test.support import warnings_helper
    +from test.support import control_characters_c0
     import os
     try:
         import ssl
    @@ -683,6 +684,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1654,6 +1654,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    
34d76b00dabd

[3.10] gh-143925: Reject control characters in data: URL mediatypes (#144115)

https://github.com/python/cpythonSeth Michael LarsonJan 25, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -11,6 +11,7 @@
     from test import support
     from test.support import os_helper
     from test.support import warnings_helper
    +from test.support import control_characters_c0
     import os
     try:
         import ssl
    @@ -683,6 +684,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1654,6 +1654,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    
05356b1cc153

[3.14] gh-143925: Reject control characters in data: URL mediatypes (#144084)

https://github.com/python/cpythonMiss Islington (bot)Jan 23, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -10,6 +10,7 @@
     from test import support
     from test.support import os_helper
     from test.support import socket_helper
    +from test.support import control_characters_c0
     import os
     import socket
     try:
    @@ -590,6 +591,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1634,6 +1634,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    
f25509e78e8b

gh-143925: Reject control characters in data: URL mediatypes

https://github.com/python/cpythonSeth Michael LarsonJan 20, 2026via osv
3 files changed · +14 0
  • Lib/test/test_urllib.py+8 0 modified
    @@ -10,6 +10,7 @@
     from test import support
     from test.support import os_helper
     from test.support import socket_helper
    +from test.support import control_characters_c0
     import os
     import socket
     try:
    @@ -590,6 +591,13 @@ def test_invalid_base64_data(self):
             # missing padding character
             self.assertRaises(ValueError,urllib.request.urlopen,'data:;base64,Cg=')
     
    +    def test_invalid_mediatype(self):
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html;{c0},data')
    +        for c0 in control_characters_c0():
    +            self.assertRaises(ValueError,urllib.request.urlopen,
    +                              f'data:text/html{c0};base64,ZGF0YQ==')
     
     class urlretrieve_FileTests(unittest.TestCase):
         """Test urllib.urlretrieve() on local files"""
    
  • Lib/urllib/request.py+5 0 modified
    @@ -1636,6 +1636,11 @@ def data_open(self, req):
             scheme, data = url.split(":",1)
             mediatype, data = data.split(",",1)
     
    +        # Disallow control characters within mediatype.
    +        if re.search(r"[\x00-\x1F\x7F]", mediatype):
    +            raise ValueError(
    +                "Control characters not allowed in data: mediatype")
    +
             # even base64 encoded data URLs might be quoted so unquote in any case:
             data = unquote_to_bytes(data)
             if mediatype.endswith(";base64"):
    
  • Misc/NEWS.d/next/Security/2026-01-16-11-51-19.gh-issue-143925.mrtcHW.rst+1 0 added
    @@ -0,0 +1 @@
    +Reject control characters in ``data:`` URL media types.
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

9

News mentions

0

No linked articles in our index yet.