Skip to content

parseIPv6() mis-encodes valid IPv6 literals that end with an embedded IPv4 address #5098

@trivikr

Description

@trivikr

Bug Description

parseIPv6() mis-encodes valid IPv6 literals that end with an embedded IPv4 address

Reproducible By

import { parseIPv6 } from "undici/lib/core/socks5-utils.js";
console.log(parseIPv6("::ffff:192.0.2.128").toString("hex"));

Expected Behavior

parseIPv6('::ffff:192.0.2.128') should return the correct 16-byte IPv6 encoding for an IPv4-mapped IPv6 address:

00000000000000000000ffffc0000280

Verified using Python's standard library

python3 - <<'PY'
import ipaddress
print(ipaddress.IPv6Address('::ffff:192.0.2.128').packed.hex())
PY

Logs & Screenshots

000000000000000000000000ffff0192

Environment

macOS 26.4.1
Node v24.15.0
undici v8.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions