A database connection string in the code has an empty password

tx0/csharp:empty-database-passwordstrictwarningsecurity/authn-authzdepth fastsecurity, cwe-521

What it finds

A connection string with an empty password logs in to a database account that has no password, which anyone who can reach the server can use as well. Such accounts belong to development setups; in shared code the password comes from configuration or a secret store, or the connection uses integrated authentication.

Reported are string literals that read as a connection string, with a server, host or data source key, whose Password or Pwd key is empty. Strings that switch on integrated security or trusted connections, which ignore the password, are left alone, and so are files of tests.

From the rule's source, empty_database_password.rs.

Example from the rule's tests
class Settings{    string Main = "Server=db.local;Database=shop;User Id=sa;Password=;";tx0 reports: this connection string logs in with an empty password    string Other = "Host=pg;Username=app;Pwd=";tx0 reports: this connection string logs in with an empty password    string Windows = "Server=db.local;Database=shop;Integrated Security=true;Password=;";    string Full = "Server=db.local;Database=shop;User Id=app;Password=secret;";    string Text = "Password=;";}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/csharp: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/csharp:empty-database-password] reason="..."

tx0 explain tx0/csharp:empty-database-password shows the same in the terminal. Found a false positive? Report it.