CVE-2022-31578
📋 TL;DR
This vulnerability allows attackers to read arbitrary files on the server through absolute path traversal in the piaoyunsoft/bt_lnmp repository. It affects systems running this software due to unsafe use of Flask's send_file function. Anyone using this repository through 2019-10-10 is vulnerable.
💻 Affected Systems
- piaoyunsoft/bt_lnmp
📦 What is this software?
Bt Lnmp by Bt Lnmp Project
⚠️ 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
Information disclosure of sensitive configuration files, source code, or user data stored on the server.
If Mitigated
Limited impact with proper file permissions and web server restrictions in place.
🎯 Exploit Status
Path traversal vulnerabilities are commonly exploited and require minimal technical skill.
🛠️ Fix & Mitigation
✅ Official Fix
Patch Version: N/A
Vendor Advisory: N/A
Restart Required: No
Instructions:
1. Remove or replace the vulnerable repository with a secure alternative. 2. If continuing to use, manually fix the Flask send_file implementation to validate file paths.
🔧 Temporary Workarounds
Implement Path Validation
linuxAdd server-side validation to restrict file access to intended directories only.
# Modify Flask app to validate file paths before send_file()
# Example: ensure requested path is within allowed directory
Web Server Restrictions
linuxConfigure web server (nginx/apache) to block requests with directory traversal patterns.
# nginx example:
location ~ \.\./ {
deny all;
}
# Apache example:
RewriteCond %{REQUEST_URI} \.\./ [NC]
RewriteRule .* - [F]
🧯 If You Can't Patch
- Implement strict file permissions (chmod 600 for sensitive files, chmod 755 for web directories)
- Deploy WAF rules to block path traversal patterns in HTTP requests
🔍 How to Verify
Check if Vulnerable:
Check if using piaoyunsoft/bt_lnmp repository dated through 2019-10-10 and if Flask send_file is used without proper path validation.
Check Version:
Check repository commit history or deployment date against 2019-10-10
Verify Fix Applied:
Test with path traversal attempts (e.g., /../../etc/passwd) and verify they are blocked or return appropriate errors.
📡 Detection & Monitoring
Log Indicators:
- HTTP requests containing '..' or absolute paths in URL parameters
- Failed file access attempts to sensitive system paths
Network Indicators:
- Unusual file requests patterns from single IPs
- Requests for known sensitive files like /etc/passwd
SIEM Query:
source="web_logs" AND (url="*../*" OR url="*/etc/*" OR url="*/root/*")