Skip to content

Commit 912a450

Browse files
committed
fix: strip apiKey from models.json to prevent secret leakage
1 parent b2c5ba6 commit 912a450

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎src/agents/models-config.plan.ts‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,14 @@ export async function planOpenClawModelsJsonWithDeps(
178178
secretRefManagedProviders,
179179
}) ?? normalizedMergedProviders;
180180
const finalProviders = applyNativeStreamingUsageCompat(secretEnforcedProviders);
181-
const nextContents = `${JSON.stringify({ providers: finalProviders }, null, 2)}\n`;
181+
// Strip apiKey from each provider before writing to models.json
182+
// to prevent secret leakage into prompt context (CVE-2026-XXXX).
183+
const sanitizedProviders: Record<string, unknown> = {};
184+
for (const [id, provider] of Object.entries(finalProviders)) {
185+
const { apiKey: _, ...rest } = provider as Record<string, unknown>;
186+
sanitizedProviders[id] = rest;
187+
}
188+
const nextContents = `${JSON.stringify({ providers: sanitizedProviders }, null, 2)}\n`;
182189

183190
if (params.existingRaw === nextContents) {
184191
return { action: "noop" };

0 commit comments

Comments
 (0)