Skip to content

Binary IP addresses ending in whitespace bytes are truncated #356

Description

@somethingwithproof

Describe the bug

xform_net_address() trims the input before detecting a four-byte binary IPv4 address. If the final address octet is also an ASCII whitespace byte, trim() removes it and the binary address is returned without conversion.

For example, binary c0 a8 01 0a (192.168.1.10) loses its final 0a byte.

To reproduce

Run from the plugin root:

php -r "require 'tests/bootstrap.php'; require 'lib/mactrack_functions.php'; var_dump(bin2hex(xform_net_address(hex2bin('c0a8010a'))));"

Observed:

string(6) "c0a801"

Expected:

string(12) "192.168.1.10"

The behavior was reproduced in clean PHP 8.1, 8.2, 8.3, and 8.4 Docker containers while building the cohesive MacTrack test suite.

Suggested direction

Detect and convert raw four-byte and sixteen-byte values before trimming textual input.

Activity

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

Metadata

Metadata

Labels

QABug found in QAbug

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions