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

`package_name` rule doesn't work SFA 1.13.7 Play Store

Open nol0n opened this issue 7 months ago • 7 comments

Operating system

Android

System version

8.1.0; 11; 13

Installation type

sing-box for Android Graphical Client

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

1.13.7

Version


Description

package_name in route.rules does not function correctly under specific conditions, while other package-based filtering (like include_package in inbounds) works fine.

In SFA 1.13.7 from Play Store client doesn't find apps added to package_name rule. But in SFA 1.13.7 from GitHub package_name rule works correctly. Is it limitation of Play Store version of SFA?

I tested it on devices with android 11 and 13, got same behavior. Tried different versions from GitHub, this problem appeared in 1.13.0 beta 1, but it was fixed in beta 2 at least for devices with android 11 and 13.

On third device with android 8.1.0 last version in which package_name rule works is 1.13.0 alpha 36. In newer versions this rule doesn't work on this device.

However, the logs indicate that the router is identifying some system packages, just not the ones defined in the rule:

INFO[0000] router: found package name: com.google.android.gsf, com.google.android.gms
INFO[0000] [4140145133 0ms] router: found package name: com.google.android.gsf, com.google.android.gms

Reproduction

SFA 1.13.7 from the Play Store.

config.json:

{
  "dns": {
    "servers": [
      {
        "type": "https",
        "tag": "DNS-GOOGLE",
        "server": "8.8.8.8",
        "tls": {
          "server_name": "dns.google"
        },
        "detour": "PROXY"
      }
    ],
    "final": "DNS-GOOGLE",
    "strategy": "ipv4_only",
    "reverse_mapping": true
  },
  "inbounds": [
    {
      "type": "tun",
      "tag": "TUN-IN",
      "interface_name": "tun0",
      "address": [
        "172.19.0.1/30",
        "fdfe:dcba:9876::1/126"
      ],
      "mtu": 1400,
      "auto_route": true,
      "strict_route": true,
      "stack": "mixed"
    }
  ],
  "outbounds": [
    {
      "type": "direct",
      "tag": "DIRECT"
    },
    {
      "tag": "PROXY"
    }
  ],
  "route": {
    "rules": [
      {
        "inbound": "TUN-IN",
        "action": "sniff",
        "sniffer": [
          "http",
          "tls",
          "quic",
          "dns"
        ],
        "timeout": "300ms"
      },
      {
        "inbound": "TUN-IN",
        "protocol": "dns",
        "action": "hijack-dns"
      },
      {
        "inbound": "TUN-IN",
        "package_name": [
          "org.cromite.cromite"
        ],
        "action": "route",
        "outbound": "PROXY"
      }
    ],
    "final": "DIRECT",
    "auto_detect_interface": true,
    "default_domain_resolver": {
      "server": "DNS-GOOGLE"
    },
    "override_android_vpn": true
  }
}

Traffic from the specified app does not match the rule and goes to the final outbound instead.

domain_keyword rule it works fine on all devices and all client versions:

{
  "inbound": "TUN-IN",
  "domain_keyword": [
    "myip"
  ],
  "action": "route",
  "outbound": "PROXY"
},
{
  "inbound": "TUN-IN",
  "package_name": [
    "org.cromite.cromite"
  ],
  "action": "route",
  "outbound": "PROXY"
}

include_package in inbound works fine on all devices and all client versions:

"inbounds": [
  {
    "type": "tun",
    "tag": "TUN-IN",
    "interface_name": "tun0",
    "address": [
      "172.19.0.1/30",
      "fdfe:dcba:9876::1/126"
    ],
    "mtu": 1400,
    "auto_route": true,
    "strict_route": true,
    "stack": "gvisor",
    "include_package": [
      "org.cromite.cromite"
    ]
  }
]

Logs


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.

nol0n avatar Apr 13 '26 19:04 nol0n

Rules based on package_name also don't work for me on an Android 9 device with SFA-1.13.8-armeabi-v7a.apk from GitHub. On SFA-1.13.9-armeabi-v7a.apk - SFA-1.13.13-armeabi-v7a.apk too.

Dr4tez avatar Apr 17 '26 15:04 Dr4tez

I can confirm as well. On my Android 10 / API level 29 phone, GooglePlay auto-updated me to 1.13.9 today and broke my package_name rules. In the log and the connection list, there is no app information displayed at all. Not sure which working version I had before that, probably a pre-1.13.7 fDroid build

AgentConDier avatar Apr 22 '26 13:04 AgentConDier

sing-box 1.13.11 from Play Store - package_name doesn't work too

testing765 avatar Apr 25 '26 08:04 testing765

After updating to 1.13.11 (arm64-v8a in my case) from GitHub releases, my config is once again working as expected. Thanks for the fix!

AgentConDier avatar Apr 26 '26 07:04 AgentConDier

update to android bin and this happened

sing-box version 1.13.11
Environment: go1.24.13 android/arm

INFO [428200963 0ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:37808
INFO [428200963 0ms] inbound/tproxy[tproxy-in]: inbound connection to 31.131.253.250:993
INFO [428200963 1ms] router: failed to search process: process not found
INFO [428200963 1ms] outbound/direct[direct-out]: outbound connection to 31.131.253.250:993

with linux bin it's normal

sing-box version 1.13.11
Environment: go1.25.9 linux/arm

INFO [1204931000 1ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:37798
INFO [1204931000 3ms] inbound/tproxy[tproxy-in]: inbound connection to 31.131.253.250:993
INFO [1204931000 37ms] router: found process path: /system/bin/app_process32, user id: 10232
DEBUG [1204931000 38ms] router: match[1] user_id=[10232 10218 9610218 10465 10297 10523 2000] => sniff(dns)
DEBUG [1204931000 38ms] router: sniff skipped due to port considered as server-first
DEBUG [1204931000 38ms] router: match[5] user_id=[10232 2000] => route(out-proxy)
INFO [1204931000 46ms] outbound/socks[out-proxy]: outbound connection to 31.131.253.250:993

sing worked in tproxy mode, same config, just bins changed A10

k-dmitrii avatar May 03 '26 03:05 k-dmitrii

it's ok for dns

INFO [2216669339 0ms] inbound/tproxy[tproxy-in]: inbound packet connection from 192.168.43.123:29767
INFO [2216669339 0ms] inbound/tproxy[tproxy-in]: inbound packet connection to 192.168.43.1:53
INFO [2216669339 1ms] router: found package name: com.android.vending
...
INFO [4137441932 0ms] inbound/tproxy[tproxy-in]: inbound packet connection from 192.168.43.123:2595
INFO [4137441932 0ms] inbound/tproxy[tproxy-in]: inbound packet connection to 192.168.43.1:53
INFO [4137441932 0ms] router: found package name: com.whatsapp
...
INFO [3689964493 0ms] inbound/tproxy[tproxy-in]: inbound packet connection from 192.168.43.123:25254
INFO [3689964493 0ms] inbound/tproxy[tproxy-in]: inbound packet connection to 192.168.43.1:53
INFO [3689964493 1ms] router: found package name: ru.fourpda.client

but fuckup on other ports

INFO [3780438821 9ms] outbound/direct[direct-out]: outbound connection to 8.8.8.8:443
DEBUG [3780438821 1.10s] dns: exchanged dit.whatsapp.net NOERROR 48
INFO [3780438821 1.10s] dns: exchanged CNAME dit.whatsapp.net. 48 IN CNAME scontent.whatsapp.net.
INFO [3780438821 1.10s] dns: exchanged CNAME scontent.whatsapp.net. 48 IN CNAME mmx-ds.cdn.whatsapp.net.
INFO [3780438821 1.10s] dns: exchanged A mmx-ds.cdn.whatsapp.net. 48 IN A 57.144.113.32
INFO [3266935821 0ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:36451
INFO [3266935821 0ms] inbound/tproxy[tproxy-in]: inbound connection to 57.144.113.32:443
INFO [3266935821 1ms] router: failed to search process: process not found
INFO [3266935821 1ms] outbound/direct[direct-out]: outbound connection to 57.144.113.32:443
INFO [3066495526 0ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:49923
INFO [3066495526 0ms] inbound/tproxy[tproxy-in]: inbound connection to 3.151.253.23:443
INFO [3066495526 1ms] router: failed to search process: process not found
INFO [3066495526 1ms] outbound/direct[direct-out]: outbound connection to 3.151.253.23:443
...
INFO [2625066577 1ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:45445
INFO [2625066577 1ms] inbound/tproxy[tproxy-in]: inbound connection to 31.131.253.250:993
INFO [2625066577 2ms] router: failed to search process: process not found

and at the same time all ok with chrome

INFO [639409748 0ms] inbound/tproxy[tproxy-in]: inbound connection from 192.168.43.123:41621
INFO [639409748 0ms] inbound/tproxy[tproxy-in]: inbound connection to 34.160.111.145:443
INFO [639409748 9ms] router: found package name: com.android.chrome
DEBUG [639409748 9ms] router: match[0] user_id=10587 => sniff
DEBUG [639409748 21ms] router: sniffed protocol: tls, domain: ifconfig.me

k-dmitrii avatar May 03 '26 20:05 k-dmitrii

I have same issue on sing-box 1.14 alpha 26 bin for android arm64 in root environment. Some connections has no process_path parameter in clash dashboard, and these connections not routing as expected. Setting include_package parameter in tun inbound is fake decision, as these connections without package_name/process_path just don't go through sing-box and, of course, aren't shown in the logs.

f0rsie avatar Jun 03 '26 17:06 f0rsie