Nettacker icon indicating copy to clipboard operation
Nettacker copied to clipboard

IndexError in generate_loops() when a single-payload module's service isn't detected and --exclude-ports is used

Open NSK-394 opened this issue 4 months ago • 2 comments

generate_loops() in nettacker/core/module.py (~line 111-118) crashes with IndexError: list index out of range when a module has exactly one payload using a recognized service-discovery library (ssh, ftp, smtp, smb, pop3, telnet, http, etc.) and that service wasn't detected open on the target, combined with --exclude-ports.

Root cause: load() (module.py:92-99) deletes the payload from module_content["payloads"] when its library wasn't detected in discovered_services, leaving payloads == []. self.module_content itself stays truthy, so a later guard passes and ["payloads"][0] raises IndexError.

Verified against a real module: nettacker/modules/brute/ssh.yaml (single payload, library: ssh, has a ports key in steps[0]) matches the crash conditions exactly.

Existing test coverage gap: tests/core/test_exclude_ports.py has two tests for generate_loops() (test_generate_loops_with_excluded_ports_and_ports_in_content, test_generate_loops_with_excluded_ports_no_ports_in_content), but both manually construct module_content with payloads[0] already present and never call load() first — so neither exercises the actual crash path.

Reproduce: python3 nettacker.py -i -m ssh_brute --exclude-ports 21 -u a -p b against a host where SSH's port is closed/filtered.

Impact: the worker thread for that module/target crashes silently (uncaught, printed to stderr, not surfaced in the report) — the module produces zero results instead of a clean "port closed" outcome. Every other single-payload brute module (ftp, ftps, smtp, smtps, pop3, pop3s, telnet) is affected the same way.

I'd like to work on this — will add a regression test that exercises load() + generate_loops() together against a module like ssh_brute to close the existing coverage gap. Could this be assigned to me? @securestep9

NSK-394 avatar Jul 27 '26 10:07 NSK-394

@NSK-394 Nettacker never produces a "port closed" outcome, so while this bug exists the impact on the accuracy of the scan is minimal. Irrespective of whether this bug is fixed, the module report will contain no findings; at the moment the module silently crashes (and produces no results) when it should instead be skipped cleanly (and still produce no results).

This is therefore a low-priority, low-impact reliability bug, rather than a security or detection accuracy issue. Nettacker is a security scanner, so an impactful bug would be one that causes false negatives (missing a real vulnerability or service), false positives (reporting a vulnerability that does not exist), corrupted output, or causes the scan to terminate prematurely. This issue does none of those - it affects the scanner's internal control flow and robustness, not the correctness of the scan results.

That said, it is still worth fixing, as modules should fail gracefully and maintain a consistent internal state rather than terminating with an unhandled exception.

While I am happy to assign this issue to you, I'd encourage you to spend your time looking for higher-impact issues. Bugs affecting detection accuracy, scan coverage, module correctness, performance, or security or new features such as new CISA KEV vulnerability detection modules are generally a much higher priority for the project and provide significantly greater value to Nettacker users.

securestep9 avatar Jul 27 '26 11:07 securestep9

Understood, thanks for the context on impact makes sense given Nettacker doesn't have a "port closed" outcome to begin with. I'll get this fixed as a quick, self-contained PR since it's assigned, then focus on higher-impact work. Actually already had a new CISA KEV module in progress (CVE-2026-33017, unauthenticated RCE in Langflow) will follow up with that separately.

NSK-394 avatar Jul 27 '26 11:07 NSK-394