Skip to content

Fix TEST-NET-1 octet boundary in ipOps.isPrivate - #3536

Closed
pasmud wants to merge 1 commit into
nmap:masterfrom
pasmud:fix-ipops-test-net-1-boundary
Closed

pasmud wants to merge 1 commit into
nmap:masterfrom
pasmud:fix-ipops-test-net-1-boundary

Conversation

@pasmud

@pasmud pasmud commented Oct 8, 2026

Copy link
Copy Markdown

ipOps.isPrivate() matches the start of the third octet when checking TEST-NET-1. This makes addresses such as 192.0.20.1 and 192.0.200.1 return true with the range 192.0.2/24. Scripts that use this helper, including asn-query, then skip those addresses.

This adds the missing dot boundary to the pattern. Addresses within 192.0.2.0/24 still match, including the shortened and zero-padded forms already supported by the library. The regression tests check both the classification and the returned range.

Validation on Kali Linux, using Nmap 7.991SVN built from this checkout:

  • The ipOps suite passes all 109 tests. With the new tests and the original pattern, 12 assertions fail.
  • An additional offline script checks 2,304 address cases across every possible third octet and 2,304 calls to asn-query's hostrule. All pass with the fix. No DNS requests or target scans were made.
  • make -j2 nmap and git diff --check pass. The build was configured with --without-zenmap and compiled without OpenSSL and libssh2.

The unit tests can be run from the repository root with:

./nmap --datadir . --script unittest --script-args 'unittest.run,unittest.tests={ipOps}' -sn -n -d1

@nnposter nnposter self-assigned this Oct 9, 2026
@nnposter

Copy link
Copy Markdown

The fix has been committed as r39822. Unit tests for isPrivate() will be refactored in a more comprehensive fashion.
Thank you for contributing to Nmap.

@nmap-bot nmap-bot closed this in f001977 Oct 11, 2026
@nnposter

Copy link
Copy Markdown

The unit test gap has been addressed in 1c7be2c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants