Skip to content

Internal IP leaks on dual stack systems #4319

Closed

Description

@Omar007

Describe the bug
If LiveKit is deployed on a dual stack system, it can leak internal addresses and does so regardless of actually making use of both or not. On a dual stack system, it will return addresses for both families at all times.

  1. If using use_external_ip: true, STUN will determine the IPv4 address but the advertised IPv6 address will be some node local address.
  2. If use_external_ip: false and node_ip: <ipv4 address>, the given address will be used for the advertised IPv4 addresses but the advertised IPv6 addresses will be some node local address.
  3. If use_external_ip: false and node_ip: <ipv6 address>, the given address will be used for the advertised IPv6 addresses but the advertised IPv4 addresses will be some node local address.

Server

  • Version: 1.9.11
  • Environment: dual stack systems

Client
N/A

To Reproduce
Steps to reproduce the behavior:

  1. Ensure running on a dual stack system. You don't even need to bind to both.
  2. Method 1:
    1. Set use_external_ip: false.
    2. Configure a node_ip, either IPv4 or IPv6 can be used. Use an address not detectable on the host itself. It does not need to be actually reachable.
  3. Method 2:
    1. Have STUN resolve the node IP value (IPv4).
  4. Connect to LiveKit. You can use the connection tester for this. It does not need to succeed in connecting, it just needs to receive and show you the advertised addresses.
  5. Observe the returned addresses in the connection tester.
  6. Note that the addresses for the other address family ends up using some address detected on the node itself.

Expected behavior

  1. Only addresses for the bound families are advertised.
  2. All used address families are resolved when using STUN.
  3. Only addresses configured in node_ip are advertised (this field should probably be changed to support multiple addresses; Node IP can only be set to 1 value #4318 )

Additional context
Because the above is currently not the case, internal addresses end up being exposed publicly when running on dual stack systems, even if only using one and not both.

Activity

  1. cnderrauber commented on Mar 4, 2026

    @cnderrauber
    Contributor

    You can use ipfilter to excludes the internal ip.
    In ipv6 there is no NAT like ipv4, can you describe the use case to resolve ipv6 by stun?

  2. Omar007 commented on Mar 4, 2026

    @Omar007
    ContributorAuthor

    There is, that would be NAT66. Though generally the more relevant one on IPv6 is NPT (stateless), not necessarily NAT66 (stateful, although NAT66 can also cover the NPT use-case).
    This is still very relevant when:
    a. Multi-homed (and control centralized, not delegated to each individual machine)
    b. Only have access to PA prefixes (or even worse, dynamically changing (PA) prefixes (yes, these providers still exist 😬 ))
    c. When using fail-over firewalls

    Aside from that, the following situations also make this relevant outside of NAT related things:
    d. Use of load balancers/(reverse) proxies (and the public address is the same for outgoing and incoming traffic)

    My current situation is a combination of 'b' and 'd' (it also used to include 'a' but for now that is not the case).

  3. biglittlebigben commented on Mar 5, 2026

    @biglittlebigben
    Contributor

    Can the existing ips/excludes config option work for your purpose?

  4. Omar007 commented on Mar 5, 2026

    @Omar007
    ContributorAuthor

    It can not. The only use-case that can cover is if you didn't actually want to be running dual stack at all.

  5. davidzhao commented on Mar 9, 2026

    @davidzhao
    Member

    have you tried setting rtc.external_ip_only: true ?

  6. cnderrauber commented on Mar 9, 2026

    @cnderrauber
    Contributor

    #4352 will have expected behavior 2 and 3. For 1, we can't do that by default as it will break current applications with only ipv4 node ip set. You can setup ip filter to avoid internal ip leaking in this case.

  7. Omar007 commented on Mar 11, 2026

    @Omar007
    ContributorAuthor

    Just rebased against master, rebuild and ran. Verified working for cases 2 and 3 and since my addresses are generally stable I don't have to rely on STUN so this works well enough 👍

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions