Skip to content

Commit d12c7c7

Browse files
gabemonteroclaude
andcommitted
fix(boost): address round-3 security findings
- Guard isSensitiveField against unknown DB keys (nil-deref) - Wrap JSON.parse in try/catch in getOverride/getAllOverrides - Warn at startup when encrypted DB values exist without encryptionSecret Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9290d05 commit d12c7c7

2 files changed

Lines changed: 28 additions & 3 deletions

File tree

workspaces/boost/plugins/boost-backend/src/config/AdminConfigService.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,15 @@ export class AdminConfigService {
125125
return undefined;
126126
}
127127

128-
let rawValue: unknown = JSON.parse(row.value);
128+
let rawValue: unknown;
129+
try {
130+
rawValue = JSON.parse(row.value);
131+
} catch {
132+
this.logger.error(
133+
`Corrupt value for config key "${key}" — skipping (invalid JSON)`,
134+
);
135+
return undefined;
136+
}
129137

130138
// Decrypt sensitive fields
131139
if (isSensitiveField(key) && typeof rawValue === 'string') {
@@ -152,7 +160,15 @@ export class AdminConfigService {
152160
const result = new Map<string, unknown>();
153161

154162
for (const row of rows) {
155-
let rawValue: unknown = JSON.parse(row.value);
163+
let rawValue: unknown;
164+
try {
165+
rawValue = JSON.parse(row.value);
166+
} catch {
167+
this.logger.error(
168+
`Corrupt value for config key "${row.key}" — skipping (invalid JSON)`,
169+
);
170+
continue;
171+
}
156172

157173
// Decrypt sensitive fields
158174
const key = row.key as BoostConfigKey;
@@ -267,6 +283,14 @@ export class AdminConfigService {
267283
continue;
268284
}
269285

286+
// Warn at startup if sensitive fields exist but cannot be decrypted
287+
if (isSensitiveField(key) && !this.encryptionSecret) {
288+
this.logger.warn(
289+
`Sensitive config override "${key}" exists in DB but no encryption secret is configured — ` +
290+
`this field will be unreadable at runtime. Set boost.encryptionSecret to restore access.`,
291+
);
292+
}
293+
270294
// Re-validate the stored value
271295
try {
272296
let rawValue: unknown = JSON.parse(row.value);

workspaces/boost/plugins/boost-backend/src/config/schemas.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,6 @@ export function isDbWritable(key: BoostConfigKey): boolean {
200200
* @public
201201
*/
202202
export function isSensitiveField(key: BoostConfigKey): boolean {
203-
return (boostConfigFields[key] as ConfigFieldMeta).sensitive === true;
203+
const field = boostConfigFields[key] as ConfigFieldMeta | undefined;
204+
return field?.sensitive === true;
204205
}

0 commit comments

Comments
 (0)