A database connection is opened with an empty password
What it finds
An empty password means the database accepts connections without one for that user, so anyone who can reach it can log in. Checked are password="" and passwd="" given to the common drivers, and connection URLs of SQLAlchemy with a user and an empty password.
From the rule's source, empty_database_password.rs.
import psycopg2from sqlalchemy import create_engine a = psycopg2.connect(host="db", user="app", password="")tx0 reports: the database password is emptyb = psycopg2.connect(host="db", user="app", password=secret)engine = create_engine("postgresql://app:@db/orders")tx0 reports: the connection URL gives a user with an empty passwordother = create_engine("postgresql://app:pw@db/orders") Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:empty-database-password" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:empty-database-password] reason="..."tx0 explain tx0/python:empty-database-password shows the same in the terminal. Found a false positive? Report it.