From 3a126ffa9d84ffcefb868ac634b6137b160731e1 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 26 Jan 2023 08:48:35 +0530 Subject: [PATCH] Restore permissions check on pwfile just use RW instead of R as the expected mode --- kittens/ssh/main.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kittens/ssh/main.py b/kittens/ssh/main.py index cacc60ff0..70ebd9814 100644 --- a/kittens/ssh/main.py +++ b/kittens/ssh/main.py @@ -50,6 +50,9 @@ def read_data_from_shared_memory(shm_name: str) -> Any: shm.unlink() if shm.stats.st_uid != os.geteuid() or shm.stats.st_gid != os.getegid(): raise ValueError('Incorrect owner on pwfile') + mode = stat.S_IMODE(shm.stats.st_mode) + if mode != stat.S_IREAD | stat.S_IWRITE: + raise ValueError('Incorrect permissions on pwfile') return json.loads(shm.read_data_with_size())