Optional authentication for the local proxy port and plugin SOCKS ports
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:
- A setting "Require authentication for local proxy". When it is on, the mixed inbound gets
userswith a random username/password, generated once per install and stored in the app database. - The app's own requests through the local port (subscription updates, update check, rule-set downloads via
HTTPClient.TrySocks5in libcore) pass these credentials. A sing-box SOCKS5 server withoutusersstill accepts a client that offers username/password, so the app can always send them, whatever the setting. - 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). - External plugins get the same credentials: mieru through
socks5Authenticationin the client config (mieru 3.4.0+), naive throughlisten: socks://user:[email protected]:port, and the sing-boxsocksoutbound to the plugin uses them. - Not covered: "Append HTTP proxy to VPN" (Android's
ProxyInfocannot carry credentials) and thedirectmapping 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.
This fix must not be optional. Security must never be optional.