VAITP Dataset

← Back to the dataset

CVE-2014-0105

Python-keystoneclient before 0.7.0 allows authenticated remote users to gain privileges via a memcache-related issue

  • CVSS 6.0
  • CWE-255
  • Authentication, Authorization, and Session Management
  • Remote

The auth_token middleware in the OpenStack Python client library for Keystone (aka python-keystoneclient) before 0.7.0 does not properly retrieve user tokens from memcache, which allows remote authenticated users to gain privileges in opportunistic circumstances via a large number of requests, related to an "interaction between eventlet and python-memcached."

CVSS base score
6.0
Published
2014-04-15
OWASP
A07 Identification and Authentication Failures
Orthogonal defect classification
Function
Code defect classification
Incorrect Functionality
Category
Authentication, Authorization, and Session Management
Subcategory
Privilege Escalation
Accessibility scope
Remote
Impact
Privilege Escalation
Fixed by upgrading
Yes

Solution

Update python-keystoneclient to version 0.7.0 or higher.

Vulnerable code sample

import memcache

class AuthTokenMiddleware:
    def __init__(self, app, memcache_servers):
        self.app = app
        self.cache = memcache.Client(memcache_servers)

    def get_user_token(self, user_id):
        token = self.cache.get(f'user_token:{user_id}')
        return token

    def __call__(self, environ, start_response):
        user_id = environ.get('HTTP_X_USER_ID')
        if not user_id:
            start_response('401 Unauthorized', [])
            return [b'Unauthorized']

        token = self.get_user_token(user_id)
        if not token:
            start_response('404 Not Found', [])
            return [b'Token not found']

        environ['AUTH_TOKEN'] = token
        return self.app(environ, start_response)

Patched code sample

import memcache
import re

class AuthTokenMiddleware:
    def __init__(self, app, memcache_servers):
        self.app = app
        self.cache = memcache.Client(memcache_servers)

    def get_user_token(self, user_id):
        try:
            return self.cache.get(f'user_token:{user_id}')
        except Exception:
            return None

    def sanitize_user_id(self, user_id):
        if not re.match(r'^[a-zA-Z0-9_]+$', user_id):
            return None
        return user_id

    def __call__(self, environ, start_response):
        user_id = environ.get('HTTP_X_USER_ID')
        if not user_id:
            start_response('401 Unauthorized', [])
            return [b'Unauthorized: Missing user ID']

        user_id = self.sanitize_user_id(user_id)
        if not user_id:
            start_response('400 Bad Request', [])
            return [b'Bad Request: Invalid user ID']

        token = self.get_user_token(user_id)
        if not token:
            start_response('404 Not Found', [])
            return [b'Token not found']

        environ['AUTH_TOKEN'] = token
        return self.app(environ, start_response)

Cite this entry

@misc{vaitp:cve20140105,
  title        = {{Python-keystoneclient before 0.7.0 allows authenticated remote users to gain privileges via a memcache-related issue}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2014},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2014-0105},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2014-0105/}}
}
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 ::