CVE-2026-103022
Urwid <4.0.7 mishandles encoding/decoding, causing crashes and FD leaks leading to DoS.
- CVSS 5.3
- CWE-116
- Input Validation and Sanitization
- Remote
Urwid is a console user interface library for Python. Prior to 4.0.7, handle_short_request() in urwid/display/web.py performs unguarded character encoding on POST input and unguarded UTF-8 decoding on polling update socket output. A remote attacker who obtains a valid X-Urwid-ID session token can submit non-ASCII POST data that raises UnicodeEncodeError, while non-UTF-8 polling output raises UnicodeDecodeError, causing the CGI handler to return an error and terminate request processing. The POST exception path also leaves an opened file descriptor unclosed for the CGI process lifetime, so repeated requests can cause denial of service for the web display interface. This issue is fixed in version 4.0.7.
- CWE
- CWE-116
- CVSS base score
- 5.3
- Published
- 2026-11-06
- OWASP
- A04 Insecure Design
- Orthogonal defect classification
- Checking
- Code defect classification
- Missing Check
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Urwid
- Fixed by upgrading
- Yes
Solution
Upgrade Urwid to version 4.0.7 (or later).
Vulnerable code sample
import socket
def handle_short_request(post_data: str, session_token: str, poll_sock: socket.socket):
# VULNERABLE: unguarded encode/decode may raise Unicode errors and leak fd
if not session_token.startswith("X-Urwid-ID-"):
raise PermissionError("Invalid session")
# encode POST data using default encoding (ASCII) – can raise UnicodeEncodeError
encoded = post_data.encode()
# write to a temporary file descriptor (simulated)
fd = open("/tmp/urwid_tmp", "wb")
fd.write(encoded)
# read polling update without error handling – can raise UnicodeDecodeError
poll_sock.settimeout(1.0)
raw = poll_sock.recv(1024)
decoded = raw.decode()
# process decoded data (placeholder)
return decodedPatched code sample
import socket
def handle_short_request(post_data: str, session_token: str, poll_sock: socket.socket):
# FIX: safe encode/decode and ensure fd is closed
if not session_token.startswith("X-Urwid-ID-"):
raise PermissionError("Invalid session")
# safely encode POST data as UTF-8, ignoring problematic chars
encoded = post_data.encode("utf-8", errors="ignore")
fd = open("/tmp/urwid_tmp", "wb")
try:
fd.write(encoded)
finally:
fd.close()
# safely decode polling data, replacing invalid sequences
poll_sock.settimeout(1.0)
raw = poll_sock.recv(1024)
decoded = raw.decode("utf-8", errors="replace")
return decodedPublished fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- Fix encoding handling by web display (#1201) (urwid/urwid)
urwid/display/web.py,urwid/display/web.py · handle_short_request,urwid/display/web.py · Screen.set_input_timeouts
Cite this entry
@misc{vaitp:cve2026103022,
title = {{Urwid <4.0.7 mishandles encoding/decoding, causing crashes and FD leaks leading to DoS.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-103022},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-103022/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
