Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(config): name the canonical S3 keys when refusing a weak secret

Yudhi Armyndharis07ea7e007ca8
diff --git a/src/config/bootstrap-security.spec.ts b/src/config/bootstrap-security.spec.ts
index e5b9681eb..3bdb67332 100644
--- a/src/config/bootstrap-security.spec.ts
+++ b/src/config/bootstrap-security.spec.ts
@@ -219,7 +219,7 @@ describe('assertNoDefaultSecretsInProduction', () => {
s3SecretKey: 'minioadmin',
minioBuiltIn: 'true',
}),
- ).toThrow(/S3_ACCESS_KEY, S3_SECRET_KEY/);
+ ).toThrow(/S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY/);
});
it('still refuses an EXTERNAL Postgres with a default password even when MinIO is built-in', () => {
@@ -254,7 +254,7 @@ describe('assertNoDefaultSecretsInProduction', () => {
minioBuiltIn: 'true',
s3Endpoint: 'https://s3.amazonaws.com',
}),
- ).toThrow(/S3_ACCESS_KEY/);
+ ).toThrow(/S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY/);
});
it('exempts the built-in defaults when the host is the internal bundled service', () => {
@@ -282,7 +282,7 @@ describe('assertNoDefaultSecretsInProduction', () => {
s3AccessKey: 'minioadmin',
s3SecretKey: 'minioadmin',
}),
- ).toThrow(/S3_ACCESS_KEY, S3_SECRET_KEY/);
+ ).toThrow(/S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY/);
});
it('refuses prod with a placeholder API_MASTER_KEY', () => {
diff --git a/src/config/bootstrap-security.ts b/src/config/bootstrap-security.ts
index 23b735e0c..45b100084 100644
--- a/src/config/bootstrap-security.ts
+++ b/src/config/bootstrap-security.ts
@@ -220,8 +220,10 @@ export function assertNoDefaultSecretsInProduction(env: SecretCheckEnv): void {
}
const s3Exempt = env.minioBuiltIn === 'true' && isInternalS3Endpoint(env.s3Endpoint);
if (env.storageType === 's3' && !s3Exempt) {
- if (isWeak(env.s3AccessKey)) problems.push('S3_ACCESS_KEY');
- if (isWeak(env.s3SecretKey)) problems.push('S3_SECRET_KEY');
+ // Name the canonical variables even when the value came from the legacy S3_ACCESS_KEY /
+ // S3_SECRET_KEY fallback: they are what the docs and .env.example tell an operator to set.
+ if (isWeak(env.s3AccessKey)) problems.push('S3_ACCESS_KEY_ID');
+ if (isWeak(env.s3SecretKey)) problems.push('S3_SECRET_ACCESS_KEY');
}
// API_MASTER_KEY is optional, but if provided it must neither be a known default nor fall below
// the length floor — both are refused the same way, like the other weak secrets above. Unset stays
diff --git a/src/modules/infra/infra-config.controller.spec.ts b/src/modules/infra/infra-config.controller.spec.ts
index 7101dcf1c..22b78bfd0 100644
--- a/src/modules/infra/infra-config.controller.spec.ts
+++ b/src/modules/infra/infra-config.controller.spec.ts
@@ -823,7 +823,7 @@ describe('InfraConfigController.saveConfig built-in/external mode flips and the
},
},
BUILTIN_MINIO_ENV,
- /S3_ACCESS_KEY, S3_SECRET_KEY/,
+ /S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY/,
);
});
@@ -840,7 +840,7 @@ describe('InfraConfigController.saveConfig built-in/external mode flips and the
},
},
undefined,
- /S3_ACCESS_KEY, S3_SECRET_KEY/,
+ /S3_ACCESS_KEY_ID, S3_SECRET_ACCESS_KEY/,
);
});