CVE-2026-8838
Unsafe eval() in the Redshift driver allows client-side code execution.
- CVSS 9.3
- CWE-94
- Input Validation and Sanitization
- Remote
Unsafe use of Python's eval() on server-received data in the vector_in() function in amazon-redshift-python-driver before 2.1.14 allows a rogue server or man-in-the-middle actor to execute arbitrary code on the client. To remediate this issue, users should upgrade to version 2.1.14.
- CWE
- CWE-94
- CVSS base score
- 9.3
- Published
- 2026-05-18
- OWASP
- A08 Software and Data Integrity Failures
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Algorithm
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- amazon-redsh
- Fixed by upgrading
- Yes
Solution
Upgrade `amazon-redshift-python-driver` to version 2.1.14 or later.
Vulnerable code sample
def vector_in(value):
if value is None:
return None
# The vulnerability lies in using eval() on a string received from the server.
# An attacker can replace the expected array-like string (e.g., "[1,2,3]")
# with a malicious payload to achieve code execution.
return eval(value)Patched code sample
import ast
def fixed_vector_in(data_from_server: str):
"""
Represents the fixed version of the vulnerable function.
The original vulnerability (CVE-2026-8838) was due to the use of `eval()`
on data received from a server. A malicious actor could provide a
string containing arbitrary code, which `eval()` would execute.
This fix replaces the dangerous `eval()` with `ast.literal_eval()`,
which safely parses only Python literals (e.g., strings, numbers, lists,
dicts) and raises an exception for any other code, preventing execution.
"""
# The original vulnerable code would have been:
# return eval(data_from_server)
# The fixed code safely evaluates the string:
return ast.literal_eval(data_from_server)
# --- Demonstration of how the fix works ---
# 1. Example of a legitimate server response (a list of values).
# This is processed correctly and safely by the fixed function.
legitimate_data = "['value1', 123, 'value2']"
parsed_legitimate_data = fixed_vector_in(legitimate_data)
# The variable `parsed_legitimate_data` now holds the list: ['value1', 123, 'value2']
# 2. Example of a malicious server response.
# The `eval()` function would have executed this code.
malicious_payload = "__import__('os').system('echo Malicious code executed!')"
try:
# The fixed function `fixed_vector_in` is called.
# Instead of executing the code, `ast.literal_eval` detects that the
# string is not a literal and raises a ValueError.
fixed_vector_in(malicious_payload)
except ValueError:
# This exception correctly prevents the arbitrary code from running.
# The vulnerability is successfully mitigated.
passPayload
__import__('os').system('touch /tmp/pwned')
Cite this entry
@misc{vaitp:cve20268838,
title = {{Unsafe eval() in the Redshift driver allows client-side code execution.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-8838},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-8838/}}
}
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 ::
