Skip to content

Instantly share code, notes, and snippets.

@forestbaker
Created October 4, 2015 05:40
Show Gist options
  • Save forestbaker/58c16149f54ba98969aa to your computer and use it in GitHub Desktop.
Save forestbaker/58c16149f54ba98969aa to your computer and use it in GitHub Desktop.
precautions to take when running SUID/SGID scripts - mitigate risk
Check if BASH_ENV is empty
set umask 077
Reset $PATH and $IFS
ALWAYS - use absolute path names
Check return codes from system utilities.
Signify the end of the option list with --
Quote all command line parameters (e.g. "$1")
Check user input for shell metacharacters and garbage
Check user supplied pathnames (absolute/relative)
set shell option noclobber to avoid overwriting existing files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment