From 8ce36a45428830605c1537c8126de7df503e5625 Mon Sep 17 00:00:00 2001 From: Stanislaw Adaszewski Date: Mon, 27 Apr 2020 15:58:34 +0200 Subject: [PATCH] Protect against spaces in env vars --- jail.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jail.py b/jail.py index 3fa49f2..605336d 100644 --- a/jail.py +++ b/jail.py @@ -27,6 +27,8 @@ def jail_fs_create(image): def gen_env_command(command, env): + if any(map(lambda a: ' ' in a, env.keys())): + raise ValueError('Environment variable names cannot contain spaces') env = [ 'export ' + k + '=' + shlex.quote(v) \ for (k, v) in env.items() ] command = ' && '.join(env + [ command ])