CVE-2022-31572

9.3 CRITICAL

📋 TL;DR

This vulnerability allows attackers to perform absolute path traversal attacks in the ceee-vip/cockybook repository, enabling unauthorized file access. It affects any system running this Flask-based application with the vulnerable code. The exploit leverages unsafe use of Flask's send_file function to read arbitrary files on the server.

💻 Affected Systems

Products:
  • ceee-vip/cockybook
Versions: All versions through 2015-04-16
Operating Systems: Any OS running Python/Flask
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects deployments using the vulnerable Flask send_file implementation in this specific repository.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete server compromise through reading sensitive files like /etc/passwd, SSH keys, or database credentials, potentially leading to remote code execution.

🟠

Likely Case

Unauthorized access to sensitive configuration files, source code, or user data stored on the server filesystem.

🟢

If Mitigated

Limited impact with proper file permissions and web server sandboxing, though some information disclosure may still occur.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Path traversal vulnerabilities are well-understood and easily weaponized with simple HTTP requests.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

Vendor Advisory: https://github.com/github/securitylab/issues/669

Restart Required: Yes

Instructions:

1. Remove or replace the vulnerable repository with a secure alternative. 2. No official patch exists as this is an abandoned project. 3. Consider implementing proper input validation and path sanitization if maintaining the codebase.

🔧 Temporary Workarounds

Implement Path Sanitization

all

Add input validation to sanitize file paths before passing to send_file

# Python code to sanitize paths
import os
from werkzeug.utils import secure_filename

safe_path = os.path.join(base_directory, secure_filename(user_input))

Restrict File Access with Web Server

linux

Configure web server to restrict file access to specific directories

# Nginx example
location /files/ {
    internal;
    alias /var/www/files/;
}

🧯 If You Can't Patch

  • Remove the application from internet-facing networks
  • Implement strict network segmentation and firewall rules to limit access

🔍 How to Verify

Check if Vulnerable:

Review Flask code for unsafe send_file usage with user-controlled paths, or test with path traversal payloads like '../../etc/passwd'

Check Version:

Check repository commit history or deployment date against 2015-04-16

Verify Fix Applied:

Test that path traversal attempts return proper error responses instead of file contents

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests containing '../' sequences
  • Access to unexpected file paths in web logs
  • 404 errors for legitimate files that should exist

Network Indicators:

  • Unusual file download patterns
  • Requests for known sensitive file paths

SIEM Query:

web_access_logs WHERE url CONTAINS '../' OR url CONTAINS '..%2F'

🔗 References

📤 Share & Export