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.
This commit is contained in:
Kartik K. Agaram 2022-02-20 04:57:01 -08:00
parent b36927e35c
commit f8f1ec666a
2 changed files with 3 additions and 2 deletions

View File

@ -187,6 +187,7 @@ Teliva also introduces some incompatibilities to protect computer owners:
- `os.execute`, `os.getenv`, `io.popen`
- `io.lines` (not a security issue; just difficult to distinguish missing
files from sandboxing issues)
- `lfs.chdir`, `lfs.currentdir`
* Some functions are disabled because they don't seem to make sense in an
ncurses environment. This includes the Lua notions of default files, which
start out as stdin/stdout.

View File

@ -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 },