Hi @Agnel Vanjare ,
Thank you for preserving the keys and for the detailed write-up. I reproduced this on a test machine, and the DACL is the cause: when NCryptOpenKey reopens the key, LSASS opens the backing file requesting 0x120089 (FILE_GENERIC_READ) under the caller's identity, and your DACL grants only READ_CONTROL from that mask. Granting FR to the publisher let it open and sign, while changing the descriptor and deleting the key were still denied.
Creation and finalization succeed because, as the NCryptOpenKey remarks explain, Microsoft software-based KSPs cache private key material in LSA for as long as a handle to the key is open. After NCryptFreeObject, the reopen has to read the file again, and on my build the denied read was reported as NTE_BAD_KEYSET.
I tested on Windows 11 Pro build 26300.9457 with an ECDSA P-256 machine key set up like yours (Export Policy 0, signing usage, protected DACL owned by Administrators), reopening from a new process with NCRYPT_MACHINE_KEY_FLAG | NCRYPT_SILENT_FLAG and using a standard local user as the publisher. These are the five cases I ran:
- Your DACL,
O:BAD:P(A;;0xE0000;;;BA)(A;;0x20000;;;<publisher-SID>): reopen returned0x80090016for both the admin and the publisher. - Your DACL plus
FRfor Administrators, no SYSTEM ACE: the admin reopened and signed successfully. -
FRfor SYSTEM only, Administrators keeping0xE0000: the admin still got0x80090016. -
O:BAD:P(A;;FA;;;SY)(A;;FA;;;BA)(A;;FR;;;<publisher-SID>): the publisher opened and signed, got NTE_PERM (0x80090010) fromNCryptSetPropertywithNCRYPT_SECURITY_DESCR_PROPERTY, and E_ACCESSDENIED (0x80070005) fromNCryptDeleteKey, with the backing file still present afterwards. - The same layout without the SYSTEM ACE: identical results to case 4.
On the security context, cases 2 and 3 show that the caller needs read access and that read access for SYSTEM alone is not enough. Each failed reopen also produced a failed Event 4656 with Process Name lsass.exe, the calling account as Subject (the admin in one run, the publisher in the other), Access Mask 0x120089, and Access Reasons showing READ_CONTROL and ReadAttributes granted but ReadData, ReadEA and SYNCHRONIZE not granted. So for this file open path, the access check runs under the caller's security context through LSASS. I would not extend that to every internal check the KSP performs.
As for the access model, the public CNG documentation does not define a separate sign-only right for Microsoft Software KSP keys. What I can show is that FR on the key is sufficient for open and sign, and that with Administrators as owner and no WRITE_DAC, WRITE_OWNER or DELETE for the publisher, the descriptor change and the delete were both refused. I did not try every bit combination, so FR is a working value rather than a proven minimum. The KSP also reported FR and FA back as 0x80120089 and 0xD01F01FF, while the file DACL showed plain FR and FA, so it is worth checking the descriptor and the file separately when you verify. Local administrators remain inside the trust boundary, since the same NCryptOpenKey remarks note that they can access the LSA-cached copy of the key. For your preserved keys, Administrators already hold WRITE_DAC in the current DACL, so adding FR for the publisher on one of them should let you confirm the same result on your machine while keeping the other untouched as evidence.
For diagnosis, the 4656 events only appeared on my build once Handle Manipulation was enabled together with File System failure auditing, which matches Advanced Audit Policy Configuration listing 4656 under Handle Manipulation. I used System Integrity for 5061 and Other System Events for 5058, and placed the SACL on a fresh test key with your DACL. To audit one of your preserved keys without touching its descriptor, a global file SACL through auditpol resourceSACL is stored in policy instead, although I did not run that variant myself.
One more observation: the failed reopen did not produce a 5058 "Read persisted key from file" record. I only saw that operation on successful opens, so a missing 5058 does not rule out a denied read.
Everything above is based on the public documentation and on what I could reproduce from the details in your question, on one machine and one build, so it describes observed behavior rather than a documented contract. This is as far as I can take it from the forum side. If you need Microsoft to confirm the access model for a production design, Windows Developer Support is the right channel, and the 4656 record with mask 0x120089 would be the most useful item to bring.
I hope the test results and the documentation help you move forward with the publisher design. If this answer resolves your question, please consider this guidance when convenient, as it can help others with a similar question find it more easily.
Thank you.