NekoBoxForAndroid icon indicating copy to clipboard operation
NekoBoxForAndroid copied to clipboard

Optional authentication for the local proxy port and plugin SOCKS ports

Open simwin opened this issue 4 weeks ago • 1 comments

Description suggestions

NekoBox always starts a mixed inbound on 127.0.0.1:<port> (2080 by default), in both VPN and proxy-only mode, without authentication. External plugins (naive, mieru, …) also listen on a random 127.0.0.1 port with an unauthenticated SOCKS5 server.

Any app on the device can connect to these ports and send traffic through the proxy, including apps excluded from the VPN by per-app proxy. Such an app learns the exit IP of the user's server and bypasses per-app routing. This is used in practice to detect proxy clients on Android (see e.g. https://habr.com/ru/articles/1022422/, April 2026).

Proposal:

  1. A setting "Require authentication for local proxy". When it is on, the mixed inbound gets users with a random username/password, generated once per install and stored in the app database.
  2. The app's own requests through the local port (subscription updates, update check, rule-set downloads via HTTPClient.TrySocks5 in libcore) pass these credentials. A sing-box SOCKS5 server without users still accepts a client that offers username/password, so the app can always send them, whatever the setting.
  3. The settings screen shows the credentials, so they can be entered in other apps that use the local proxy (for example a tg://socks?... link for Telegram in proxy-only mode).
  4. External plugins get the same credentials: mieru through socks5Authentication in the client config (mieru 3.4.0+), naive through listen: socks://user:[email protected]:port, and the sing-box socks outbound to the plugin uses them.
  5. Not covered: "Append HTTP proxy to VPN" (Android's ProxyInfo cannot carry credentials) and the direct mapping inbounds that plugins use to reach the server.

I have this working in a personal build on top of 1.4.2 (naive and mieru with auth, Telegram through the local port) and can send a PR. Two questions first:

  • Should it be on by default, or opt-in? On by default breaks setups where other apps or LAN devices use the port without credentials.
  • Is a minimum mieru plugin version acceptable, or should authentication be skipped for older plugins?

Necessity of recommendations

The local ports are the easiest way for other apps on the device to find out that a proxy is running and which server it uses, even when those apps are excluded from the VPN. Authentication closes this without changing anything for users who keep it off.

simwin avatar Nov 04 '26 12:11 simwin

This fix must not be optional. Security must never be optional.

EternalBlueInfinity avatar Nov 14 '26 17:11 EternalBlueInfinity