Skip to content

Compressed IPv6 addresses are corrupted by xform_net_address #355

Description

@somethingwithproof

Describe the bug

xform_net_address() converts valid short/compressed IPv6 text as though it were a colon-delimited hexadecimal IPv4 value.

For example, 2001:db8::1 becomes 8193.3512.0.1. The function currently assumes any colon-delimited input with a string length of 11 characters or fewer is hexadecimal IPv4.

To reproduce

Run from the plugin root:

php -r "require 'tests/bootstrap.php'; require 'lib/mactrack_functions.php'; var_dump(xform_net_address('2001:db8::1'));"

Observed:

string(15) "8193.3512.0.1"

Expected:

string(11) "2001:db8::1"

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

Recognize valid IPv6 text (for example with filter_var(..., FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) before applying the legacy hexadecimal IPv4 conversion.

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