GetAppContainerRegistryLocation does not provide a documented, profile-specific, non-mutating discovery contract, so the suspended-process technique should not be used as a security invariant for locating or pre-locking a named AppContainer’s private registry.
Supportability of the proposed sequence
The individual mechanics are documented:
- Creating the process with
CREATE_SUSPENDEDprevents its primary thread from beginning execution untilResumeThreadis called. Terminating it without resuming therefore prevents the application entry point from running.^1^ -
OpenProcessTokencan retrieve the suspended process’s primary token. -
ImpersonateLoggedOnUseraccepts either a primary or impersonation token. For a primary token, the handle requiresTOKEN_QUERY | TOKEN_DUPLICATE; the call must succeed before proceeding. Impersonation also requires an eligible caller relationship/privilege, and an impersonation level ofSecurityImpersonationor higher.^2^ - Alternatively,
DuplicateTokencan create an impersonation token andSetThreadTokencan assign it to the calling thread.^3^
However, the documented contract for GetAppContainerRegistryLocation only says that it returns the registry storage for the current profile, gets storage for the current user, and requires user impersonation when accessing another user’s storage. It has no profile-name, Package SID, token, or process parameter.^4^
Consequently, the documentation does not establish that:
- impersonating a suspended AppContainer token selects that token’s Package SID as the target profile;
- the returned key is authoritatively associated with the particular named profile whose SID you verified;
- this technique is a supported lookup mechanism for arbitrary AppContainer profiles.
Impersonation changes the security context used for access checks; it does not, by itself, supply the missing documented profile-selection parameter.
Read-only access and mutation
Passing KEY_READ requests a handle containing query, enumeration, notification, and standard read rights. It excludes KEY_SET_VALUE and KEY_CREATE_SUB_KEY, so operations performed through the returned handle cannot set values or create subkeys.^5^
A suitable minimal call would be:
HKEY key = nullptr;
HRESULT hr = GetAppContainerRegistryLocation(KEY_READ, &key);
if (SUCCEEDED(hr)) {
// Query or enumerate only.
RegCloseKey(key);
} else {
// Abort; do not continue under the broker's original context.
}
RevertToSelf();
That limits the returned handle’s rights, but the API reference does not promise that the call is observationally pure, does not initialize backing storage, or never causes profile-related state to be materialized. CreateAppContainerProfile explicitly creates the per-user application data store; successful creation returns S_OK, while an existing store returns ERROR_ALREADY_EXISTS.^6^ Once the profile has already been created, no stronger “zero mutation” guarantee for the registry-location call is documented.
Lookup by profile name or SID
There is a documented name-to-SID operation:
PSID sid = nullptr;
HRESULT hr =
DeriveAppContainerSidFromAppContainerName(profileName, &sid);
if (SUCCEEDED(hr)) {
// Use SID for identity comparison or ACL construction.
FreeSid(sid);
}
DeriveAppContainerSidFromAppContainerName derives the SID for a profile name, but it does not return or open the private registry and its documented errors do not provide profile-storage existence semantics.^7^
No supplied public API documents a profile-name/SID-to-private-registry operation. Therefore, there is no supported direct equivalent of:
OpenAppContainerRegistry(profileName-or-SID, KEY_READ)
Undocumented hive paths should not be used to fill that gap.
Making the private registry read-only
Windows registry keys generally support DACL-based control, and RegSetKeySecurity can change a key’s security descriptor when the caller has the required rights.^5^ AppContainer access is normally the intersection of permissions granted to the user/group identities and the Package or capability SIDs.^8^
Those general mechanisms do not document a supported procedure for replacing the ACL of an AppContainer’s managed private-registry root before launch while preserving correct profile behavior. AppContainer virtualization is designed to give the application its own writable virtual registry and application-data area.^9^ Treating that managed store as broker-owned ACL policy could interfere with virtualization and profile lifecycle behavior.
Use ACLs on resources owned by the broker—such as the verification workspace—and grant the Package SID read-only access there. Do not depend on rewriting the private hive’s ACL as a supported AppContainer configuration feature. A Job Object also does not provide registry ACL policy; modern Windows requires process security restrictions to be set per process.^10^
An LPAC can reduce access to common registry resources and requires the registryRead capability for registry access, but that is not documented as a mechanism that converts its own private registry into a read-only store.^8^
Stronger supported isolation
For strict non-persistence and stronger host separation, use Windows Sandbox or a dedicated Hyper-V VM rather than relying on private-hive behavior.
Windows Sandbox is available on supported Windows 11 Pro editions and uses hypervisor-based isolation with a separate kernel; its state is discarded when the sandbox closes.^11^ A .wsb configuration can disable networking and expose only a read-only host workspace:
<Configuration>
<Networking>Disable</Networking>
<ClipboardRedirection>Disable</ClipboardRedirection>
<MappedFolders>
<MappedFolder>
<HostFolder>C:\VerificationInput</HostFolder>
<SandboxFolder>C:\Input</SandboxFolder>
<ReadOnly>true</ReadOnly>
</MappedFolder>
</MappedFolders>
</Configuration>
ReadOnly=true enforces read-only access to that mapped host folder, while networking can be explicitly disabled.^12^ If the verifier needs persistent tooling, automation, multiple concurrent instances, or tighter device controls, use a dedicated Hyper-V VM; the VM boundary provides hardware-level isolation and its own kernel.^13^
References
- Process Creation Flags
- ImpersonateLoggedOnUser function (securitybaseapi.h)
- DuplicateToken function (securitybaseapi.h)
- GetAppContainerRegistryLocation function (userenv.h)
- Registry Key Security and Access Rights
- CreateAppContainerProfile function (userenv.h)
- DeriveAppContainerSidFromAppContainerName function (userenv.h)
- Launch an AppContainer
- AppContainer for legacy apps
- Job Object Security and Access Rights
- Windows Sandbox
- Use and configure Windows Sandbox
- Isolation Modes