CVE-2024-6891
Python code injection vulnerability during login with valid credentials.
- CVSS 8.8
- CWE-94
- Input Validation and Sanitization
- Remote
Attackers with a valid username and password can exploit a python code injection vulnerability during the natural login flow.
- CWE
- CWE-94
- CVSS base score
- 8.8
- Published
- 2024-08-07
- OWASP
- A03 Injection
- Orthogonal defect classification
- Interface
- Code defect classification
- Incorrect Interface
- Category
- Input Validation and Sanitization
- Subcategory
- Command Injection
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- Python
- Fixed by upgrading
- Yes
Solution
Sanitize and validate all user inputs, and upgrade to the latest version of the framework or library that addresses this vulnerability.
Vulnerable code sample
def login(username, password):
exec(f"if authenticate('{username}', '{password}'): print('Login successful!') else: print('Invalid credentials.')")
def authenticate(username, password):
return username == "validUser" and password == "validPass"
login("validUser", "validPass")Patched code sample
import re
def sanitize_input(user_input):
return re.sub(r'[^\w\s]', '', user_input)
def login(username, password):
sanitized_username = sanitize_input(username)
sanitized_password = sanitize_input(password)
if authenticate(sanitized_username, sanitized_password):
print("Login successful!")
else:
print("Invalid credentials.")
def authenticate(username, password):
return username == "validUser " and password == "validPass"
login("validUser ", "validPass")Payload
"; __import__('os').system('whoami') #"
Cite this entry
@misc{vaitp:cve20246891,
title = {{Python code injection vulnerability during login with valid credentials.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2024},
note = {VAITP Python Vulnerability Dataset, entry CVE-2024-6891},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2024-6891/}}
}
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 ::
