In-depth lesson · RCE
Typical fixes
Every point the RCE reports back under this heading, best-backed first, each with the reports it is seen in.
-
Treat configuration values as inert data and never pass them into a code-execution function.
Seen in 21 reports
-
Pass untrusted values as safely quoted arguments or environment variables rather than interpolating them into the command text.
Seen in 20 reports
-
Do not check out or run code from the pull request's fork in a pull_request_target workflow; use the unprivileged pull_request event for untrusted code, or require approval before running fork code.
Seen in 19 reports
-
Avoid building shell commands from user input and pass arguments as separate values instead.
Seen in 17 reports
-
Pass arguments as separate values instead of building shell command strings.
Seen in 17 reports
-
Pass user-supplied values as separate escaped arguments instead of concatenating them into shell command strings.
Seen in 17 reports
-
Escape shell metacharacters and avoid concatenating user input into shell command strings.
Seen in 14 reports
-
Restrict deserialization to a whitelist of allowed classes and validate incoming serialized data.
Seen in 12 reports
-
Sanitise or escape user input before passing it to a shell, or avoid the shell entirely.
Seen in 12 reports
-
Restrict which classes can be deserialised and validate incoming serialised data.
Seen in 10 reports
-
Restrict which object types may be reconstructed when loading checkpoints, or use a safe format that carries no executable objects.
Seen in 10 reports
-
Validate and restrict the classes that can be instantiated when deserializing untrusted input.
Seen in 10 reports
-
Build system calls with argument separation and escaping rather than string concatenation.
Seen in 9 reports
-
Validate the source markup of uploaded application packages before processing them.
Seen in 9 reports
-
Do not call unserialize on user-controlled input; use a safe format such as JSON and validate the value.
Seen in 8 reports
-
Do not insert untrusted pull request data into scripts, and do not check out and run pull request code in workflows that use pull_request_target.
Seen in 8 reports
-
Do not pass user input to create_function or eval; use a fixed allow-list of sort columns and directions.
Seen in 7 reports
-
Restrict which object types a deserialiser may reconstruct and validate data before deserialising.
Seen in 7 reports
-
Do not write user-supplied values into executable PHP files; store data in a non-executable format and escape output.
Seen in 6 reports
-
Filter or allowlist classes accepted during deserialisation.
Seen in 6 reports
-
Properly validate user-supplied data before deserialisation.
Seen in 6 reports
-
Sanitise or strip Java EL expressions from user-controlled data before passing it to constraint violation message templates.
Seen in 6 reports
-
Validate and escape user-supplied filenames, URL strings and request header values before they reach a system call, or avoid shell invocation entirely.
Seen in 6 reports
-
Validate and safely handle data returned by the server before processing it in the client driver.
Seen in 6 reports
-
Avoid passing user-supplied strings to shell calls, or escape them properly before use.
Seen in 5 reports
-
Fix the flaw in on-premises Azure Site Recovery components that allows code execution with administrative access.
Seen in 5 reports
-
Update Log4j to a version that does not process JNDI lookups in logged messages.
Seen in 5 reports
-
Avoid building shell command lines from user input; use argument arrays and validate fields against strict allow-lists.
Seen in 4 reports
-
Clear global pointers into the request heap after fatal errors and reset worker globals before each request.
Seen in 4 reports
-
Do not interpolate pull request or comment text into shell commands, and pass untrusted values through environment variables.
Seen in 4 reports
-
Do not pass user input to evaluation or execution functions; use a sandbox that restricts what code can reach.
Seen in 4 reports
-
Escape or validate user-supplied arguments before concatenating them into shell commands.
Seen in 4 reports
-
Microsoft judged the flaws architectural and disabled RemoteFX rather than patching it.
Seen in 4 reports
-
Pass untrusted values through environment variables instead of interpolating them into shell commands.
Seen in 4 reports
-
Sanitise branch names and filenames before using them in run steps or writing them to the output file.
Seen in 4 reports
-
Use type allow-lists and secure coding flags, and never deserialise unauthenticated input.
Seen in 4 reports
-
Validate and restrict what is deserialised, and verify signatures before deserialising token or session data.
Seen in 4 reports
-
Validate input before loading libraries and correct how the application resolves library paths.
Seen in 4 reports
-
Validate user-supplied data and restrict the types that can be instantiated during deserialisation.
Seen in 4 reports
-
Avoid building shell commands from user input; use argument lists and escaping, and run with least privilege.
Seen in 3 reports
-
Avoid passing user input to a shell; use argument arrays and separate options from values with a delimiter.
Seen in 3 reports
-
Configure package managers to resolve dependencies only from the internal registry, or claim internal names on the public registry.
Seen in 3 reports
-
Do not deserialise untrusted input; restrict which classes can be instantiated and validate serialised data strictly.
Seen in 3 reports
-
Do not unserialise cookie values; validate and restrict the data, or use a signed safe format.
Seen in 3 reports
-
Ensure links that invoke the Protected View protocol cannot bypass protection.
Seen in 3 reports
-
Escape formula characters at the start of each cell, not just the whole field, and account for newline and semicolon delimiters.
Seen in 3 reports
-
Escape or validate firmware update parameters before using them in shell commands.
Seen in 3 reports
-
Match the full request path in authentication filters and validate input before shell use.
Seen in 3 reports
-
Parse untrusted fields with a restricted grammar and treat stored data as data rather than evaluating it.
Seen in 3 reports
-
Remove default administrator credentials and require strong authentication on exposed admin interfaces.
Seen in 3 reports