mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
fix(cloud): every agent credential a sandbox gets in full is marked 'Real value in sandbox', not only AWS keys
A shared list of agent and model-provider credential names (AWS, Bedrock, OpenRouter, Groq, xAI,
Mistral, DeepSeek, Together, Fireworks, Perplexity, Cerebras, Moonshot/Kimi, DashScope, Z.ai,
MiniMax, NVIDIA, Cohere, Azure OpenAI, Hugging Face, Amp, Factory, ...) marks every one that has no
egress swap. AWS keeps its own sentence; others read 'Orca can't swap {{name}} at the network edge,
...'. The control-plane test now walks the server's agent keys, this list and the desktop's Agent
API key presets: each is swapped, or flagged.
This commit is contained in:
@@ -6,7 +6,14 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import { compileNetworkPolicy } from '../src/network-policy'
|
||||
import { SWAPPED_CREDENTIALS, credentialTargets } from '../src/provider-env'
|
||||
import { AGENT_KEY_NAMES } from '../src/secrets'
|
||||
import { CLOUD_SWAPPED_CREDENTIALS, cloudSecretStoredOnVm } from '../../../../src/shared/cloud-secrets/cloud-secret-rules'
|
||||
import {
|
||||
AGENT_CREDENTIAL_NAMES,
|
||||
CLOUD_SWAPPED_CREDENTIALS,
|
||||
cloudSecretStoredOnVm
|
||||
} from '../../../../src/shared/cloud-secrets/cloud-secret-rules'
|
||||
import { AGENT_API_KEY_PRESETS } from '../../../../src/shared/agent-api-keys/agent-api-key-catalog'
|
||||
|
||||
const AGENT_API_KEY_PRESET_NAMES = Object.values(AGENT_API_KEY_PRESETS).flatMap((presets) => (presets ?? []).map((preset) => preset.envName))
|
||||
import { egressSecretHosts, encodeEgressSecretHosts } from '../src/secret-egress'
|
||||
import { ENV_COMMAND } from '../src/sandbox-vm-commands'
|
||||
import { createHarness } from './harness'
|
||||
@@ -282,7 +289,10 @@ describe('egress swap on a sandbox with the new keys', () => {
|
||||
describe('every agent credential is either swapped or marked "stored on workspace"', () => {
|
||||
it('leaves no agent key reaching the VM raw without the warning', () => {
|
||||
const settings = /(_MODEL|_BASE_URL|_REGION|_PROJECT|_PROJECT_ID)$|^CLAUDE_CODE_USE_/
|
||||
for (const name of AGENT_KEY_NAMES) {
|
||||
// Every credential the server treats as an agent key, the desktop's agent key presets and the
|
||||
// known model-provider key names: each is swapped, or the UI says the sandbox gets it in full.
|
||||
const names = new Set([...AGENT_KEY_NAMES, ...AGENT_CREDENTIAL_NAMES, ...AGENT_API_KEY_PRESET_NAMES])
|
||||
for (const name of names) {
|
||||
if (settings.test(name)) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -169,7 +169,7 @@ export function CloudSecretEditor({
|
||||
{cloudSecretStoredOnVm(name.trim()) ? (
|
||||
<>
|
||||
{' '}
|
||||
<span className="text-foreground">{cloudSecretVmWarning(t)}</span>
|
||||
<span className="text-foreground">{cloudSecretVmWarning(t, name.trim())}</span>
|
||||
</>
|
||||
) : null}
|
||||
</p>
|
||||
|
||||
@@ -13,7 +13,7 @@ export function CloudSecretVmBadge({ name }: { name: string }): React.JSX.Elemen
|
||||
if (!cloudSecretStoredOnVm(name)) {
|
||||
return null
|
||||
}
|
||||
const why = cloudSecretVmWarning(t)
|
||||
const why = cloudSecretVmWarning(t, name)
|
||||
return (
|
||||
<Tooltip>
|
||||
<TooltipTrigger asChild>
|
||||
@@ -36,9 +36,15 @@ export function CloudSecretVmBadge({ name }: { name: string }): React.JSX.Elemen
|
||||
)
|
||||
}
|
||||
|
||||
export function cloudSecretVmWarning(t: ReturnType<typeof useTranslate>): string {
|
||||
return t(
|
||||
'cloudSecrets.vm.warning',
|
||||
'Orca can’t swap AWS keys at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it.'
|
||||
)
|
||||
export function cloudSecretVmWarning(t: ReturnType<typeof useTranslate>, name: string): string {
|
||||
return name.startsWith('AWS_')
|
||||
? t(
|
||||
'cloudSecrets.vm.warning',
|
||||
'Orca can’t swap AWS keys at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it.'
|
||||
)
|
||||
: t(
|
||||
'cloudSecrets.vm.warningKey',
|
||||
'Orca can’t swap {{name}} at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it.',
|
||||
{ name }
|
||||
)
|
||||
}
|
||||
|
||||
@@ -192,7 +192,7 @@ export function PasteRowEditor({
|
||||
{note ? `${status} · ${note}` : status}
|
||||
</p>
|
||||
{row.name && cloudSecretStoredOnVm(row.name) ? (
|
||||
<p className="pl-5.5 text-2xs text-muted-foreground">{cloudSecretVmWarning(t)}</p>
|
||||
<p className="pl-5.5 text-2xs text-muted-foreground">{cloudSecretVmWarning(t, row.name)}</p>
|
||||
) : null}
|
||||
</li>
|
||||
)
|
||||
|
||||
@@ -47,7 +47,8 @@ export const FIXTURE_SECRETS: Record<CloudSecretScope, CloudSecretView[]> = {
|
||||
view('personal', 'SENTRY_ENV', 'env', null, 400),
|
||||
// Not swappable at egress: shows "Real value in sandbox".
|
||||
view('personal', 'AWS_ACCESS_KEY_ID', 'agent_key', 'Q7MP', 6),
|
||||
view('personal', 'AWS_SECRET_ACCESS_KEY', 'agent_key', 'k2Vd', 6)
|
||||
view('personal', 'AWS_SECRET_ACCESS_KEY', 'agent_key', 'k2Vd', 6),
|
||||
view('personal', 'OPENROUTER_API_KEY', 'env', 'r9Tw', 8)
|
||||
],
|
||||
org: [
|
||||
view('org', 'AI_GATEWAY_API_KEY', 'agent_key', 'M3kz', 30, 'u_dana'),
|
||||
|
||||
@@ -26936,7 +26936,8 @@
|
||||
},
|
||||
"vm": {
|
||||
"badge": "Real value in sandbox",
|
||||
"warning": "Orca can’t swap AWS keys at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it."
|
||||
"warning": "Orca can’t swap AWS keys at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it.",
|
||||
"warningKey": "Orca can’t swap {{name}} at the network edge, so cloud workspaces get the real value. Anything running in the sandbox can read it."
|
||||
}
|
||||
},
|
||||
"cloudMcpSync": {
|
||||
|
||||
@@ -38,19 +38,80 @@ const AGENT_KEY_NAMES: ReadonlySet<string> = new Set([
|
||||
])
|
||||
|
||||
/**
|
||||
* Agent keys the egress proxy cannot swap, so the workspace VM holds the real value: AWS requests
|
||||
* are signed in the VM (SigV4) with the secret key, and Bedrock API keys are not routed yet. Every
|
||||
* other agent key reaches the VM only as a placeholder. Mirrors the control plane's swap list.
|
||||
* Credentials agents and their model providers read. Any of these the egress proxy cannot swap
|
||||
* reaches a cloud sandbox as its real value, so the UI marks it "Real value in sandbox": AWS keys
|
||||
* (requests are signed in the VM with SigV4), Bedrock API keys (not routed yet) and every provider
|
||||
* key below that has no swap route. A control-plane test keeps this in step with the proxy.
|
||||
*/
|
||||
const STORED_ON_VM_NAMES: ReadonlySet<string> = new Set([
|
||||
export const AGENT_CREDENTIAL_NAMES: readonly string[] = [
|
||||
'AWS_ACCESS_KEY_ID',
|
||||
'AWS_SECRET_ACCESS_KEY',
|
||||
'AWS_SESSION_TOKEN',
|
||||
'AWS_BEARER_TOKEN_BEDROCK'
|
||||
])
|
||||
'AWS_BEARER_TOKEN_BEDROCK',
|
||||
'OPENROUTER_API_KEY',
|
||||
'GROQ_API_KEY',
|
||||
'XAI_API_KEY',
|
||||
'MISTRAL_API_KEY',
|
||||
'DEEPSEEK_API_KEY',
|
||||
'TOGETHER_API_KEY',
|
||||
'TOGETHER_AI_API_KEY',
|
||||
'FIREWORKS_API_KEY',
|
||||
'PERPLEXITY_API_KEY',
|
||||
'CEREBRAS_API_KEY',
|
||||
'MOONSHOT_API_KEY',
|
||||
'KIMI_API_KEY',
|
||||
'DASHSCOPE_API_KEY',
|
||||
'ZAI_API_KEY',
|
||||
'ZHIPU_API_KEY',
|
||||
'MINIMAX_API_KEY',
|
||||
'NVIDIA_API_KEY',
|
||||
'COHERE_API_KEY',
|
||||
'AZURE_OPENAI_API_KEY',
|
||||
'AZURE_API_KEY',
|
||||
'HUGGINGFACE_API_KEY',
|
||||
'HF_TOKEN',
|
||||
'AMP_API_KEY',
|
||||
'FACTORY_API_KEY',
|
||||
'AUGMENT_API_KEY',
|
||||
'CODEBUFF_API_KEY',
|
||||
'CLINE_API_KEY',
|
||||
'QWEN_API_KEY',
|
||||
// Swapped (no badge): listed so the test sees every agent credential in one place.
|
||||
'ANTHROPIC_API_KEY',
|
||||
'ANTHROPIC_AUTH_TOKEN',
|
||||
'AI_GATEWAY_API_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'GEMINI_API_KEY',
|
||||
'GOOGLE_API_KEY',
|
||||
'GOOGLE_GENERATIVE_AI_API_KEY',
|
||||
'CURSOR_API_KEY',
|
||||
'COPILOT_GITHUB_TOKEN',
|
||||
'COPILOT_PROVIDER_API_KEY',
|
||||
'COPILOT_PROVIDER_BEARER_TOKEN'
|
||||
]
|
||||
|
||||
/** Agent credentials the egress proxy swaps: a sandbox only ever holds a stand-in for these. */
|
||||
export const CLOUD_SWAPPED_CREDENTIALS: readonly string[] = [
|
||||
'ANTHROPIC_API_KEY',
|
||||
'ANTHROPIC_AUTH_TOKEN',
|
||||
'AI_GATEWAY_API_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'GEMINI_API_KEY',
|
||||
'GOOGLE_GENERATIVE_AI_API_KEY',
|
||||
'CURSOR_API_KEY',
|
||||
'GOOGLE_API_KEY',
|
||||
'COPILOT_GITHUB_TOKEN',
|
||||
'COPILOT_PROVIDER_API_KEY',
|
||||
'COPILOT_PROVIDER_BEARER_TOKEN'
|
||||
]
|
||||
|
||||
export function cloudSecretSwapped(name: string): boolean {
|
||||
return CLOUD_SWAPPED_CREDENTIALS.includes(name)
|
||||
}
|
||||
|
||||
/** An agent credential a cloud sandbox gets in full (no egress stand-in for it). */
|
||||
export function cloudSecretStoredOnVm(name: string): boolean {
|
||||
return STORED_ON_VM_NAMES.has(name)
|
||||
return AGENT_CREDENTIAL_NAMES.includes(name) && !cloudSecretSwapped(name)
|
||||
}
|
||||
|
||||
const RESERVED_NAMES: ReadonlySet<string> = new Set([
|
||||
@@ -169,25 +230,3 @@ export function isPublicHttpsUrl(value: string): boolean {
|
||||
!host.startsWith('[')
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Variables the Orca Cloud egress proxy swaps (cloud/apps/sandbox-control/src/provider-env.ts,
|
||||
* checked equal by a control-plane test): a workspace only ever holds a stand-in for these.
|
||||
*/
|
||||
export const CLOUD_SWAPPED_CREDENTIALS: readonly string[] = [
|
||||
'ANTHROPIC_API_KEY',
|
||||
'ANTHROPIC_AUTH_TOKEN',
|
||||
'AI_GATEWAY_API_KEY',
|
||||
'OPENAI_API_KEY',
|
||||
'GEMINI_API_KEY',
|
||||
'GOOGLE_GENERATIVE_AI_API_KEY',
|
||||
'CURSOR_API_KEY',
|
||||
'GOOGLE_API_KEY',
|
||||
'COPILOT_GITHUB_TOKEN',
|
||||
'COPILOT_PROVIDER_API_KEY',
|
||||
'COPILOT_PROVIDER_BEARER_TOKEN'
|
||||
]
|
||||
|
||||
export function cloudSecretSwapped(name: string): boolean {
|
||||
return CLOUD_SWAPPED_CREDENTIALS.includes(name)
|
||||
}
|
||||
|
||||
@@ -1,8 +1,31 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { cloudSecretKind, cloudSecretStoredOnVm } from './cloud-secret-rules'
|
||||
import {
|
||||
AGENT_CREDENTIAL_NAMES,
|
||||
cloudSecretKind,
|
||||
cloudSecretStoredOnVm,
|
||||
cloudSecretSwapped
|
||||
} from './cloud-secret-rules'
|
||||
|
||||
describe('agent keys the workspace VM holds in full', () => {
|
||||
it('marks only the AWS keys, which the egress proxy cannot swap', () => {
|
||||
it('flags every agent credential that is not swapped, and only those', () => {
|
||||
for (const name of AGENT_CREDENTIAL_NAMES) {
|
||||
expect(cloudSecretStoredOnVm(name), name).toBe(!cloudSecretSwapped(name))
|
||||
}
|
||||
for (const name of [
|
||||
'OPENROUTER_API_KEY',
|
||||
'GROQ_API_KEY',
|
||||
'XAI_API_KEY',
|
||||
'AWS_BEARER_TOKEN_BEDROCK'
|
||||
]) {
|
||||
expect(cloudSecretStoredOnVm(name), name).toBe(true)
|
||||
}
|
||||
// Ordinary variables are the user's own business, not agent credentials.
|
||||
for (const name of ['DATABASE_URL', 'STRIPE_SECRET_KEY', 'AWS_REGION']) {
|
||||
expect(cloudSecretStoredOnVm(name), name).toBe(false)
|
||||
}
|
||||
})
|
||||
|
||||
it('marks the AWS keys, which the egress proxy cannot swap', () => {
|
||||
for (const name of [
|
||||
'AWS_ACCESS_KEY_ID',
|
||||
'AWS_SECRET_ACCESS_KEY',
|
||||
|
||||
Reference in New Issue
Block a user