Summary
A logic flaw in Coturn's address handling allows IPv4-mapped IPv6 addresses (such as ::ffff:127.0.0.1) to bypass loopback and internal range restrictions configured with denied-peer-ip and default loopback protections.
Under these conditions, an attacker can create TURN permissions or channels to otherwise blocked internal or loopback endpoints, potentially exposing internal services to unauthorized relay traffic.
Affected context
This vulnerability affects Coturn deployments that:
- Rely on
denied-peer-ipand/or built-in loopback protections to block access to loopback or internal IP ranges, and - Process TURN
CreatePermissionorChannelBindrequests, and - Run versions where IPv4-mapped IPv6 addresses (e.g.,
::ffff:127.0.0.1) are not normalized and checked consistently against access control rules.
The issue appears when TURN peers are specified using IPv4-mapped IPv6 forms instead of plain IPv4, allowing traffic that is intended to be blocked by policy.
Exploit preconditions
- Attack surface: TURN server interface exposed to clients on the network or internet.
- Required access: Ability to authenticate or otherwise use the TURN service to send
CreatePermissionorChannelBindrequests (depending on deployment, this may be open or restricted). - Trigger point: Supplying a
XOR-PEER-ADDRESSfield using an IPv4-mapped IPv6 address (e.g.,::ffff:127.0.0.1) that corresponds to an IPv4 address covered bydenied-peer-ipor loopback restrictions. - Why exploitation is possible: Internal address classification and range-matching functions (
ioa_addr_is_loopback(),ioa_addr_is_zero(),addr_less_eq()/ioa_addr_in_range()) do not recognize IPv4-mapped IPv6 addresses as equivalent to their IPv4 counterparts before enforcing deny rules, causing the access checks to be skipped or mis-evaluated.
Why this happens
The root cause is inconsistent handling of address families and IPv4-mapped IPv6 addresses in Coturn's access control logic.
Several key functions in src/client/ns_turn_ioaddr.c treat IPv4 (AF_INET) and IPv6 (AF_INET6) addresses as separate categories without first normalizing or extracting embedded IPv4 from IPv4-mapped IPv6 addresses:
ioa_addr_is_loopback()only checks127.x.x.xand::1, but not::ffff:127.0.0.1.ioa_addr_is_zero()only checks0.0.0.0and::, but not::ffff:0.0.0.0.addr_less_eq()(used byioa_addr_in_range()fordenied-peer-ipmatching) comparesAF_INETranges toAF_INET6peers without resolving IPv4-mapped addresses to the underlying IPv4 value, returning 0 and effectively skipping enforcement.
This design flaw maps to CWE-284: Improper Access Control, as access decisions are incorrectly evaluated for a subset of addresses, and is related to CWE-441: Unintended Proxy or Intermediary because the TURN server may relay traffic to internal endpoints that should not be reachable.
Potential impact
- TURN relaying to loopback addresses (e.g.,
127.0.0.1) that are intended to be blocked by policy. - Access to internal or management services bound only to localhost, via TURN as an unintended proxy.
- Bypass of configured
denied-peer-iprules and loopback protections using IPv4-mapped IPv6 notation. - Expanded attack surface for internal reconnaissance, exploitation, or brute-force against services assumed to be locally reachable only.
- Increased risk of data exposure or service compromise if sensitive internal endpoints are accessed through the TURN server.
General mitigation guidance
Effective mitigation typically involves tightening address normalization and access control evaluation rather than relying on specific patterns or blocklists alone.
Defenders commonly:
- Normalize and canonicalize all incoming peer addresses before policy evaluation, converting IPv4-mapped IPv6 to a consistent internal representation.
- Apply loopback and private-range checks uniformly to IPv4, IPv6, and IPv4-mapped IPv6 addresses.
- Design deny/allow logic to be default-deny for ambiguous address forms, only granting access when classification is unambiguous.
- Treat the TURN server as a sensitive network boundary component and restrict which back-end networks and addresses it is allowed to reach (e.g., avoid allowing relays to loopback or management subnets at all).
- Reduce privileges of the TURN service at the OS and network layer (e.g., firewall rules, routing constraints) so that even if logical checks fail, the process cannot reach internal-only interfaces.
How teams detect issues like this
Detection usually focuses on both code-level and operational signals:
- Static/code analysis:
- Search for address comparison logic that branches on
AF_INETvsAF_INET6without explicitly checkingIN6_IS_ADDR_V4MAPPEDor equivalent helpers. - Flag any access control routines (
*_in_range,*_is_loopback, or similar) that do not normalize IPv4-mapped IPv6 addresses prior to evaluation. - Use static analysis rules to identify IP/port filtering implemented separately for IPv4 and IPv6 without a shared canonical path.
- Code review cues:
- Review network boundary code for assumptions that "IPv4 and IPv6 are disjoint," especially around deny/allow lists.
- Confirm that loopback and special addresses (
0.0.0.0,::,127.0.0.1,::1) are treated equivalently across all supported address families.
- Runtime/operational monitoring:
- Log
CreatePermissionandChannelBindrequests, including resolved peer addresses, and alert on IPv4-mapped IPv6 forms targeting loopback or internal ranges. - Implement anomaly detection for TURN relays to local or management endpoints.
Automated review and SAST tools can be configured with custom rules to highlight inconsistent address-family handling and missing IPv4-mapped IPv6 checks in network access control logic.

