Hello @Roman Prudchenko ,
I have carefully reviewed the scenario you described, and I would like to share some perspectives and relevant documentation to help us analyze this issue together. Based on the current Windows system architecture, I would like to offer some suggestions and observations regarding your questions:
1 & 2. Scope of KeyCredentialManager and Cross-process behavior
According to the architectural documentation for the pure (unpackaged) Win32 environment, it appears that the security boundary is generally established at the User Account level rather than the application level. In this traditional environment, processes running under the same user typically share a common privilege space. Therefore, the fact that another process can request to open a KeyCredential if it knows the credential name is likely an anticipated behavior, as the operating system might not differentiate between two Win32 processes belonging to the same user.
- Reference: Windows Access Control Model
3 & 4. App Isolation, AppContainer, and MSIX
To establish isolation at the application level, Microsoft often suggests granting the application an App Identity. If your application is not running within an AppContainer, it may struggle to protect itself from other same-user processes. If you utilize packaging such as MSIX or adopt the new Win32 App Isolation mechanisms, I believe this behavior might change. In those cases, the system seems to evaluate access rights based on the Package Family Name (PFN), which helps keep credentials isolated per application rather than shared entirely at the user level.
- References: AppContainer Isolation and MSIX App Identity
5. Binding to an executable or package identity
In case you want to "bind" the credential to a specific application, identifying it via package identity (e.g., through MSIX) seems to be the most frequently mentioned solution in the documentation. For standalone, unpackaged .exe files, there is probably no standard mechanism supported by the OS to tightly bind this API solely to that specific executable.
6. Secrecy of the Credential Name
Microsoft's documentation might not explicitly state that the credential name must be an absolute secret. Even though malware could potentially discover it, relying on hiding this name (security through obscurity) perhaps shouldn't be your core defense layer. Nevertheless, generating a random name could be considered a mitigating measure to reduce the attack surface.
7. TPM and Key Attestation
The presence of a TPM chip and key attestation is typically intended to ensure that the key material cannot be extracted or exported off the physical device. However, it might not resolve the "Confused Deputy" problem at the software level. This means that if a valid cryptographic request is sent by malicious code running under the same user privileges, the TPM would likely still process the operation because it cannot distinguish process boundaries in an environment without an AppContainer.
- Reference: TPM Fundamentals
8. Advice on Defense-in-depth architecture
For applications protecting high-value local secrets (like a password vault), I think relying solely on a single layer of protection (Windows Hello in an unpackaged Win32 environment) could carry potential risks if the device is compromised by same-user malware. A safer approach would perhaps be adopting a "Defense in depth" model. You might consider using Windows Hello as a convenient unlock method while combining it with boundaries like MSIX packaging, or requiring a master password periodically to mitigate risks.
- Reference: KeyCredentialManager Class
I hope the information and documents above can provide additional perspectives for your architectural evaluation. If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation.
Thank you.