]> glassweightruler.freedombox.rocks Git - waydroid.git/commitdiff
shell: Filter imported environment
authorAlessandro Astone <ales.astone@gmail.com>
Tue, 24 Jun 2025 09:14:11 +0000 (11:14 +0200)
committerAlessandro Astone <ales.astone@gmail.com>
Tue, 24 Jun 2025 09:14:13 +0000 (11:14 +0200)
The classpath environment file might be user-writable, so we don't want the
user to be able to inject any variable in the container root shell.

tools/helpers/lxc.py

index b8c0485b921c727a7ebf22192aeafa546f124dd5..dc3011b408add7d456b9784bd50a8b13b9153c63 100644 (file)
@@ -434,13 +434,15 @@ def android_env_attach_options(args):
     command = ["lxc-attach", "-P", tools.config.defaults["lxc"],
                "-n", "waydroid", "--clear-env", "--",
                "/system/bin/cat" ,"/data/system/environ/classpath"]
+    allowed = ["CLASSPATH", "SYSTEMSERVER"]
     try:
         p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
         out, _ = p.communicate()
         if p.returncode == 0:
             for line in out.decode().splitlines():
                 _, k, v = line.split(' ', 2)
-                local_env[k] = v
+                if any(pattern in k for pattern in allowed):
+                    local_env[k] = v
     except:
         pass
     env = [k + "=" + v for k, v in local_env.items()]