Skip to content

Commit fd36ff0

Browse files
la14-1louisgvclaude
authored
fix(security): add base64 validation guards in orchestrate.ts (fixes #3006) (#3007)
Add /^[A-Za-z0-9+/=]+$/ validation after each .toString("base64") call in delegateCloudCredentials() and injectEnvVars(), consistent with the pattern established in agent-setup.ts by #2988. Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 463b839 commit fd36ff0

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

packages/cli/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@openrouter/spawn",
3-
"version": "0.26.9",
3+
"version": "0.26.10",
44
"type": "module",
55
"bin": {
66
"spawn": "cli.js"

packages/cli/src/shared/orchestrate.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ export async function delegateCloudCredentials(runner: CloudRunner, _cloudName:
191191
for (const file of filesToDelegate) {
192192
const content = readFileSync(file.localPath, "utf-8");
193193
const b64 = Buffer.from(content).toString("base64");
194+
if (!/^[A-Za-z0-9+/=]+$/.test(b64)) {
195+
throw new Error("Unexpected characters in base64 output");
196+
}
194197
const writeResult = await asyncTryCatch(() =>
195198
runner.runServer(`printf '%s' '${b64}' | base64 -d > ${file.remotePath} && chmod 600 ${file.remotePath}`),
196199
);
@@ -498,6 +501,9 @@ export async function runOrchestration(
498501
async function injectEnvVars(cloud: CloudOrchestrator, envContent: string): Promise<void> {
499502
logStep("Setting up environment variables...");
500503
const envB64 = Buffer.from(envContent).toString("base64");
504+
if (!/^[A-Za-z0-9+/=]+$/.test(envB64)) {
505+
throw new Error("Unexpected characters in base64 output");
506+
}
501507

502508
const isLocalWindows = cloud.cloudName === "local" && isWindows();
503509
const envSetupCmd = isLocalWindows

0 commit comments

Comments
 (0)