CVE-2022-31574

9.3 CRITICAL

📋 TL;DR

This vulnerability allows attackers to perform absolute path traversal attacks in the deepaliupadhyay/RealEstate repository due to unsafe use of Flask's send_file function. Attackers can read arbitrary files from the server filesystem. Anyone using this GitHub repository through 2018-11-30 is affected.

💻 Affected Systems

Products:
  • deepaliupadhyay/RealEstate repository
Versions: All versions through 2018-11-30
Operating Systems: Any OS running Python/Flask
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects deployments 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 files like /etc/passwd, SSH keys, or database credentials, potentially leading to full system takeover.

🟠

Likely Case

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

🟢

If Mitigated

Limited impact if proper file permissions and web server configurations restrict access to sensitive directories.

🌐 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 exploitable with basic HTTP requests.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: N/A

Vendor Advisory: N/A

Restart Required: No

Instructions:

1. Stop using the vulnerable repository. 2. Migrate to a maintained alternative. 3. Review and sanitize all file path inputs in your Flask application.

🔧 Temporary Workarounds

Input Validation and Sanitization

all

Implement strict validation and sanitization of all user-supplied file paths before passing to send_file.

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

safe_path = secure_filename(user_input)
# Additional validation to ensure path is within allowed directory

Web Server Configuration

linux

Configure web server to restrict file access to specific directories only.

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

🧯 If You Can't Patch

  • Implement strict network segmentation to isolate vulnerable systems
  • Deploy WAF rules to block path traversal patterns in HTTP requests

🔍 How to Verify

Check if Vulnerable:

Review Flask code for unsanitized user input passed to send_file() function. Test with path traversal payloads like '../../etc/passwd'.

Check Version:

Check repository commit history and date - vulnerable if using code from 2018-11-30 or earlier.

Verify Fix Applied:

Test that path traversal attempts return proper error responses instead of file contents. Verify input validation is implemented.

📡 Detection & Monitoring

Log Indicators:

  • HTTP requests containing '../' patterns
  • Unusual file access patterns from web application logs
  • Failed file access attempts to sensitive system paths

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="*../*" OR uri="*..%2f*" OR uri="*%2e%2e%2f*")

🔗 References

📤 Share & Export