Skip to content

Commit

Permalink
Don't expose /proc when running apply_extra
Browse files Browse the repository at this point in the history
As shown by CVE-2019-5736, it is sometimes possible for the sandbox
app to access outside files using /proc/self/exe. This is not
typically an issue for flatpak as the sandbox runs as the user which
has no permissions to e.g. modify the host files.

However, when installing apps using extra-data into the system repo
we *do* actually run a sandbox as root. So, in this case we disable mounting
/proc in the sandbox, which will neuter attacks like this.
  • Loading branch information
alexlarsson committed Feb 11, 2019
1 parent b85f386 commit cd21428
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/flatpak-common-types-private.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ typedef enum {
FLATPAK_RUN_FLAG_BLUETOOTH = (1 << 16),
FLATPAK_RUN_FLAG_CANBUS = (1 << 17),
FLATPAK_RUN_FLAG_DO_NOT_REAP = (1 << 18),
FLATPAK_RUN_FLAG_NO_PROC = (1 << 19),
} FlatpakRunFlags;

typedef struct FlatpakDir FlatpakDir;
Expand Down
2 changes: 1 addition & 1 deletion common/flatpak-dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -6786,7 +6786,7 @@ apply_extra_data (FlatpakDir *self,
NULL);

if (!flatpak_run_setup_base_argv (bwrap, runtime_files, NULL, runtime_ref_parts[2],
FLATPAK_RUN_FLAG_NO_SESSION_HELPER,
FLATPAK_RUN_FLAG_NO_SESSION_HELPER | FLATPAK_RUN_FLAG_NO_PROC,
error))
return FALSE;

Expand Down
6 changes: 5 additions & 1 deletion common/flatpak-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -2606,9 +2606,13 @@ flatpak_run_setup_base_argv (FlatpakBwrap *bwrap,
"# Disable user pkcs11 config, because the host modules don't work in the runtime\n"
"user-config: none\n";

if ((flags & FLATPAK_RUN_FLAG_NO_PROC) == 0)
flatpak_bwrap_add_args (bwrap,
"--proc", "/proc",
NULL);

flatpak_bwrap_add_args (bwrap,
"--unshare-pid",
"--proc", "/proc",
"--dir", "/tmp",
"--dir", "/var/tmp",
"--dir", "/run/host",
Expand Down

0 comments on commit cd21428

Please sign in to comment.