From f8f1ec666afd0ec85fd6a7eff5f5b728412b4c98 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Sun, 20 Feb 2022 04:57:01 -0800 Subject: stop letting apps change directory I introduced this ability when I packaged up the lfs directory, but it can enable apps to circumvent sandboxing rules in some situations. If you can socially engineer someone to allow reading a file called 'passwd' in the current directory, you can now change directory to /etc and read something sensitive. Protecting against stuff like this gets subtle. It's easy for people to create policies that aren't robust to changing directories. Requiring absolute paths is also pretty unfriendly. So the whole notion of current directory is perhaps implicit state that is confusing to manage. Fix it in the context of a single session. --- src/lfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lfs.c b/src/lfs.c index 29c4f55..536bf99 100644 --- a/src/lfs.c +++ b/src/lfs.c @@ -1156,8 +1156,8 @@ static void set_info(lua_State * L) static const struct luaL_Reg fslib[] = { { "attributes", file_info }, - { "chdir", change_dir }, - { "currentdir", get_dir }, + /* no 'chdir' without sandboxing it */ + /* no 'currentdir' without sandboxing it */ { "dir", dir_iter_factory }, { "link", make_link }, { "lock", file_lock }, -- cgit 1.4.1-2-gfad0