VT 108021 (Nmap OS Identification) truncates the OS host detail at the first n

VT: Nmap OS Identification (NASL wrapper) — OID 1.3.6.1.4.1.25623.1.0.108021, family Service detection
Feed revision: script_version("2024-06-26T05:05:39+0000")

Symptom

When this VT is the only source of OS information in a report, the OS host detail is truncated at the first lowercase n of the OS name:

nmap OS details host detail OS
Linux Li
Windows 7 Wi
Ubuntu 18.04 Ubu

This is not a fixed-length slice: Linux and Ubuntu lose 3 characters, Windows 7 loses 5. The cut always lands right before the first n.

It is a deterministic truncation, not the usual nmap non-determinism / fuzzy fingerprinting. A host detail OS = Li was observed on 18 hosts in a scan where 108021 was the only source for that detail.

Root cause

The VT extracts the OS name from the nmap log with a double-quoted pattern:

osTxt = eregmatch(string: res, pattern: "OS( details)?:\s*([^\n;]+)", icase: FALSE);

In NASL, tokenize_string (double quotes) does not process escape sequences — only tokenize_data (single quotes) applies .replace("\n", <LF>). So \n reaches the POSIX regex engine as two literal characters, \ and n.

POSIX ERE does not treat \ as an escape inside a bracket expression, therefore [^\n;] is the negation of the set { \ , n , ; } — “match until a backslash, an n, or a semicolon”. Linux consequently stops at the first n.

\s* still works, because it sits outside the bracket expression and uses the GNU extension — which is why the stored value has no leading space. Both behaviours coexist consistently with the output above.

Minimal reproduction (no GVM required)

printf 'Linux\n'   | grep -oE '[^\n;]+'   # -> Li
printf 'Windows\n' | grep -oE '[^\n;]+'   # -> Wi
printf 'Ubuntu\n'  | grep -oE '[^\n;]+'   # -> Ubu
printf 'Linux\n'   | grep -oP '[^\n;]+'   # -> Linux   (PCRE: \n is an escape inside [])

Suggested fix

Use a single-quoted pattern, so the newline is real before the regex is compiled:

osTxt = eregmatch(string: res, pattern: 'OS( details)?:\s*([^\n;]+)', icase: FALSE);

If you prefer to stay independent of tokenizer semantics, spell the class out: [^\\\n;]+.

Why this is easy to miss

Li looks like a plausible short value, and GSA does not render the OS host detail in its host view (it uses best_os_txt / best_os_cpe), so the truncation is invisible in the UI. It only shows up for consumers that read this particular host detail.

Please let me know if you would like a full --details report export for a host where this reproduces.

Hello,

welcome to this community forums and thanks for your report. Only short:

  1. The overall report was actually right, expect an update to the relevant code in one of the next few feed updates
  2. The suggested fix was actually not fully correct and would have caused a NASL syntax error

In general it would be appreciated to use shorter / more on point descriptions for such minor things rather then such (presumably AI generated) too verbose output from which it is usually difficult to extract relevant parts from.

1 Like