In-depth lesson · Command injection
Typical fixes
Every point the Command injection reports back under this heading, best-backed first, each with the reports it is seen in.
-
Validate and escape values before inserting them into generated configuration.
Seen in 3 reports
-
Escape or avoid shell interpretation of user input before building commands.
Seen in 2 reports
-
Escape configuration values before embedding them in scripts users run.
Seen in 2 reports
-
Insert a separator before user values so they cannot be read as options.
Seen in 1 report
-
Restrict which configuration-altering environment variables users can set.
-
Do not pass untrusted filter input to libraries that compile strings into functions.
Seen in 1 report
-
Account for Windows stripping trailing whitespace and periods when escaping batch file names.
-
Escape environment variable names as well as values before passing them to commands.