Linux: Git invoked with shell execution via redirected stdin to bash/dash/sh

Flags Linux command lines where git usage (with -p and help) triggers bash/dash/sh execution via stdin redirection.

FreeUnreviewedSigmahighv1
title: "Linux: Git invoked with shell execution via redirected stdin to bash/dash/sh"
id: 95692309-c22a-49ef-bd0f-258b297654af
status: test
description: This rule identifies process creation where a parent process whose command line includes the pattern for running git with help (e.g., "-p" and "help") invokes a shell. It specifically matches command lines containing stdin redirection to bash, dash, or sh ("bash 0<&1", "dash 0<&1", or "sh 0<&1"). Attackers may use this behavior to run unauthorized commands or to escape restricted execution contexts. The detection relies on Linux process creation telemetry with parent image/command line and child command line details.
references:
  - https://gtfobins.github.io/gtfobins/git/#shell
  - https://github.com/SigmaHQ/sigma/blob/master/rules/linux/process_creation/proc_creation_lnx_git_shell_execution.yml
author: Li Ling, Andy Parkidomo, Robert Rakowski, Blake Hartstein (Bloomberg L.P.), Huntrule Team
date: 2024-09-02
tags:
  - attack.execution
  - attack.t1059
logsource:
  category: process_creation
  product: linux
detection:
  selection:
    ParentImage|endswith: /git
    ParentCommandLine|contains|all:
      - " -p "
      - help
    CommandLine|contains:
      - bash 0<&1
      - dash 0<&1
      - sh 0<&1
  condition: selection
falsepositives:
  - Unknown
level: high
license: DRL-1.1
related:
  - id: 47b3bbd4-1bf7-48cc-84ab-995362aaa75a
    type: derived

What it detects

This rule identifies process creation where a parent process whose command line includes the pattern for running git with help (e.g., "-p" and "help") invokes a shell. It specifically matches command lines containing stdin redirection to bash, dash, or sh ("bash 0<&1", "dash 0<&1", or "sh 0<&1"). Attackers may use this behavior to run unauthorized commands or to escape restricted execution contexts. The detection relies on Linux process creation telemetry with parent image/command line and child command line details.

Known false positives

  • Unknown

Detection content is published as a reviewed draft. Tune thresholds and exclusions against your own telemetry before enabling this rule for alerting.