fix(sandbox): harden enforcement validation and backup handling

This commit is contained in:
Chris Scott committed 2026-08-20 11:10:59 -04:00
1 parent f315dda3f3
commit 0481160f5e
13 files changed
+180 -101

No files matched your search

@@ -48,9 +48,16 @@ export function sanitizeConfigForEnforcementResult(
return { sanitized, removed }
}
export function isProvablyRemoteMcpEntry(entry: unknown): boolean {
return isRecord(entry)
&& entry.type === 'remote'
&& typeof entry.url === 'string'
&& entry.command === undefined
&& entry.environment === undefined
}
export function isLocalMcpServerEntry(entry: unknown): boolean {
if (!isRecord(entry)) return false
return entry.type === 'local' || Array.isArray(entry.command)
return !isProvablyRemoteMcpEntry(entry)
}
export function isCustomProviderEntry(entry: unknown): boolean {
@@ -1,4 +1,4 @@
import { isRecord, sanitizeConfigForEnforcement } from './enforcement-config'
import { isProvablyRemoteMcpEntry, isRecord, sanitizeConfigForEnforcement } from './enforcement-config'
export type SandboxProxyDecision = { blocked: true; reason: string } | { blocked: false }
@@ -158,14 +158,7 @@ export function decideSandboxMcpAddBody(
reason: `${SANDBOX_CONFIG_MUTATION_REASON_PREFIX}the MCP server body must be a JSON object`,
}
}
const config = parsed.config
if (
!isRecord(config) ||
config.type !== 'remote' ||
typeof config.url !== 'string' ||
config.command !== undefined ||
config.environment !== undefined
) {
if (!isProvablyRemoteMcpEntry(parsed.config)) {
return {
kind: 'reject',
reason: `${SANDBOX_CONFIG_MUTATION_REASON_PREFIX}only remote MCP servers can be added while enforcement is active`,