Skip to content

Commit 6916487

Browse files
committed
fix(security): fail fast on known default secrets outside development (issue #130)
1 parent 8368d61 commit 6916487

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ services:
146146
- "8080:8080"
147147
environment:
148148
- JWT_SECRET=${JWT_SECRET:-change-me-to-a-long-random-string}
149+
- NODE_ENV=${NODE_ENV:-development}
149150
- ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-http://localhost:3000}
150151
- AUTH_SERVICE_URL=http://auth-service:8010
151152
- EMPLOYEE_SERVICE_URL=http://employee-service:8001

services/api-gateway-node/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ if (!JWT_SECRET) {
126126
process.exit(1);
127127
}
128128

129+
if (NODE_ENV !== 'development' && (INTERNAL_JWT_SECRET === 'atlas-internal-jwt-secret-change-me' || JWT_SECRET === 'change-me-to-a-long-random-string')) {
130+
console.error('FATAL: refusing to start outside development with known default secrets (INTERNAL_JWT_SECRET / JWT_SECRET); set strong values via .env');
131+
process.exit(1);
132+
}
133+
129134
const jwtSecret = JWT_SECRET;
130135

131136
const allowedOrigins = (process.env.ALLOWED_ORIGINS || 'http://localhost:3000')

services/auth-service/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ if (!SCIM_API_KEY) {
119119
process.exit(1);
120120
}
121121

122+
if (NODE_ENV !== 'development' && (JWT_SECRET === 'change-me-to-a-long-random-string' || ADMIN_DEFAULT_PASSWORD === 'ChangeMe123!')) {
123+
console.error('FATAL: refusing to start outside development with known default secrets (JWT_SECRET / ADMIN_DEFAULT_PASSWORD); set strong values via .env');
124+
process.exit(1);
125+
}
126+
122127
const jwtSecret = JWT_SECRET;
123128

124129
if (!process.env.POSTGRES_URL) {

0 commit comments

Comments
 (0)