Skip to content
Threat Feed
high advisory

Linux: GCC Compiler Shell Execution

The GCC, C89, and C99 compilers can be leveraged to execute arbitrary shell commands via the wrapper functionality, a technique often used for privilege escalation or sandbox escapes.

Triage facts

Revision 1
Applicability
Linux
Evidence
Unknown
Severity
High
Action
Elevated
Sources
4 public sources
Freshness
Revision 1Nov 10, 02:37 UTC
Detection
1 rule
Source quality
B2Likely

The gcc, c89, and c99 utilities contain functionality that allows them to use a wrapper program for compilation. By specifying a shell binary and the -s argument via the -wrapper flag, an attacker can force the compiler to execute the shell. This behavior is documented in GTFOBins and is often utilized by threat actors to break out of restricted shells or execute commands under the context of the compiler process.

Impact

The exploitation of this feature allows for arbitrary command execution on the host system. This may lead to privilege escalation if the compiler is executed with elevated permissions or within a restricted execution environment.

Recommendation

  • Deploy the provided Sigma rule to detect suspicious use of compiler wrappers targeting shell binaries.
  • Review environments where compiler utilities are present to determine if they are required for production operations; restrict access to these binaries on systems where they are not necessary.
  • Baseline legitimate usage of the -wrapper flag in your build pipelines to differentiate between authorized builds and malicious command execution attempts.

Immediate actions

Deploy Sigma rule to identify GCC wrapper misuse

Detection Engineering 48h

Mitigations

Remove or restrict access to GCC, C89, and C99 on production systems where code compilation is not a core requirement

medium_term IT Operations

Linux compiler wrapper abuse

Detection coverage 1

Detect GCC, C89, or C99 Wrapper Shell Execution

high

Detects the use of the gcc, c89, or c99 utility with the -wrapper flag to execute a shell binary

sigma tactics: discovery techniques: T1083 sources: process_creation, linux

Detection queries are available on the platform. Get full rules →