VAITP Dataset

← Back to the dataset

CVE-2014-3429

IPython Notebook 0.12-1.x WebSocket Origin Validation Bypass

  • CVSS 6.8
  • CWE-94
  • Configuration Issues
  • Remote

IPython Notebook 0.12 through 1.x before 1.2 does not validate the origin of websocket requests, which allows remote attackers to execute arbitrary code by leveraging knowledge of the kernel id and a crafted page.

CVSS base score
6.8
Published
2014-08-07
OWASP
A07 Identification and Authentication Failures
Orthogonal defect classification
Interface
Code defect classification
Incorrect Interface
Category
Configuration Issues
Subcategory
Cross-Site Request Forgery (CSRF)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Fixed by upgrading
Yes

Solution

Update to IPython Notebook version 1.2 or higher

Vulnerable code sample

import tornado.web
import tornado.websocket
import json

class WebSocket(tornado.websocket.WebSocketHandler):
    def open(self):
        print("WebSocket opened")

    def on_message(self, message):
        data = json.loads(message)

    def on_close(self):
        print("WebSocket closed")

application = tornado.web.Application([
    (r'/websocket', WebSocket),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Patched code sample

import tornado.web
import tornado.websocket
import tornado.ioloop
import json
import logging

class WebSocket(tornado.websocket.WebSocketHandler):
    def open(self):
        print("WebSocket opened")

    def on_message(self, message):
        try:
            data = json.loads(message)

            if not isinstance(data, dict) or "type" not in data:
                self.close(reason="Invalid message format")
                return

        except json.JSONDecodeError:
            self.close(reason="Invalid JSON format")
        except Exception as e:
            logging.error(f"Error while processing message: {e}")
            self.close(reason="Internal server error")

    def on_close(self):
        print("WebSocket closed")

    def check_origin(self, origin):
        allowed_origins = ["http://your-allowed-origin.com"]
        if origin not in allowed_origins:
            return False
        return True

application = tornado.web.Application([
    (r'/websocket', WebSocket),
])

if __name__ == "__main__":
    application.listen(8888)
    tornado.ioloop.IOLoop.current().start()

Cite this entry

@misc{vaitp:cve20143429,
  title        = {{IPython Notebook 0.12-1.x WebSocket Origin Validation Bypass}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2014},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2014-3429},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-3429/}}
}
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 ::