Python Log Injection Unescaped Input
Description
Detects log injection vulnerabilities where unsanitized user input is passed directly to Python logging functions (info, debug, warning, error, critical). This could allow attackers to inject malicious payloads into log files, potentially leading to log forging or log file manipulation.
Detection Strategy
• Check if the Python 'logging' library is imported in the code
• Look for calls to logging functions: info(), debug(), warning(), error(), critical()
• Verify if any arguments passed to these logging functions contain unsanitized user input
• Report a vulnerability if user-controlled data flows into logging function calls without proper sanitization
Vulnerable code example
from flask import Flask, request
import logging
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
@app.route("/redirect")
def redirect_page():...✅ Secure code example
from flask import Flask, request, redirect, escape
import logging
from urllib.parse import urlparse, urljoin
app = Flask(__name__)
logging.basicConfig(level=logging.INFO)
# Whitelist of allowed redirect paths...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.