mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
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>
This commit is contained in:
parent
463b8398f2
commit
fd36ff0e3d
2 changed files with 7 additions and 1 deletions
|
|
@ -191,6 +191,9 @@ export async function delegateCloudCredentials(runner: CloudRunner, _cloudName:
|
|||
for (const file of filesToDelegate) {
|
||||
const content = readFileSync(file.localPath, "utf-8");
|
||||
const b64 = Buffer.from(content).toString("base64");
|
||||
if (!/^[A-Za-z0-9+/=]+$/.test(b64)) {
|
||||
throw new Error("Unexpected characters in base64 output");
|
||||
}
|
||||
const writeResult = await asyncTryCatch(() =>
|
||||
runner.runServer(`printf '%s' '${b64}' | base64 -d > ${file.remotePath} && chmod 600 ${file.remotePath}`),
|
||||
);
|
||||
|
|
@ -498,6 +501,9 @@ export async function runOrchestration(
|
|||
async function injectEnvVars(cloud: CloudOrchestrator, envContent: string): Promise<void> {
|
||||
logStep("Setting up environment variables...");
|
||||
const envB64 = Buffer.from(envContent).toString("base64");
|
||||
if (!/^[A-Za-z0-9+/=]+$/.test(envB64)) {
|
||||
throw new Error("Unexpected characters in base64 output");
|
||||
}
|
||||
|
||||
const isLocalWindows = cloud.cloudName === "local" && isWindows();
|
||||
const envSetupCmd = isLocalWindows
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue