VAITP Dataset

← Back to the dataset

CVE-2014-7143

Python Twisted 14.0 HTTP client ignores trustRoot, causing a security vulnerability

  • CVSS 7.5
  • CWE-295 Improper Certificate Validation
  • Authentication, Authorization, and Session Management
  • Remote

Python Twisted 14.0 trustRoot is not respected in HTTP client

CVSS base score
7.5
Published
2019-11-12
OWASP
A05 Security Misconfiguration
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Authentication, Authorization, and Session Management
Subcategory
Insecure Authentication Mechanisms
Accessibility scope
Remote
Impact
Unauthorized Access
Fixed by upgrading
Yes

Solution

Update Twisted to version 14.0.1 or higher.

Vulnerable code sample

from twisted.web.client import Agent
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from twisted.web.http_headers import Headers

class AgentClass(Agent):
    def __init__(self, reactor, contextFactory=None):
        super().__init__(reactor, contextFactory)

@inlineCallbacks
def fetch_url(url):
    agent = AgentClass(reactor)
    response = yield agent.request(
        b'GET',
        url.encode('utf-8'),
        Headers({'User -Agent': ['Twisted Web Client']}),
        None
    )
    print("Response code:", response.code)

fetch_url("https://example.com")
reactor.run()

Patched code sample

from twisted.web.client import Agent
from twisted.web.http import BrowserLikePolicyForHTTPS
from twisted.internet import reactor
from twisted.internet.defer import inlineCallbacks
from twisted.web.http_headers import Headers
from twisted.web.http import Request

class AgentClass(Agent):
    def __init__(self, reactor, contextFactory=None):
        super().__init__(reactor, contextFactory)
        self.trustRoot = BrowserLikePolicyForHTTPS()

@inlineCallbacks
def fetch_url(url):
    agent = AgentClass(reactor)
    response = yield agent.request(
        b'GET',
        url.encode('utf-8'),
        Headers({'User -Agent': ['Twisted Web Client']}),
        None
    )
    print("Response code:", response.code)

fetch_url("https://example.com")
reactor.run()

Cite this entry

@misc{vaitp:cve20147143,
  title        = {{Python Twisted 14.0 HTTP client ignores trustRoot, causing a security vulnerability}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2019},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2014-7143},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-7143/}}
}
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 ::