CVE-2022-31583

9.3 CRITICAL

📋 TL;DR

This vulnerability allows attackers to read arbitrary files on the server through absolute path traversal in the AutomatedQuizEval repository. It affects any system running this Flask-based quiz evaluation application with the vulnerable code. Attackers can access sensitive files like configuration files, passwords, or source code.

💻 Affected Systems

Products:
  • sravaniboinepelli/AutomatedQuizEval
Versions: All versions through 2020-04-27
Operating Systems: Any OS running Python/Flask
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects systems where this specific GitHub repository is deployed and running.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

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

🟠

Likely Case

Exfiltration of sensitive application data, configuration files, or source code that could enable additional attacks.

🟢

If Mitigated

Limited impact with proper file permissions and network segmentation preventing access to critical system files.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

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

The vulnerability is in the Flask send_file function usage, making exploitation straightforward with simple HTTP requests.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

Vendor Advisory: N/A

Restart Required: No

Instructions:

1. Remove or replace the vulnerable repository code
2. Implement proper input validation for file paths
3. Use Flask's safe file serving methods with path sanitization

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Add validation to ensure file paths are within allowed directories and sanitize user input.

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

safe_path = safe_join(base_directory, user_input_path)
if safe_path is None:
    return 'Invalid path'

# Use safe_path with send_file

Web Application Firewall Rules

all

Block requests containing path traversal sequences like '../', '..\', or absolute paths.

# Example WAF rule to block path traversal
# Block requests with:
# ../ or ..\ in URL parameters
# Absolute paths starting with /etc/, /root/, etc.

🧯 If You Can't Patch

  • Isolate the application in a restricted network segment with minimal file system access
  • Implement strict file permissions and remove sensitive files from accessible directories

🔍 How to Verify

Check if Vulnerable:

Review the Flask application code for unsafe use of send_file() with user-controlled input without proper path validation.

Check Version:

# Check if using vulnerable repository
git log --oneline | grep -i "2020-04-27"
# Or check repository metadata

Verify Fix Applied:

Test that attempts to access files outside allowed directories (like /etc/passwd or ../../config.py) return errors instead of file contents.

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests with path traversal sequences (../, ..\)
  • Requests for sensitive file paths like /etc/passwd, /proc/self/environ
  • Unusual file access patterns from single IPs

Network Indicators:

  • HTTP requests with encoded path traversal sequences (%2e%2e%2f)
  • Rapid sequential requests for different file paths

SIEM Query:

source="web_logs" AND (url="*../*" OR url="*..\\*" OR url="/etc/*" OR url="/root/*")

🔗 References

📤 Share & Export