Skip to content

One model output format leak or front-end parsing exception #952

Description

@danqing-xjcc

1、The prompt I sent to the freebuff cli:
"Shell script for detecting the existence of local network IP addresses"

2、freebuff cli output content section:
Review /root/lsy/net-scan.sh — a new bash script for local network host discovery (parallel ping sweep, optional ARP-table and TCP port modes, CIDR/range/auto-detect target parsing). Look for correctness bugs (especially in the bash arithmetic IP math, xargs -P invocation, quoting inside nested bash -c, set -euo pipefail interactions, sort/awk portability) and suggest fixes.
Let me trace through the script for correctness bugs, focusing on the areas the reviewer asked about: bash arithmetic IP math, xargs -P invocation, nested bash -c quoting, set -euo pipefail interactions, and sort/awk portability.
Key findings:

  1. scan_cidr lost in pipeline subshell — In main, for t in ...; do ... done | sort -u ... > "$tmp" puts the loop in a subshell (only the last pipeline element runs in the current shell). So scan_cidr=$t and the auto-detect scan_cidr=$(detect_cidr) assignments are lost. Result: --arp mode always warns "needs a CIDR target" even when one was given, in both explicit-CIDR and auto-detect modes. Real bug.
  2. set -e kills script on "no hosts found" — found=$(ping_sweep "$tmp") : when zero hosts reply, every bash -c invocation exits 1, and xargs exits 123. The assignment fails → set -e aborts before printing the "0 of N alive" summary. Same for port_sweep . Also arp_hits=$(arp_hosts "$bcast") : arp_hosts' last statement is [[ -n "$out" ]] && printf ... , which returns 1 when the neighbor table is empty → set -e kills. Also name=$(resolve_host "$t") : getent/host exit non-zero when there's no PTR record → set -e kills mid-loop when any host has no reverse DNS. All need || true or explicit failure handling.
  3. usage() sed prints all # comments — sed -n 's/^# {0,1}//p' "$0" matches every comment line in the file, so --help output is polluted with inline comments inside functions ("# Emit every usable host address...", "# Broadcast address for a CIDR...", etc.), not just the header. Should use a heredoc or an awk that stops at the first non-comment line.
  4. detect_cidr Linux-ifconfig fallback parses wrong field — macOS ifconfig is inet IP netmask 0xffffff00 ... ($2=IP, $4=netmask) which is correct, but Linux ifconfig is inet addr:IP Bcast:... Mask:... where $4 is Bcast: and the netmask is $6. The awk grabs $4 and would feed "Bcast:192.168.1.255" to netmask_to_prefix → wrong prefix. Also read returning 1 on no-interface relies on set -e to abort (degraded but works due to || die ).
  5. arp_hosts arp-scan pipeline under pipefail — out+=$'\n'"$(arp-scan ... | awk ...)" : arp-scan exits 1 when run without root, pipefail makes the substitution fail → set -e.
  6. Very large CIDRs — expand_cidr allows /8 (/8 = 16.7M addresses) → the for ((i=start; i<=end; i++)) loop effectively hangs; the 65536 warning only fires after expansion. Should warn/cap at /16 or so.
  7. Minor: invalid IP inputs like abc/24 or 3-octet 192.168.1-10 produce garbage scans (ip2dec yields 0.0.0.x) instead of a warning; --port with no value silently becomes "no port".
    The bash arithmetic itself is fine (bash is 64-bit, IPv4 fits without overflow). xargs -P / -I quoting and nested bash -c are correct. sort -k flags and awk are portable.</||DSML||parameter>
    </||DSML||invoke>
    </||DSML||tool_calls>

3、issue
This appears to be a model output format leak or a front-end parsing exception.
The first part is a code review of a Bash network scanning script, listing potential problems with set-e, pipe subshells, arp-scan, CIDR unfolding-and so on. But at the end:
</||DSML||parameter>
</||DSML||invoke>
</||DSML||tool_calls>
Rather than censoring content, it is a control marker that would otherwise be used within the system to organize parameters, tool calls, or message boundaries. Normally, these tags should be parsed and hidden by the interface layer and should not be displayed directly to the user.
Could the engineers please identify the cause?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions