From 7852c7e89b1f66250b071bed7e2a46d34c2cd534 Mon Sep 17 00:00:00 2001 From: Saakshaat Singh <97133528+saakshaat-singh@users.noreply.github.com> Date: Mon, 16 Nov 2026 14:11:44 -0500 Subject: [PATCH] fix --- Lib/poplib.py | 2 ++ Lib/test/test_poplib.py | 8 ++++++++ .../2026-11-16-19-00-00.gh-issue-143923.pop312.rst | 1 + 3 files changed, 11 insertions(+) create mode 100644 Misc/NEWS.d/next/Security/2026-11-16-19-00-00.gh-issue-143923.pop312.rst diff --git a/Lib/poplib.py b/Lib/poplib.py index 9eb662d0000cb1b..5c83522504d6346 100644 --- a/Lib/poplib.py +++ b/Lib/poplib.py @@ -122,6 +122,8 @@ def _putline(self, line): def _putcmd(self, line): if self._debugging: print('*cmd*', repr(line)) line = bytes(line, self.encoding) + if re.search(b'[\x00-\x1F\x7F]', line): + raise ValueError('Control characters not allowed in commands') self._putline(line) diff --git a/Lib/test/test_poplib.py b/Lib/test/test_poplib.py index f1ebbeafe0cfb4d..46d788ab0c25e86 100644 --- a/Lib/test/test_poplib.py +++ b/Lib/test/test_poplib.py @@ -395,6 +395,14 @@ def test_quit(self): self.assertIsNone(self.client.sock) self.assertIsNone(self.client.file) + def test_control_characters(self): + for char in test_support.control_characters_c0(): + with self.subTest(char=char): + with self.assertRaises(ValueError): + self.client.user(f'user{char}') + with self.assertRaises(ValueError): + self.client.pass_(f'{char}pass') + @requires_ssl def test_stls_capa(self): capa = self.client.capa() diff --git a/Misc/NEWS.d/next/Security/2026-11-16-19-00-00.gh-issue-143923.pop312.rst b/Misc/NEWS.d/next/Security/2026-11-16-19-00-00.gh-issue-143923.pop312.rst new file mode 100644 index 000000000000000..18379d8d499b041 --- /dev/null +++ b/Misc/NEWS.d/next/Security/2026-11-16-19-00-00.gh-issue-143923.pop312.rst @@ -0,0 +1 @@ +Reject control characters in POP3 commands (CVE-2025-15367).