Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions api/src/secure-startup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,18 @@ describe('hardened sandbox-runner startup config', () => {
expect(() => validateHardenedSandboxStartup()).toThrow('REDIS_HOST');
});

test('allows Lambda MicroVM image metadata while rejecting AWS credentials', () => {
setValidHardenedConfig();
process.env.AWS_LAMBDA_MICROVM_IMAGE_ARN = 'arn:aws:lambda:us-east-1:123456789012:microvm-image:codeapi';
process.env.AWS_LAMBDA_MICROVM_IMAGE_NAME = 'codeapi';
process.env.AWS_LAMBDA_MICROVM_IMAGE_VERSION = '3';
process.env.AWS_REGION = 'us-east-1';
expect(() => validateHardenedSandboxStartup()).not.toThrow();

process.env.AWS_ACCESS_KEY_ID = 'access-key';
expect(() => validateHardenedSandboxStartup()).toThrow('AWS_ACCESS_KEY_ID');
});

test('rejects missing manifest verifier and wrong forwarding target', () => {
setValidHardenedConfig();
config.egress_gateway_url = '';
Expand Down
9 changes: 8 additions & 1 deletion api/src/secure-startup.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { config } from './config';
import { workspaceIsolationConfigErrors } from './workspace-isolation';

const ALLOWED_LAMBDA_MICROVM_AWS_ENV = new Set([
'AWS_LAMBDA_MICROVM_IMAGE_ARN',
'AWS_LAMBDA_MICROVM_IMAGE_NAME',
'AWS_LAMBDA_MICROVM_IMAGE_VERSION',
'AWS_REGION',
]);

export class SandboxSecureStartupError extends Error {
constructor(message: string) {
super(message);
Expand Down Expand Up @@ -57,7 +64,7 @@ function forbiddenEnvNames(): string[] {
if (name === 'CODEAPI_HARDENED_SANDBOX_MODE') continue;
if (name.startsWith('CODEAPI_')) forbidden.push(name);
if (name.startsWith('REDIS_')) forbidden.push(name);
if (name.startsWith('AWS_')) forbidden.push(name);
if (name.startsWith('AWS_') && !ALLOWED_LAMBDA_MICROVM_AWS_ENV.has(name)) forbidden.push(name);
if (name.startsWith('S3_')) forbidden.push(name);
if (name.startsWith('MINIO_')) forbidden.push(name);
if (/(SECRET|TOKEN|PASSWORD|PRIVATE_KEY)/.test(name)) forbidden.push(name);
Expand Down