Replies: 3 comments 5 replies
-
Hey Dexter! Could you provide more details on how the RPC server security is implemented? Are you using a custom SD on the endpoint itself, or are you performing some other runtime validation manually, with something like ::CheckTokenCapability ? If you are using a custom SD on the endpoint, can you provide the full security descriptor in string form? |
Beta Was this translation helpful? Give feedback.
-
we are using |
Beta Was this translation helpful? Give feedback.
-
here's the code for permission check. static __int64 inline PermissionCheck()
{
// impersonate the client
__int64 ulCode = RpcImpersonateClient(NULL);
if (ulCode != RPC_S_OK)
return ulCode;
__int64 i64Result = ERROR_ACCESS_DENIED;
HANDLE hToken = NULL;
if (!OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, FALSE, &hToken))
{
i64Result = GetLastError();
TraceEvents(TRACE_LEVEL_ERROR, TRACE_HPD, "OpenThreadToken failed, GLE=%I64d", i64Result);
goto end;
}
PTOKEN_GROUPS pTokenCapabilities = NULL;
DWORD dwSize = 0;
if (!GetTokenInformation(hToken, TokenCapabilities, NULL, dwSize, &dwSize) && GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{
pTokenCapabilities = (PTOKEN_GROUPS)GlobalAlloc(GPTR, dwSize);
// Call GetTokenInformation again to get the group information.
if (pTokenCapabilities != NULL)
{
if (GetTokenInformation(hToken, TokenCapabilities, pTokenCapabilities,
dwSize, &dwSize))
{
for (DWORD i = 0; i < pTokenCapabilities->GroupCount; i++)
{
if (EqualSid(pTokenCapabilities->Groups[i].Sid, g_capabilitySids[0]) && pTokenCapabilities->Groups[i].Attributes & SE_GROUP_ENABLED)
{
i64Result = S_OK;
goto end;
}
}
}
else
{
i64Result = GetLastError();
}
GlobalFree(pTokenCapabilities);
}
else
{
i64Result = ERROR_OUTOFMEMORY;
}
}
else
{
i64Result = GetLastError();
}
end:
if (hToken != NULL)
{
CloseHandle(hToken);
}
return i64Result;
} g_capabilitySids is created via the following code // Get the SID form of the custom capability. In this case we only expect one SID and
// we don't care about the capability group.
if (!DeriveCapabilitySidsFromName(
L"DolbyLabs.dolbyDAX3ApiService_rz1tebttyb220",
&g_capabilityGroupSids,
&g_capabilityGroupSidCount,
&g_capabilitySids,
&g_capabilitySidCount))
{
hResult = GetLastError();
goto end;
} basically what they do is impersonate as the client, and then try to retrieve the Thread token and check if there's the security token of that custom capability. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
is it possible for a packaged win32 app process to retain the custom capability declared in the package manifest?
I have this UWP app migrating to Packaged Win32 app with WindowsAppSDK, however there's a security check in the RPC server that will validate the custom capability token, if we cannot get the custom capability to work we might have to roll back to UWP...(oh! god! please don‘t!)
Beta Was this translation helpful? Give feedback.
All reactions