mirror of
https://github.com/OpenRouterTeam/spawn.git
synced 2026-04-28 11:59:29 +00:00
fix(security): shell-quote package names in cloud-init scripts (#3220)
Apply shellQuote() to package names interpolated into startup scripts across all four cloud providers (GCP, AWS, Hetzner, DigitalOcean). Defense-in-depth against supply chain attacks where compromised package lists could inject shell metacharacters into root cloud-init scripts. Fixes #3216 Agent: security-auditor Co-authored-by: B <6723574+louisgv@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
aad03f3b1b
commit
0fe16d3ffc
4 changed files with 8 additions and 4 deletions
|
|
@ -304,6 +304,7 @@ export async function ensureSshKey(): Promise<void> {
|
|||
|
||||
function getCloudInitUserdata(tier: CloudInitTier = "full"): string {
|
||||
const packages = getPackagesForTier(tier);
|
||||
const quotedPackages = packages.map((p) => shellQuote(p)).join(" ");
|
||||
const lines = [
|
||||
"#!/bin/bash",
|
||||
"export HOME=/root",
|
||||
|
|
@ -311,7 +312,7 @@ function getCloudInitUserdata(tier: CloudInitTier = "full"): string {
|
|||
"# Guarantee the cloud-init marker is written on exit (success, failure, or signal)",
|
||||
"trap 'touch /home/ubuntu/.cloud-init-complete 2>/dev/null; touch /root/.cloud-init-complete' EXIT",
|
||||
"apt-get update -y || true",
|
||||
`apt-get install -y --no-install-recommends ${packages.join(" ")} || true`,
|
||||
`apt-get install -y --no-install-recommends ${quotedPackages} || true`,
|
||||
];
|
||||
if (needsNode(tier)) {
|
||||
lines.push(`${NODE_INSTALL_CMD} || true`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue