Skip to content

Add per-app access control for remote automation - #6206

Open
eliotcougar wants to merge 14 commits into
2dust:masterfrom
eliotcougar:codex/remote-control-access
Open

eliotcougar wants to merge 14 commits into
2dust:masterfrom
eliotcougar:codex/remote-control-access

Conversation

@eliotcougar

@eliotcougar eliotcougar commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem and motivation

The exported Locale/Tasker receiver accepts start/stop commands from other installed apps without authorization. An unrelated app can stop the user's VPN without sharing v2rayNG's signing key. External shared text and install links can also silently replace profiles in the default group and change selection (#6231).

I have received a confidential report that two government-affiliated apps in Russia already detect v2rayNG and send its stop command, disabling the user's VPN. The source cannot be disclosed. The independent reproduction verifies the exposed control mechanism, not the app-specific attribution.

Leaving this channel open makes it easy for more domestic apps to follow suit as they face government demands to restrict VPN users. RBC reported that the Ministry of Digital Development instructed major platforms to restrict access for users with active VPNs, with April 15, 2026 as the target date. This provides public context for the risk of wider adoption; it does not establish the reported stop-command behavior.

Changes

  • Add Settings → Advanced → Automation app access, using the existing app picker. Access is denied by default, independent of per-app proxy routing, and saved when leaving the picker. Unchanged selections avoid redundant lookups and writes.
  • Bind grants to signing certificates and installation time. Store grants and random per-app capabilities in one device-local MMKV record under noBackupFilesDir, using process-local and cross-process locking. Control commands and imports share this grant store.
  • Authenticate commands with Android's platform sender UID when shared on API 34+, otherwise require the saved per-app capability. A known platform UID takes precedence over supplied credentials; a claimed package name or referrer never proves identity.
  • Check the Tasker editor's getCallingPackage() before loading profiles and again before returning a capability. Preserve selection/start state across recreation and validate commands and explicit profile GUIDs before dispatch.
  • Keep app-internal command receivers private and dispatch through LauncherManager. Immutable launcher PendingIntents continue working without an automation grant. Broadcast actions use the installed application's ID, including the F-Droid suffix.
  • Apply the same grants to configuration imports. Authenticated automation retains unattended replacement; other callers must confirm before import or subscription download, and confirmed one-off imports append. Cancelling changes nothing and does not create a grant.
  • Keep import confirmation/work in a ViewModel, prevent duplicate submission, decode only the outer URL wrapper, and remove incoming-configuration logging. Import identity uses the platform launcher UID or saved capability, not getCallingPackage(), which can identify a forwarded result recipient.
  • Preserve the picker and Tasker rows' accessible interaction semantics and update all maintained locale catalogs. Protocol details are in docs/remote-control.md.

Compatibility

Public integration entry points stay exported for independently signed automation hosts. Users must allow a host, then reopen and save existing plugin actions to receive a capability. Legacy anonymous Send Intent broadcasts are rejected. Import clients without shared platform identity can supply the saved capability bundle; other imports take the confirmation-and-append path.

Revocation invalidates capabilities for control and imports; regranting creates a new token. Exporting a task containing the capability delegates that access, so hosts must keep it secret. Android VPN consent, background-execution restrictions, and the selected operating mode still apply.

Current validation

Validation on 95d5ec215746cb205e1b52d87baedc4a3b4362bb, which merges upstream 57907cf354d9769200ed4717b4430d605abe0952 (2.3.15) without rewriting history. Reviewed the configuration/format, subscription-info, native, OkHttp, and workflow delta together with caller authorization, flavor IDs, and daemon ownership. Upstream configuration fields and request/cancellation lifecycle code are retained.

  • Focused authorization, Tasker request/editor, import parser/ViewModel, and picker checks: 36 tests passed, no failures, errors, or skips.
  • Full Play Store and F-Droid JVM suites: 159 tests passed in each flavor, no failures, errors, or skips. Both Kotlin compilation and ARM64 debug assembly passed.
  • Full :app:lintPlaystoreDebug and :app:lintFdroidDebug passed with zero errors (329 and 345 warnings respectively). git diff --check passed.
  • All 110 main XML files parse; all seven feature keys are present in the default catalog and nine maintained translations.
  • Native inputs are official AndroidLibXrayLite v26.10.31 and HEV 2.19.3. Checked the AAR SHA-256, its four ABI runtimes, and all eight HEV input binaries against verified references. Both ARM64 APKs contain libgojni.so, libhev-socks5-tunnel.so, and libhevsockstun.so.
  • Merged manifests confirm the correct Play Store/F-Droid application IDs and internal broadcast actions, the private widget receiver, and the exported Tasker receiver in the daemon process.

Not run: fresh device/emulator grant/revoke, caller-UID/capability, import confirmation, recreation/forwarded-result, legacy-signature, service-mode, keyboard/D-pad/TalkBack, or physical-device checks. No device target was available for this sync. Actual Tasker/Locale/MacroDroid interoperability, real network subscription updates, root-mode end-to-end, signer replacement/reinstallation, and process-death scenarios also remain unrun. Earlier API 33/API 37 protocol-compatible-host results are historical and were not repeated on this merged revision.

Fixes #6231 Silent configuration import.

@eliotcougar
eliotcougar marked this pull request as ready for review September 7, 2026 15:01
@2dust

2dust commented Sep 11, 2026

Copy link
Copy Markdown
Owner

非常感谢
虽然是为了安全性考虑,但是这样也造成了人为的限制,这不是我们想要的。
本来用自动化的用户已经非常少了,如果加了此功能,会导致不了解的用户无法使用

@eliotcougar

Copy link
Copy Markdown
Contributor Author

非常感谢 虽然是为了安全性考虑,但是这样也造成了人为的限制,这不是我们想要的。 本来用自动化的用户已经非常少了,如果加了此功能,会导致不了解的用户无法使用

It's exactly backwards. The feature that is used by a small number of people makes everybody else vulnerable.

It is extremely uncomfortable when an unrelated domestic app can have an update any moment that will make it possible to disable your VPN whenever it wants. And it already happens.

Existing users who need automation will only have to check what automation apps can access v2rayNG.

We can also try to preselect the most popular known automation apps to make the update more seamless.

Resolve shared-resource conflicts without dropping feature-specific semantics or current upstream translations. Retain upstream service and UI updates, and migrate feature regression tests to the upstream JUnit Platform setup.

Validation: PlaystoreDebug JVM suite, Kotlin compilation and APK assembly passed. All declared ABIs contain the current Xray library and both HEV libraries. Full device and OEM lifecycle regression coverage was not run.
Integrate upstream/master 01b4630, retaining subscription response-header
usage metadata, the subscription information card, pill group navigation,
current Kotlin/Gradle versions, and upstream native dependency gitlinks.

Preserve identity-bound automation grants, authenticated Tasker and external
import requests, append-only user-confirmed imports, and private internal
broadcast receivers. Supply all seven feature strings in the newly maintained
Azerbaijani catalog so access controls and import confirmation remain localized.
VPN, proxy-only, and root start dispatch continue through LauncherManager.

Validation: all 148 Play Store debug JVM tests passed, including automation
policy, Tasker, URL import, and subscription metadata regressions. Kotlin
compilation and x86_64 debug assembly passed; all three required packaged
native libraries hash-match the official upstream inputs. Locale XML,
feature-key coverage, placeholders, whitespace, and instruction-file gates
passed.
Not run: Android caller-identity, permission, Tasker host, external-import UI,
widget/tile, and VPN/proxy-only/root runtime scenarios; VM/adb use was excluded.
Preserve per-app automation grants and daemon-only command handling while adopting upstream configuration, format, and native dependency updates.
@jimmand

jimmand commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

Existing users who need automation will only have to check what automation apps can access v2rayNG.

To add to that, if someone’s already gone to the trouble of setting up automation, I doubt they’ll have much trouble poking around in Settings and giving their automation app access.

本来用自动化的用户已经非常少了,如果加了此功能,会导致不了解的用户无法使用

That’s what release notes are for. You can put BREAKING CHANGES in HUGE, SCARY LETTERS.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Security: requesting a private disclosure channel (exported component allows silent config hijack)

3 participants