Skip to content

Commit de8c00b

Browse files
author
Saakshaat Singh
committed
fix
1 parent 40533a4 commit de8c00b

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

‎Lib/poplib.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@ def _putline(self, line):
122122
def _putcmd(self, line):
123123
if self._debugging: print('*cmd*', repr(line))
124124
line = bytes(line, self.encoding)
125+
if re.search(b'[\x00-\x1F\x7F]', line):
126+
raise ValueError('Control characters not allowed in commands')
125127
self._putline(line)
126128

127129

‎Lib/test/test_poplib.py‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,14 @@ def test_quit(self):
395395
self.assertIsNone(self.client.sock)
396396
self.assertIsNone(self.client.file)
397397

398+
def test_control_characters(self):
399+
for char in test_support.control_characters_c0():
400+
with self.subTest(char=char):
401+
with self.assertRaises(ValueError):
402+
self.client.user(f'user{char}')
403+
with self.assertRaises(ValueError):
404+
self.client.pass_(f'{char}pass')
405+
398406
@requires_ssl
399407
def test_stls_capa(self):
400408
capa = self.client.capa()
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Reject control characters in POP3 commands (CVE-2025-15367).

0 commit comments

Comments
 (0)