Why it matters
Anyone who reads it can forge session cookies and signed tokens.
How to fix it
Read the key from the environment or a secret store and rotate the committed value.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
from flask import Flask
app = Flask(__name__)
app.secret_key = "dev-secret-that-shipped-to-production"import os
from flask import Flask
app = Flask(__name__)
app.secret_key = os.environ["FLASK_SECRET_KEY"]What TrustIvan reads
Runs on repository scans of Python source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Django mark safe non literal (Python)
PythonSeverity: Medium
trustivan-python-django-mark-safe-non-literal - JWT hardcoded secret (Python)
PythonSeverity: High
trustivan-python-jwt-hardcoded-secret - Mass assignment from request input (Python)
PythonSeverity: Medium
trustivan-python-taint-mass-assignment - Weak RSA key (Python)
PythonSeverity: Medium
trustivan-python-weak-rsa-key - NoSQL injection from request input (Python)
PythonSeverity: High
trustivan-python-taint-nosql-injection - CORS wildcard credentials (Python)
PythonSeverity: High
trustivan-python-cors-wildcard-credentials
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation