Nettacker icon indicating copy to clipboard operation
Nettacker copied to clipboard

Trailing newline in wordlists causes read_from_file() to inject empty payload, causing false positives on web root in admin_scan

Open himanchalkaushale opened this issue 4 weeks ago • 0 comments

Description

When running admin_scan against a target web server with no administrative pages, Nettacker falsely reports the homepage (/) as a valid admin panel finding.

This is caused by read_from_file() in nettacker/core/fuzzer.py using .split("\n") on files that end with a trailing newline (POSIX standard EOF). The trailing newline produces an empty string ("") as the last item of the wordlist. When admin_scan fuzzes the target with this empty payload, it requests http://target:port/, which returns 200 OK, matching the success condition in admin.yaml.


Root Cause Analysis

In nettacker/core/fuzzer.py:

def read_from_file(file_path):
    with open(...) as f:
        return f.read().split("\n")

When a wordlist has a trailing newline (e.g., added to wordlists/admin_wordlist.txt in #1366):

>>> from nettacker.core.fuzzer import read_from_file
>>> w = read_from_file("wordlists/admin_wordlist.txt")
>>> len(w), repr(w[-1])
(507, '')
  • test_wordlists.py expects 506 entries, but receives 507.
  • The final entry ("") targets the web root (http://target:port/).
  • admin.yaml checks for status codes [200, 401, 403], causing any reachable website with a working homepage to be reported as a positive admin panel finding.

Broader Impact

  1. Credential Brute-Force Duplication: Wordlists such as top_1000_common_passwords.txt intentionally contain a blank first line to test for empty passwords. Because the file also ends with a trailing newline, read_from_file() appends an empty password to the end as well. Consequently, brute-force modules test the empty password twice per user (1,002 attempts instead of 1,001 as documented in Modules.md).
  2. Directory Fuzzing (dir_scan) & Custom Lists (-W): Using a custom wordlist formatted with standard POSIX trailing newlines causes dir_scan to fuzz // and report false positives on the root path.
  3. PR #1440 Impact: PR #1440 adds trailing newlines to 6 additional wordlists (dir_wordlist.txt, pma_wordlist.txt, config_wordlist.txt, wp_wordlist.txt, etc.). If merged without a fix in read_from_file(), all of these modules will also exhibit false positives against root paths.

Steps to Reproduce

  1. Start a dummy HTTP server serving a single index page:

    mkdir -p /tmp/site && echo "home" > /tmp/site/index.html
    python -m http.server 18080 --bind 127.0.0.1 --directory /tmp/site
    
  2. Run admin_scan against the dummy server:

    python nettacker.py -i 127.0.0.1 -g 18080 -d -m admin_scan
    
  3. Observed Behavior: All 506 admin paths return 404, but request 507 targets http://127.0.0.1:18080/ (200 OK) and is reported as a discovered admin page.

  4. Expected Behavior: 506 requests sent, 0 admin pages reported.


Proposed Solution

Update read_from_file() in nettacker/core/fuzzer.py to properly handle trailing EOF newlines while preserving intentional leading blank entries (such as the empty password line):

Option A (Using splitlines() - Recommended for cross-platform CRLF/LF support):

def read_from_file(file_path):
    with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
        return f.read().splitlines()

Note: splitlines() strips the single trailing newline while preserving any leading empty lines (e.g. "\npass\n".splitlines() == ['', 'pass']).

Option B (Explicit suffix removal):

def read_from_file(file_path):
    with open(file_path, "r", encoding="utf-8", errors="ignore") as f:
        return f.read().removesuffix("\n").split("\n")

Environment

  • OS: Linux Mint 22.3 / Ubuntu / Any POSIX
  • Python Version: 3.12.3
  • Nettacker Version: 0.4.2 (master @ commit f333cee)

himanchalkaushale avatar Nov 07 '26 17:11 himanchalkaushale