Security: a view-only paired client can terminate the currently running app
Security: a view-only paired client can terminate the currently running app
launch() in src/nvhttp.cpp has a permission-downgrade check meant to exclude
terminate requests from being treated as a normal view-only join. The exclusion
doesn't cover every way a request reaches the terminate branch, so a client
paired with only view permission — the default for every device paired after
the first — can terminate the app another user is running.
Where
src/nvhttp.cpp, function launch(), the permission-downgrade block (around
line 1184 on current master):
if (current_appid > 0
&& (appuuid_str != TERMINATE_APP_UUID || appid != proc::terminate_app_id)
&& (is_input_only || appid == current_appid || (!appuuid_str.empty() && appuuid_str == current_app_uuid)))
perm = PERM::_allow_view;and the terminate branch further down (around line 1214):
if (!is_input_only) {
if ((config::input.enable_input_only_mode && appid == proc::terminate_app_id)
|| appuuid_str == TERMINATE_APP_UUID) {
proc::proc.terminate();
...
}
}There is no permission check between the downgrade and the terminate() call
other than the one at the top of launch(), which the downgrade already
bypassed.
Two ways to trigger it
A client with _default permission (view | list, what every paired device
gets except the first) can terminate the running app while current_appid > 0:
By UUID. Send
/launchwithappuuid=E16CBE1B-295D-4632-9A76-EC4180C857D3(TERMINATE_APP_UUID) andappidequal to the running app's id. The running app's id is available to any paired client from/serverinfo(root.currentgame), which has no permission check.The middle clause of the downgrade condition is only false when both
appuuid_str == TERMINATE_APP_UUIDandappid == proc::terminate_app_id.proc::terminate_app_idis-1unless Input Only Mode is on, so an ordinary running app's id never equals it — the clause is almost always true, and the request gets downgraded to_allow_viewinstead of being excluded. Aview-only client then passes the earlier!(cert->perm & perm)check, and falls into the terminate branch.By app id, with Input Only Mode on. Send
/launchwithappidequal to the Terminate entry's own app id (proc::terminate_app_id) andappuuidequal to the running app's uuid (not the terminate UUID). The third clause of the downgrade (appid == current_appidorappuuid_str == current_app_uuid) is satisfied by the uuid match, so the request is downgraded, and the terminate branch's other trigger (enable_input_only_mode && appid == terminate_app_id) fires.
Minimal repro (case 1)
Using the client certificate of a device paired with default (view-only)
permission, while an app is running:
GET https://<host>:47984/launch?appid=<root.currentgame from /serverinfo>&appuuid=E16CBE1B-295D-4632-9A76-EC4180C857D3&rikey=00&rikeyid=0&localAudioPlayMode=0Expected: HTTP 200, XML root status_code=410, "App terminated.", and the
running app is killed. No permission error, even though this client has no
launch permission.
Suggested fix
Compute a single predicate for "this is a terminate request" that covers both
triggers, and use it in both places: to exclude the downgrade, and to gate
the terminate branch. That way the two checks can't drift apart again, and
terminating always requires PERM::launch, matching how /cancel already
checks PERM::launch elsewhere in the same file.
Scope
Verified by reading the code and hand-tracing every branch; not yet verified
by running a live server (no existing test harness covers launch()). Checked
against master, current as of this report. The logic is unchanged from
23dd06b3 / 1798887e, so this isn't new.
A client holding real launch permission is unaffected either way, since it
already passes the check regardless of the downgrade.
Source: ClassicOldSong/Apollo