Flask

Security rules for Flask web framework

21
Security Rules

Run All Flask Rules

pathfinder scan --ruleset python/flask --project .

Rules

Flask Debug Mode Enabled

HIGH

Detects Flask applications started with debug=True, which enables the interactive Werkzeug debugger and must never run in production.

pythonflaskdebug-modeconfigurationinformation-disclosurewerkzeugproductionmisconfigurationremote-code-executionCWE-489OWASP-A05
CWE-489
Updated 2026-03-22

Flask Bound to All Interfaces

MEDIUM

Detects Flask applications binding the development server to 0.0.0.0, exposing it to every network interface instead of localhost only.

pythonflasknetworkbindinginterfaceconfigurationmisconfigurationdevelopment-serverCWE-668OWASP-A05
CWE-668
Updated 2026-03-22

Flask CORS Wildcard Origin

MEDIUM

Detects Flask-CORS configured with origins="*", allowing any domain to make cross-origin requests to the application.

pythonflaskcorswildcardcross-originconfigurationmisconfigurationflask-corsCWE-942OWASP-A05
CWE-942
Updated 2026-03-22

Flask url_for with _external=True

LOW

Detects url_for() called with _external=True, which generates absolute URLs using the Host header and can be abused for open redirect or host header injection attacks.

pythonflaskurl-forexternalopen-redirecthost-header-injectionauditCWE-601OWASP-A01
CWE-601
Updated 2026-03-22

Flask render_template_string Usage

MEDIUM

Detects any use of render_template_string(), which renders Jinja2 templates from Python strings and is inherently adjacent to Server-Side Template Injection (SSTI) vulnerabilities.

pythonflasktemplatesstiserver-side-template-injectionjinja2auditrender-template-stringCWE-1336OWASP-A03
CWE-1336
Updated 2026-03-22

Flask Cookie Without Secure Flags

MEDIUM

Detects set_cookie() calls with secure=False or httponly=False, which expose session and authentication cookies to theft via network eavesdropping or JavaScript access.

pythonflaskcookiesecurehttponlysamesitesession-managementconfigurationCWE-614OWASP-A05
CWE-614
Updated 2026-03-22

Flask Command Injection via subprocess

CRITICAL

User input from Flask request parameters flows to subprocess functions with shell=True or as a command string. Use list arguments without shell=True.

pythonflaskcommand-injectionsubprocessshell-injectioncross-fileinter-proceduraltaint-analysisCWE-78OWASP-A03
CWE-78
Updated 2026-03-22

Flask SQL Injection via Tainted String

CRITICAL

Finds user input reaching raw SQL queries in Flask apps where parameterized queries should be used instead.

pythonflasksql-injectiondatabaseparameterized-queriescursor-executesqlitemysqlpostgresqlpymysqlpsycopg2cross-fileinter-proceduraltaint-analysisCWE-89OWASP-A03
CWE-89
Updated 2026-03-22

Flask Code Injection via eval()

CRITICAL

User input from Flask request parameters flows to eval(). Replace with ast.literal_eval() for data parsing or json.loads() for structured input.

pythonflaskcode-injectionevaleval-injectionrcecross-fileinter-proceduraltaint-analysisCWE-95OWASP-A03
CWE-95
Updated 2026-03-22

Flask Code Injection via exec()

CRITICAL

User input from Flask request parameters flows to exec() or compile(). exec() cannot be safely sanitized -- redesign the feature to avoid dynamic code execution.

pythonflaskcode-injectionexeccompilercecross-fileinter-proceduraltaint-analysisCWE-95OWASP-A03
CWE-95
Updated 2026-03-22

Flask SSRF via requests Library

HIGH

User input from Flask request parameters flows to outbound HTTP request URLs via the requests library. Validate and allowlist target hosts before making server-side requests.

pythonflaskssrfrequestsurllibserver-side-request-forgerycloud-metadatacross-fileinter-proceduraltaint-analysisCWE-918OWASP-A10
CWE-918
Updated 2026-03-22

Flask Path Traversal via open()

HIGH

User input from Flask request parameters flows to open() or io.open() without path sanitization. Use werkzeug secure_filename() and verify the resolved path stays within the intended directory.

pythonflaskpath-traversaldirectory-traversalfile-readopenio-opencross-fileinter-proceduraltaint-analysisCWE-22OWASP-A01
CWE-22
Updated 2026-03-22

Flask CSV Injection

MEDIUM

User input from Flask request parameters flows to csv.writer.writerow() or writerows() without formula character sanitization. Strip or escape leading =, +, -, @ characters to prevent spreadsheet formula injection.

pythonflaskcsv-injectionformula-injectionspreadsheet-injectioncross-fileinter-proceduraltaint-analysisCWE-1236OWASP-A03
CWE-1236
Updated 2026-03-22

Flask NaN Injection via float()

LOW

User input from Flask request parameters flows to float() which can produce NaN or Inf values. Validate and reject non-finite float values with math.isnan() and math.isinf().

pythonflasknan-injectiontype-confusionfloat-conversionnumeric-validationcross-fileinter-proceduraltaint-analysisCWE-704OWASP-A03
CWE-704
Updated 2026-03-22

Flask SSRF via Tainted URL Host

HIGH

User input from Flask request parameters is used to construct the host component of an outbound HTTP request URL. Validate the host against an explicit allowlist before making server-side requests.

pythonflaskssrfurl-hosthost-injectionrequestsurllibcross-fileinter-proceduraltaint-analysisCWE-918OWASP-A10
CWE-918
Updated 2026-03-22

Flask Open Redirect

MEDIUM

User input from Flask request parameters flows to redirect() without URL validation. Validate redirect targets against an allowlist or use url_for() to generate trusted application-internal URLs.

pythonflaskopen-redirectunvalidated-redirectphishingcross-fileinter-proceduraltaint-analysisCWE-601OWASP-A01
CWE-601
Updated 2026-03-22

Flask Server-Side Template Injection (SSTI)

CRITICAL

User input from Flask request parameters flows to render_template_string() as part of the template source. Pass user data as template variables, never in the template string itself.

pythonflasksstitemplate-injectionjinja2render-template-stringrcecross-fileinter-proceduraltaint-analysisCWE-1336OWASP-A03
CWE-1336
Updated 2026-03-22

Flask Insecure Static File Serve

MEDIUM

Detects use of send_file() and send_from_directory() which serve files from the server's file system and are vulnerable to path traversal when the filename argument comes from user input.

pythonflaskpath-traversalstatic-filesfile-disclosuresend-filesend-from-directoryauditCWE-73OWASP-A01
CWE-73
Updated 2026-03-22

Flask Hashids with Secret Key as Salt

MEDIUM

Detects Hashids initialized with app.secret_key as the salt, which exposes Flask's secret key because the Hashids salt is recoverable through cryptanalysis.

pythonflaskhashidssecret-keycryptographysaltsession-forgeryCWE-327OWASP-A02
CWE-327
Updated 2026-03-22

Flask Direct Use of Jinja2

MEDIUM

Detects direct use of jinja2.Environment or jinja2.Template, which bypasses Flask's automatic HTML autoescaping and can lead to XSS vulnerabilities.

pythonflaskjinja2xsscross-site-scriptingautoescapingtemplateauditCWE-79OWASP-A03
CWE-79
Updated 2026-03-22

Flask Explicit Unescape with Markup

MEDIUM

Detects use of Markup() or markupsafe.Markup() which marks strings as safe HTML, bypassing Jinja2's autoescaping and introducing XSS risk if applied to user-controlled content.

pythonflaskmarkupmarkupsafexsscross-site-scriptingautoescapingauditCWE-79OWASP-A03
CWE-79
Updated 2026-03-22