sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

Inbound UDP connections from Tailscale not working properly after update to 1.13+

Open AgentConDier opened this issue 8 months ago • 3 comments

Operating system

Android

System version

Android 10 / API level 29 / EMUI 12.0.0 / Security-Patchlevel May 1st 2022

Installation type

sing-box for Android Graphical Client

If you are using a graphical client, please provide the version of the client.

1.13.1 (SFA-1.13.1-arm64-v8a.apk)

Version


Description

After updating to 1.13, I can't connect to Termux on my phone using mosh via Tailscale anymore.

Tests using netcat show that the connection is recognized by sing-box, but no data/packets are received by the listener. TCP connections work fine and are not affected.

If I downgrade to the latest pre-1.13 version, everything works as expected (tested using SFA-1.12.23-arm64-v8a.apk)

My 2nd phone with Android 16 is showing the same symptoms.

Reproduction

Config JSON
{
  "log": {
    "level": "trace",
    "output": "box.log"
  },
  "dns": {
    "servers": [
      {
        "type": "local",
        "tag": "local-dns"
      }
    ],
    "rules": [],
    "final": "local-dns"
  },
  "endpoints": [
    {
      "type": "tailscale",
      "tag": "ts-ep",
      "domain_resolver": "local-dns"
    }
  ],
  "inbounds": [
    {
      "type": "direct",
      "tag": "loopback-test",
      "network": "udp",
      "listen": "127.0.0.1",
      "listen_port": 60012,
      "override_port": 60013
    }
  ],
  "outbounds": [
    {
      "type": "direct",
      "tag": "direct-out"
    }
  ],
  "route": {
    "rules": [
      {
        "inbound": "ts-ep",
        "port": 60011,
        "udp_connect": true,
        "action": "route-options"
      }
    ],
    "final": "direct-out"
  }
}

General Setup

  • Install Termux or any similar app that provides the nc command on android (use pkg install netcat-openbsd inside termux to install netcat)
  • Import the configuration into SFA and start the profile
  • Authenticate to tailscale (can be accelerated by adding an auth_key to the tailscale endpoint, generate one here)
  • Prepare a second host connected to the same tailnet with netcat installed to serve as the client while testing. Referred to as PC below.

Test case 1

  • Android: start nc -vulp 60010
  • PC: start nc -u termux 60010 (replace termux with the tailscale hostname assigned to sing-box)
  • PC: enter some text and press enter to open the UDP connection
  • Android: enter some text and press enter to send a response
Results on 1.12.23 Netcat on android reports an incoming connection from localhost. UDP messages sent from either side are received by the other device.

sing-box log messages:

TRACE endpoint/tailscale[ts-ep]: [v1] Accept: UDP{100.83.23.111:33803 > 100.88.133.79:60010} 33 ok
INFO endpoint/tailscale[ts-ep]: inbound packet connection from 100.83.23.111:33803
INFO endpoint/tailscale[ts-ep]: inbound packet connection to 127.0.0.1:60010
INFO outbound/direct[direct-out]: outbound packet connection
Results on 1.13.1 Netcat on android does not receive the incoming connection. UDP messages sent from either side are not received.

sing-box log messages:

TRACE endpoint/tailscale[ts-ep]: [v1] Accept: UDP{100.83.23.111:52997 > 100.88.133.79:60010} 33 ok
INFO [3745872642 0ms] endpoint/tailscale[ts-ep]: inbound packet connection from 100.83.23.111:52997
INFO [3745872642 0ms] endpoint/tailscale[ts-ep]: inbound packet connection to 127.0.0.1:60010
INFO [3745872642 2ms] router: failed to search process: App must either be an active VPN or have the NETWORK_STACK permission
INFO [3745872642 2ms] outbound/direct[direct-out]: outbound packet connection

Test case 2

  • Android: start nc -vulp 60011. This port will match the rule and enable the udp_connect option.
  • PC: start nc -u termux 60011
  • PC: enter some text and press enter to open the UDP connection
  • Android: enter some text and press enter to send a response
Results on 1.12.23 Netcat on android reports an incoming connection from localhost. UDP messages sent from either side are received by the other device.

sing-box log messages:

TRACE endpoint/tailscale[ts-ep]: wg: [v2] [P1afG] - Received handshake initiation
INFO endpoint/tailscale[ts-ep]: inbound packet connection from 100.83.23.111:33587
TRACE endpoint/tailscale[ts-ep]: wg: [v2] [P1afG] - Sending handshake response
INFO endpoint/tailscale[ts-ep]: inbound packet connection to 127.0.0.1:60011
DEBUG router: match[0] inbound=ts-ep port=60011 => route-options(udp-connect)
INFO outbound/direct[direct-out]: outbound packet connection to 127.0.0.1:60011
TRACE connection: packet upload closed
TRACE connection: packet upload closed
TRACE connection: packet download closed
TRACE connection: packet download closed
Results on 1.13.1 Netcat on android reports an incoming connection from localhost. UDP messages sent from PC are received on android, but responses from android don't arrive on PC.

sing-box log messages:

TRACE endpoint/tailscale[ts-ep]: [v1] Accept: UDP{100.83.23.111:47711 > 100.88.133.79:60011} 33 ok
INFO [327532484 0ms] endpoint/tailscale[ts-ep]: inbound packet connection from 100.83.23.111:47711
INFO [327532484 0ms] endpoint/tailscale[ts-ep]: inbound packet connection to 127.0.0.1:60011
INFO [327532484 2ms] router: failed to search process: App must either be an active VPN or have the NETWORK_STACK permission
DEBUG [327532484 2ms] router: match[0] inbound=ts-ep port=60011 => route-options(udp-connect)
INFO [327532484 2ms] outbound/direct[direct-out]: outbound packet connection to 127.0.0.1:60011

Test case 3

  • To demonstrate the behavior without tailscale, I have included a UDP loopback listener in the config.
  • Android: start nc -vulp 60013
  • Android (in a 2nd console session): start nc -u localhost 60012
  • Send some data back and forth
Results on 1.12.23 Netcat reports an incoming connection from localhost. UDP messages sent from either side are received by the other netcat instance.

sing-box log messages:

INFO [2461823342 0ms] inbound/direct[loopback-test]: inbound packet connection from 127.0.0.1:41821
INFO [2461823342 0ms] inbound/direct[loopback-test]: inbound packet connection to 127.0.0.1:60013
INFO [2461823342 1ms] outbound/direct[direct-out]: outbound packet connection
Results on 1.13.1 Netcat reports an incoming connection from localhost. UDP messages sent from either side are received by the other netcat instance.

sing-box log messages:

INFO [1115721949 3ms] inbound/direct[loopback-test]: inbound packet connection from 127.0.0.1:47447
INFO [1115721949 3ms] inbound/direct[loopback-test]: inbound packet connection to 127.0.0.1:60013
INFO [1115721949 6ms] router: failed to search process: App must either be an active VPN or have the NETWORK_STACK permission
INFO [1115721949 7ms] outbound/direct[direct-out]: outbound packet connection

Summary

① Tailscale -> direct-out ② Tailscale -> direct-out
udp_connect: true
③ direct-in -> direct-out
1.12.23 ok ok ok
1.13.1 no connection receive only ok

Logs

See https://github.com/user-attachments/files/25798931/unabridged-logfile.log

Supporter

Integrity requirements

  • [x] I confirm that I have read the documentation, understand the meaning of all the configuration items I wrote, and did not pile up seemingly useful options or default values.
  • [x] I confirm that I have provided the server and client configuration files and process that can be reproduced locally, instead of a complicated client configuration file that has been stripped of sensitive data.
  • [x] I confirm that I have provided the simplest configuration that can be used to reproduce the error I reported, instead of depending on remote servers, TUN, graphical interface clients, or other closed-source software.
  • [x] I confirm that I have provided the complete configuration files and logs, rather than just providing parts I think are useful out of confidence in my own intelligence.

AgentConDier avatar Mar 06 '26 15:03 AgentConDier

In version 1.13.x, to improve performance or fix other UDP forwarding issues, Sing-box adjusted the routing logic for the first UDP packet. Now, for UDP packets, if L7 sniffing hasn't returned a result, the routing engine may directly allow the first packet according to existing IP rules.

eurekaevan avatar Mar 08 '26 10:03 eurekaevan

Now, for UDP packets, if L7 sniffing hasn't returned a result, the routing engine may directly allow the first packet according to existing IP rules.

I am not using L7 sniffing. And in any case, bypassing any rules would not affect UDP connectivity in my test case.

In other news, I can reproduce the issue in the android emulator using the steps and configuration posted above. I used the API 36.0 ‘Google Play Intel x86_64 Atom‘ image, and the following APKs: SFA 1.12.23 (UDP works) SFA 1.13.2 (UDP not working) Termux 0.118.3

AgentConDier avatar Mar 09 '26 01:03 AgentConDier

Updated to 1.13.3 via f-droid today, can confirm UDP connections are working as expected again. Thanks a lot!

AgentConDier avatar Mar 20 '26 20:03 AgentConDier