CVE-2022-31511

9.3 CRITICAL

📋 TL;DR

This vulnerability allows attackers to read arbitrary files on the server by exploiting an unsafe implementation of Flask's send_file function. It affects any system running the AFDudley/equanimity repository from GitHub with versions through April 23, 2014. Attackers can access sensitive files outside the intended directory structure.

💻 Affected Systems

Products:
  • AFDudley/equanimity repository
Versions: All versions through 2014-04-23
Operating Systems: Any OS running Python/Flask
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems using the vulnerable Flask send_file implementation from this specific repository.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete server compromise through reading sensitive configuration files, credentials, or private keys leading to further attacks.

🟠

Likely Case

Exfiltration of sensitive data including configuration files, source code, or user data stored on the server.

🟢

If Mitigated

Limited impact with proper file permissions and web server configurations restricting access to sensitive directories.

🌐 Internet-Facing: HIGH - Web applications are directly accessible and vulnerable to unauthenticated attacks.
🏢 Internal Only: MEDIUM - Internal attackers could still exploit this to access sensitive files on affected systems.

🎯 Exploit Status

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

Path traversal attacks are well-understood and easy to automate. The vulnerability is in a public GitHub repository with known exploitation patterns.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

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

Restart Required: No

Instructions:

1. Remove or replace the vulnerable equanimity repository code. 2. Implement proper input validation and path sanitization. 3. Use Flask's send_file with safe path handling or implement custom secure file serving.

🔧 Temporary Workarounds

Implement Input Validation

all

Add validation to ensure file paths are within allowed directories before passing to send_file.

# Python code to validate paths
import os
from flask import abort

def safe_path(user_input):
    base_dir = '/allowed/path'
    requested_path = os.path.join(base_dir, user_input)
    if not requested_path.startswith(base_dir):
        abort(403)
    return requested_path

Web Server Restrictions

all

Configure web server to restrict access to sensitive directories.

# Nginx configuration
location ~ /\. {
    deny all;
}

# Apache configuration
<Directory "/var/www/sensitive">
    Require all denied
</Directory>

🧯 If You Can't Patch

  • Isolate the vulnerable application in a container or VM with minimal file access permissions.
  • Implement network segmentation and WAF rules to block path traversal patterns in requests.

🔍 How to Verify

Check if Vulnerable:

Review Flask application code for unsanitized user input passed to send_file() function. Check if the application uses the AFDudley/equanimity repository code.

Check Version:

# Check if equanimity repository is present
grep -r "equanimity" /path/to/application/ || find /path/to/application -name "*.py" -exec grep -l "AFDudley" {} \;

Verify Fix Applied:

Test with path traversal payloads (e.g., '../../etc/passwd') and verify the application rejects them or returns appropriate error messages.

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests containing '../' patterns
  • 403/404 errors for sensitive file paths
  • Unusual file access patterns in application logs

Network Indicators:

  • HTTP requests with encoded path traversal sequences (%2e%2e%2f)
  • Multiple failed attempts to access sensitive file paths

SIEM Query:

source="web_logs" AND (uri="*..%2f*" OR uri="*../*") AND response="200"

🔗 References

📤 Share & Export