Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Lib/poplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down
8 changes: 8 additions & 0 deletions Lib/test/test_poplib.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Reject control characters in POP3 commands (CVE-2025-15367).
Loading