Infraloka Logo
Professional Blacklist: personal dispute documentation
Professional BlacklistAbhi FabhianA W SSecrets Manager

Abhi Fabhian, AWS: The Fix for Hard-Coded Database Credentials in Node.js, mssql and Amazon RDS

Header illustration: a code file reading its secret from a vault instead of the source

Part of my series on hard-coded secrets in a public repository. The main record names the problem. This post is the answer: how a Solutions Architect would fix it in about twenty lines, using AWS's own services. All values below are invented.

RAHMAT WIBOWO | 28 NOVEMBER 2026


The pattern

The record describes a Node.js file that connects to Microsoft SQL Server on Amazon RDS with the login written in the source, and with driver encryption switched off. In outline:

// the pattern in the record, with invented values
const config = {
  user: 'app_user',
  password: 'example-only',      // written in the file
  server: 'db.example.internal',
  options: { encrypt: false },   // no transport encryption
};

Anyone who can read the file can use the login. That includes everyone, if the repository is public.

Step 1: rotate first

Before changing any code, change the database password. A secret that was ever committed must be treated as known, because history, forks and clones keep it. Rewriting history is optional. Rotation is not.

Step 2: put the secret in AWS Secrets Manager

Store a JSON secret with username, password, host, dbname and port. For Amazon RDS, Secrets Manager can also rotate the password automatically on a schedule, so no person ever needs to know it.

Step 3: read it at runtime

# the code needs only the secret's name, which is not secret
export DB_SECRET_ID=prod/app/db
export AWS_REGION=ap-southeast-1
import { SecretsManagerClient, GetSecretValueCommand } from '@aws-sdk/client-secrets-manager';
import sql from 'mssql';

const client = new SecretsManagerClient({ region: process.env.AWS_REGION });

async function getConfig() {
  const out = await client.send(new GetSecretValueCommand({ SecretId: process.env.DB_SECRET_ID }));
  const s = JSON.parse(out.SecretString);      // { username, password, host, dbname, port }
  return {
    user: s.username,
    password: s.password,
    server: s.host,
    database: s.dbname,
    port: Number(s.port),
    options: { encrypt: true, trustServerCertificate: false },
  };
}

const pool = await sql.connect(await getConfig());

The code now holds a name, not a password. Access is granted by an IAM role on the machine or the function, so there is no access key in the file either.

Step 4: fix the network and the transport

  • Turn encrypt on, and leave certificate checking on.
  • Make the RDS instance not publicly accessible unless there is a stated reason, and limit the security group to the application's own address range.
  • Use a database user with only the rights the application needs, not admin.

Step 5: stop it coming back

  1. Add .env to .gitignore before the first commit.
  2. Enable GitHub push protection and secret scanning.
  3. Add a pre-commit scan, for example with gitleaks, so the mistake stops on the developer's machine.
  4. If the budget is small, AWS Systems Manager Parameter Store with a SecureString also works.

Why this belongs in the series

The point is not that the fix is clever. The point is that it is small and standard, and that a person whose job is to advise on it is expected to use it, in public and in private. That is a view about professional practice. It is not a claim about anyone's intent or about any employer.

Right of reply and correction policy

Abhi Fabhian is invited to send a response, correction or added context. A substantive response may be published alongside this article, subject to reasonable editing for privacy, safety and relevance. If reliable evidence shows that any factual statement here is wrong, or that the identification is mistaken, I will correct it promptly and note the change. Requests to remove personal data will be considered in good faith.

This post is my account and my opinion. It is not a finding by any court, regulator or employer.

Published by Rahmat Wibowo, InfraLoka: infraloka.co.id

#ProfessionalBlacklist #AbhiFabhian #AWS #SecretsManager #AmazonRDS #NodeJS