VAITP Dataset

← Back to the dataset

CVE-2015-4706

IPython 3.x < 3.2 XSS in /api/contents

  • CVSS 6.1
  • CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
  • Configuration Issues
  • Remote

Cross-site scripting (XSS) vulnerability in IPython 3.x before 3.2 allows remote attackers to inject arbitrary web script or HTML via vectors involving JSON error messages and the /api/contents path.

CVSS base score
6.1
Published
2017-09-21
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Configuration Issues
Subcategory
Cross-Site Scripting (XSS)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Fixed by upgrading
Yes

Solution

Update to IPython version 3.2 or higher

Vulnerable code sample

from flask import Flask, jsonify, request

app = Flask(__name__)

@app.route('/api/contents', methods=['POST'])
def contents():
    error_message = request.json.get('error_message', '')

    response = {
        'status': 'error',
        'message': error_message
    }
    return jsonify(response)

if __name__ == '__main__':
    app.run()

Patched code sample

from flask import Flask, jsonify, request, escape

app = Flask(__name__)

@app.route('/api/contents', methods=['POST'])
def contents():
    error_message = request.json.get('error_message', '')

    escaped_error_message = escape(error_message)

    response = {
        'status': 'error',
        'message': escaped_error_message
    }
    return jsonify(response)

if __name__ == '__main__':
    app.run()

Cite this entry

@misc{vaitp:cve20154706,
  title        = {{IPython 3.x < 3.2 XSS in /api/contents}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2017},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2015-4706},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2015-4706/}}
}
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 ::