sandbox/seunshare: prevent path traversal via -W/-P
Stephen Smalley
maintainerPATCH 1/1 sandbox/seunshare: prevent path traversal via -W/-P
The -W/-P options specify the wayland or pipewire socket name respectively. The option argument is then concatenated with the runuserdir to create a pathname. We don't want to allow it to be used to construct arbitrary paths outside of the runuserdir. Also, check and handle
errors when bind mounting the pipewire socket file.
Signed-off-by Stephen Smalley <[email protected]>
--- sandbox/seunshare.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
sandbox/seunshare.c +8 -1
@@ -849,6 +849,12 @@ int main(int argc, char **argv) { } } +if ((wayland_display && (strchr (wayland_display,'/' ) ||strstr (wayland_display,".." ))) || + (pipewire_socket && (strchr (pipewire_socket,'/' ) ||strstr (pipewire_socket,".." )))) { +fprintf (stderr,_ ("Error: -W/-P must be a socket name, not a path\n" )); +return -1 ; + } +if (! homedir_s && ! tmpdir_s) {fprintf (stderr,_ ("Error: tmpdir and/or homedir required\n %s\n" ),USAGE_STRING );return -1 ;
@@ -990,7 +996,8 @@ int main(int argc, char **argv) {perror (_ ("Out of memory" )); goto childerr; } -seunshare_mount_file (pipewire_path, pipewire_path_s); +if (seunshare_mount_file (pipewire_path, pipewire_path_s) ==-1 ) + goto childerr; } }
Signature · 1 line
2.53.0
Stephen Smalley
maintainerQuoted 11 lines · Stephen Smalley
The -W/-P options specify the wayland or pipewire socket name respectively. The option argument is then concatenated with the runuserdir to create a pathname. We don't want to allow it to be used to construct arbitrary paths outside of the runuserdir. Also, check and handle
errors when bind mounting the pipewire socket file.Signed-off-by Stephen Smalley <[email protected]>--- sandbox/seunshare.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
Merged.