CVE-2011-1157
XSS in Universal Feed Parser 5.x < 5.0.1 via malformed XML comments
- CVSS 4.3
- CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
- Input Validation and Sanitization
- Remote
Cross-site scripting (XSS) vulnerability in feedparser.py in Universal Feed Parser (aka feedparser or python-feedparser) 5.x before 5.0.1 allows remote attackers to inject arbitrary web script or HTML via malformed XML comments.
- CVSS base score
- 4.3
- Published
- 2011-04-11
- OWASP
- A03 Injection
- Orthogonal defect classification
- Function
- Code defect classification
- Incorrect Functionality
- Category
- Input Validation and Sanitization
- Subcategory
- Insecure Parsing or Deserialization
- Accessibility scope
- Remote
- Impact
- Arbitrary Code Execution
- Affected component
- feedparser
- Fixed by upgrading
- Yes
Solution
Update Universal Feed Parser to version 5.0.1 or higher.
Vulnerable code sample
import re
def parse_feed(feed_content):
# Example of parsing feed content
# This regex captures XML comments which could be exploited
malicious_pattern = re.compile(r'<!--(.*?)-->')
# Directly include the malicious content without sanitization
parsed_content = malicious_pattern.sub(lambda m: m.group(1), feed_content)
# Continue parsing the parsed_content
# (Parsing logic goes here)
return parsed_content
# Example usage
feed = "<!--<script>alert('XSS')</script>--> <item>Example Item</item>"
parsed_feed = parse_feed(feed)
print(parsed_feed)Patched code sample
import re
from xml.sax import saxutils
def sanitize_input(input_data):
# Escape HTML special characters to prevent XSS
return saxutils.escape(input_data)
def parse_feed(feed_content):
# Example of parsing feed content
# This regex is a simplistic representation of the vulnerability
# It captures XML comments which could be exploited
malicious_pattern = re.compile(r'<!--(.*?)-->')
# Replace any found malicious comments with sanitized content
sanitized_content = malicious_pattern.sub(lambda m: sanitize_input(m.group(0)), feed_content)
# Continue parsing the sanitized_content
# (Parsing logic goes here)
return sanitized_content
# Example usage
feed = "<!--<script>alert('XSS')</script>--> <item>Example Item</item>"
parsed_feed = parse_feed(feed)
print(parsed_feed)Cite this entry
@misc{vaitp:cve20111157,
title = {{XSS in Universal Feed Parser 5.x < 5.0.1 via malformed XML comments}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2011},
note = {VAITP Python Vulnerability Dataset, entry CVE-2011-1157},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2011-1157/}}
}
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 ::
