diff --git a/packages/cli/src/aws/aws.ts b/packages/cli/src/aws/aws.ts index cde6ade6..9ff14ab3 100644 --- a/packages/cli/src/aws/aws.ts +++ b/packages/cli/src/aws/aws.ts @@ -1086,7 +1086,7 @@ export async function runServerCapture(cmd: string, timeoutSecs?: number): Promi } export async function uploadFile(localPath: string, remotePath: string): Promise { - if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath)) { + if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath) || remotePath.includes("..")) { throw new Error(`Invalid remote path: ${remotePath}`); } const keyOpts = getSshKeyOpts(await ensureSshKeys()); diff --git a/packages/cli/src/digitalocean/digitalocean.ts b/packages/cli/src/digitalocean/digitalocean.ts index 14479f43..4b0ac4c5 100644 --- a/packages/cli/src/digitalocean/digitalocean.ts +++ b/packages/cli/src/digitalocean/digitalocean.ts @@ -1040,7 +1040,7 @@ export async function runServerCapture(cmd: string, timeoutSecs?: number, ip?: s export async function uploadFile(localPath: string, remotePath: string, ip?: string): Promise { const serverIp = ip || doServerIp; - if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath)) { + if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath) || remotePath.includes("..")) { logError(`Invalid remote path: ${remotePath}`); throw new Error("Invalid remote path"); } diff --git a/packages/cli/src/hetzner/hetzner.ts b/packages/cli/src/hetzner/hetzner.ts index c086a0ab..e7b745b5 100644 --- a/packages/cli/src/hetzner/hetzner.ts +++ b/packages/cli/src/hetzner/hetzner.ts @@ -579,7 +579,7 @@ export async function runServerCapture(cmd: string, timeoutSecs?: number, ip?: s export async function uploadFile(localPath: string, remotePath: string, ip?: string): Promise { const serverIp = ip || hetznerServerIp; - if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath)) { + if (!/^[a-zA-Z0-9/_.~-]+$/.test(remotePath) || remotePath.includes("..")) { logError(`Invalid remote path: ${remotePath}`); throw new Error("Invalid remote path"); }