{"id":633,"cve":"CVE-2011-1157","cve_url":"https:\/\/www.cvedetails.com\/cve\/CVE-2011-1157","cwe":"CWE-79 Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')","cwe_number":79,"cwe_url":"https:\/\/cwe.mitre.org\/data\/definitions\/79","cvss_score":4.3,"published":"2011-04-11","owasp":"A03 Injection","odc":"Function","cdc":"Incorrect Functionality","category":"Input Validation and Sanitization","subcategory":"Insecure Parsing or Deserialization","scope":"Remote","impact":"Arbitrary Code Execution","summary":"XSS in Universal Feed Parser 5.x < 5.0.1 via malformed XML comments","permalink":"https:\/\/netpack.pt\/vaitp\/vulnerability\/CVE-2011-1157\/","description":"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.","solution":"Update Universal Feed Parser to version 5.0.1 or higher.","affected_component":"feedparser","fixed_by_upgrading":true,"vulnerable_code":"import re\n\ndef parse_feed(feed_content):\n    # Example of parsing feed content\n    # This regex captures XML comments which could be exploited\n    malicious_pattern = re.compile(r'<!--(.*?)-->')\n    \n    # Directly include the malicious content without sanitization\n    parsed_content = malicious_pattern.sub(lambda m: m.group(1), feed_content)\n    \n    # Continue parsing the parsed_content\n    # (Parsing logic goes here)\n    \n    return parsed_content\n\n# Example usage\nfeed = \"<!--<script>alert('XSS')<\/script>--> <item>Example Item<\/item>\"\nparsed_feed = parse_feed(feed)\nprint(parsed_feed)","patched_code":"import re\nfrom xml.sax import saxutils\n\ndef sanitize_input(input_data):\n    # Escape HTML special characters to prevent XSS\n    return saxutils.escape(input_data)\n\ndef parse_feed(feed_content):\n    # Example of parsing feed content\n    # This regex is a simplistic representation of the vulnerability\n    # It captures XML comments which could be exploited\n    malicious_pattern = re.compile(r'<!--(.*?)-->')\n    \n    # Replace any found malicious comments with sanitized content\n    sanitized_content = malicious_pattern.sub(lambda m: sanitize_input(m.group(0)), feed_content)\n    \n    # Continue parsing the sanitized_content\n    # (Parsing logic goes here)\n    \n    return sanitized_content\n\n# Example usage\nfeed = \"<!--<script>alert('XSS')<\/script>--> <item>Example Item<\/item>\"\nparsed_feed = parse_feed(feed)\nprint(parsed_feed)","payload_needed":false,"payload":null,"payload_status":"none","published_fix":[],"references":null}