T09 · Insecure Skill Coding Practices
- Location
SKILL.md:119- Finding
Predictable Default Database Password in Generated Configuration
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 113–121 and 162–168
Vulnerability Type: Hardcoded and predictable default credential
Risk Level: MediumThe skill recommends a TypeORM configuration that silently uses the well-known password
postgreswhenDB_PASSWORDis missing. Its environment-file example also assigns that same predictable password.Vulnerable Code
ts export default registerAs("database", () => ({ type: "postgres", host: process.env.DB_HOST ?? "localhost", port: parseInt(process.env.DB_PORT ?? "5432", 10), username: process.env.DB_USERNAME ?? "postgres", password: process.env.DB_PASSWORD ?? "postgres", database: process.env.DB_NAME ?? "app_db", }));env DB_HOST=localhost DB_PORT=5432 DB_USERNAME=postgres DB_PASSWORD=postgres DB_NAME=app_dbTechnical Analysis
The password fallback at line 119 causes the application to continue operating with a predictable credential rather than failing securely when
DB_PASSWORDis absent. The environment example at line 167 reinforces this unsafe value and increases the likelihood that users will copy it into a deployed configuration without replacing it.Because this file defines instructions and templates for generated NestJS applications, the vulnerability becomes exploitable when an agent applies the example to a real project and the resulting database account retains the documented password. Exploitation additionally requires network or local access to the PostgreSQL service.
Attack Path
- A developer or agent applies the database configuration from
SKILL.md. - The deployment omits
DB_PASSWORD, or the provided environment example is copied without changingDB_PASSWORD=postgres. - The application and database are configured to accept the predictable
postgrescredential. - An attacker identifies an exposed or otherwise reachable PostgreSQL service.
- The attacker ...[truncated 778 chars]
- A developer or agent applies the database configuration from
- Remediation
View remediation
Remediation Suggestions
-
Remove the password fallback and require an explicit secret:
ts const password = process.env.DB_PASSWORD; if (!password) { throw new Error("DB_PASSWORD must be configured"); } -
Add startup configuration validation, such as a Joi or Zod schema, that rejects missing, empty, or known default database credentials.
-
Replace the value in
.env.examplewith a clearly nonfunctional placeholder:env DB_PASSWORD=replace-with-a-strong-secret -
Provision a unique, randomly generated password through a secret manager or protected deployment environment variable.
-
Use a dedicated application database role instead of the PostgreSQL superuser.
-
Grant that role only the permissions required by the application.
-
Prevent public database exposure through firewall rules, private networking, and PostgreSQL access controls.
-
Rotate the credential immediately if the documented default has already been used in any environment.
-
