Microsoft Software KSP: generic access-right mapping for persisted CNG keys and export-policy changes after finalization

Marco Silveira 0 Reputation points
2026-11-19T02:51:53.23+00:00

We are qualifying a Windows service in an isolated laboratory and need clarification about the documented security contract of the Microsoft Software Key Storage Provider.

Configuration and required policy

  • Persisted, machine-scoped ECDSA P-256 key.
  • KeyUsage = Signing.
  • ExportPolicy = None.
  • Service running as LocalService with a restricted, service-specific SID.
  • SYSTEM provisions and recovers the key.

The service must be able to open the key, read necessary public metadata and security information, and sign challenges. It must not be able to export private key material, delete the key, change its owner or DACL, or broaden its export policy.

The requested security descriptor is schematically:

O:SYG:SYD:P(A;;GA;;;SY)(A;;GR;;;<SERVICE_SID>)

<SERVICE_SID> is a placeholder for the actual service-specific SID.

Reading back NCRYPT_SECURITY_DESCR_PROPERTY produces:

Trustee Requested access mask Observed access mask
SYSTEM 0x10000000 — GENERIC_ALL 0xD01F01FF
-------- -------- --------
SYSTEM 0x10000000 — GENERIC_ALL 0xD01F01FF
Service-specific SID 0x80000000 — GENERIC_READ 0x80120089

The owner and primary group remain SYSTEM. The DACL remains protected and contains exactly two access-allowed ACEs, in the expected order, with no inheritance or additional trustees.

An independent reference experiment reproduced this representation. However, reproducibility alone does not establish the meaning of the resulting rights or their equivalence to our required policy.

We do not want to apply a file-object GENERIC_MAPPING, or interpret these masks as FILE_GENERIC_READ or FILE_ALL_ACCESS, merely because some bits resemble file access masks.

Observed behavior

The authorized restricted LocalService process successfully opened the key and signed a challenge. The signature was independently verified.

Attempts to change the DACL, change the owner, and delete the disposable key were explicitly refused.

Private-key export attempts returned NTE_NOT_SUPPORTED (0x80090029). The export policy remained None. We have retained the distinction between an unsupported operation and an explicit access-control refusal; we do not classify this error automatically as “access denied.”

Export-policy test limitation

A separate test called NCryptSetProperty on a reopened, finalized key handle, setting NCRYPT_EXPORT_POLICY_PROPERTY to NCRYPT_ALLOW_ARCHIVING_FLAG (0x00000004). It returned NTE_BAD_KEY_STATE (0x8009000B), and the policy remained unchanged.

The Key Storage Property Identifiers documentation limits this archiving policy to the original key handle. Therefore, we do not regard that result as proof of an ACL-based refusal.

Questions

Provider-specific mapping: Where is the Microsoft Software KSP’s mapping from GENERIC_ALL and GENERIC_READ to effective key access rights documented? Are the observed masks above a supported normalization of the requested descriptor, and which Windows/provider versions does that behavior cover?

Operation-specific authorization: Which rights govern opening a persisted key, reading its properties or security descriptor, signing, deleting the key, changing its owner/DACL, and changing its export policy? In particular, does the observed service mask grant any operation prohibited by our policy?

Descriptor validation: What supported method should an application use to validate the effective policy after readback, without requiring binary equality with generic ACE masks and without inventing an object-specific GENERIC_MAPPING?

Export-policy mutability: For a persisted ECDSA P-256 key finalized with export policy zero, can a reopened handle validly enable NCRYPT_ALLOW_EXPORT_FLAG or NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG? If so, what lifecycle conditions, flags and access rights govern that operation? If not, where is the applicable immutability guarantee documented?

Valid negative test: Is there a documented, valid export-policy modification on a reopened key that can test the service’s lack of authorization, independently of invalid key-state restrictions? If no such operation exists, what documented guarantee should replace that test?

We would appreciate authoritative documentation or clarification from the relevant Windows/CNG team. Until these points are established, our validator continues to reject the unqualified descriptor representation.We are qualifying a Windows service in an isolated laboratory and need clarification about the documented security contract of the Microsoft Software Key Storage Provider.

Configuration and required policy

  • Persisted, machine-scoped ECDSA P-256 key.
  • KeyUsage = Signing.
  • ExportPolicy = None.
  • Service running as LocalService with a restricted, service-specific SID.
  • SYSTEM provisions and recovers the key.

The service must be able to open the key, read necessary public metadata and security information, and sign challenges. It must not be able to export private key material, delete the key, change its owner or DACL, or broaden its export policy.

The requested security descriptor is schematically:

O:SYG:SYD:P(A;;GA;;;SY)(A;;GR;;;<SERVICE_SID>)

<SERVICE_SID> is a placeholder for the actual service-specific SID.

Reading back NCRYPT_SECURITY_DESCR_PROPERTY produces:

Trustee Requested access mask Observed access mask
SYSTEM 0x10000000 — GENERIC_ALL 0xD01F01FF
Service-specific SID 0x80000000 — GENERIC_READ 0x80120089

The owner and primary group remain SYSTEM. The DACL remains protected and contains exactly two access-allowed ACEs, in the expected order, with no inheritance or additional trustees.

An independent reference experiment reproduced this representation. However, reproducibility alone does not establish the meaning of the resulting rights or their equivalence to our required policy.

We do not want to apply a file-object GENERIC_MAPPING, or interpret these masks as FILE_GENERIC_READ or FILE_ALL_ACCESS, merely because some bits resemble file access masks.

Observed behavior

The authorized restricted LocalService process successfully opened the key and signed a challenge. The signature was independently verified.

Attempts to change the DACL, change the owner, and delete the disposable key were explicitly refused.

Private-key export attempts returned NTE_NOT_SUPPORTED (0x80090029). The export policy remained None. We have retained the distinction between an unsupported operation and an explicit access-control refusal; we do not classify this error automatically as “access denied.”

Export-policy test limitation

A separate test called NCryptSetProperty on a reopened, finalized key handle, setting NCRYPT_EXPORT_POLICY_PROPERTY to NCRYPT_ALLOW_ARCHIVING_FLAG (0x00000004). It returned NTE_BAD_KEY_STATE (0x8009000B), and the policy remained unchanged.

The Key Storage Property Identifiers documentation limits this archiving policy to the original key handle. Therefore, we do not regard that result as proof of an ACL-based refusal.

Questions

Provider-specific mapping: Where is the Microsoft Software KSP’s mapping from GENERIC_ALL and GENERIC_READ to effective key access rights documented? Are the observed masks above a supported normalization of the requested descriptor, and which Windows/provider versions does that behavior cover?

Operation-specific authorization: Which rights govern opening a persisted key, reading its properties or security descriptor, signing, deleting the key, changing its owner/DACL, and changing its export policy? In particular, does the observed service mask grant any operation prohibited by our policy?

Descriptor validation: What supported method should an application use to validate the effective policy after readback, without requiring binary equality with generic ACE masks and without inventing an object-specific GENERIC_MAPPING?

Export-policy mutability: For a persisted ECDSA P-256 key finalized with export policy zero, can a reopened handle validly enable NCRYPT_ALLOW_EXPORT_FLAG or NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG? If so, what lifecycle conditions, flags and access rights govern that operation? If not, where is the applicable immutability guarantee documented?

Valid negative test: Is there a documented, valid export-policy modification on a reopened key that can test the service’s lack of authorization, independently of invalid key-state restrictions? If no such operation exists, what documented guarantee should replace that test?

We would appreciate authoritative documentation or clarification from the relevant Windows/CNG team. Until these points are established, our validator continues to reject the unqualified descriptor representation.

Windows development | Windows API - Win32
0 comments No comments

1 answer

Sort by: Newest
  1. Gatlin Le (WICLOUD CORPORATION) 1,495 Reputation points Microsoft External Staff Moderator
    2026-11-19T04:35:24.41+00:00

    Hi Marco Silveira,

    I was able to reproduce the behavior you described, and the public Microsoft documentation does not define a Microsoft Software KSP generic mapping or a per-operation access contract for persisted keys. The points that need an authoritative guarantee therefore have to come from the Windows/CNG team. The way you separated descriptor representation, operational evidence, and documented contract is exactly the right boundary here, and it made the reproduction much easier to scope.

    I reproduced the same behavior on Windows 11 Pro 26H2, build 26300.9457, using a persisted machine-scoped ECDSA_P256 key with the same descriptor applied before NCryptFinalizeKey, and running the operation tests in a real LocalService service with a restricted service SID. The readback returned 0xD01F01FF for SYSTEM and 0x80120089 for the service SID, with the protected DACL unchanged. Open and sign succeeded, DACL and owner changes returned NTE_PERM (0x80090010), delete returned E_ACCESSDENIED (0x80070005), and private export with BCRYPT_ECCPRIVATE_BLOB returned NTE_NOT_SUPPORTED (0x80090029). Setting NCRYPT_ALLOW_ARCHIVING_FLAG on a reopened key as SYSTEM returned NTE_BAD_KEY_STATE (0x8009000B), and the policy stayed 0. This is my observed behavior, not a provider contract.

    On the provider-specific mapping, Generic Access Rights explains that each type of securable object maps the generic bits to its own standard and object-specific rights, while Key Storage Property Identifiers only describes NCRYPT_SECURITY_DESCR_PROPERTY as a security descriptor that contains access control information for a persistent key. I could not find a published Software KSP GENERIC_MAPPING, a statement that the readback masks are a supported normalization, or any Windows/provider version coverage for that behavior. Your decision not to borrow the file-object mapping is consistent with what the documentation actually says.

    As for operation-specific authorization, NCryptSetProperty documents the OWNER_SECURITY_INFORMATION and DACL_SECURITY_INFORMATION selectors but not the rights the provider checks for them, and no NCrypt reference I reviewed maps open, property or descriptor read, sign, delete, or export-policy change to specific access bits. At the bit level, ACCESS_MASK shows that 0x80120089 contains GENERIC_READ, SYNCHRONIZE, READ_CONTROL, and the object-specific value 0x89, and that it does not contain DELETE, WRITE_DAC, or WRITE_OWNER. The same page states that bits 0 to 15 depend on the object type, so 0x89 has no documented meaning for KSP keys, and the GENERIC_READ bit remains unexpanded. The observation and the refusals above are consistent with your policy, but they do not prove that the mask grants nothing your policy prohibits. Export is also governed by the documented export policy flags, which are a key property rather than an ACE right.

    For descriptor validation, AccessCheck requires the GENERIC_MAPPING associated with the object and a desired access mask already mapped through MapGenericMask, so without a published mapping there is no documented read-only way to evaluate effective access for a Software KSP key. The most defensible approach available today is structural conformance on readback (owner, group, DACL protection, ACE types, trustees, and the raw masks recorded per Windows build) combined with operational negative tests, reported as observations rather than as a contract.

    On export-policy mutability, the property page states that the archiving flags apply only to the original key handle, which matches your 0x8009000B result. For NCRYPT_ALLOW_EXPORT_FLAG and NCRYPT_ALLOW_PLAINTEXT_EXPORT_FLAG, the page does not say whether they can be enabled on a reopened finalized key, and it does not document an immutability guarantee either. The page explicitly marks NCRYPT_UI_POLICY_PROPERTY as read-only after finalization but makes no equivalent statement for export policy. I did not test those two flags, so I cannot confirm the behavior. I also could not find a documented, valid export-policy modification on a reopened key that would serve as your negative test, or a documented guarantee that could replace it.

    This is what I was able to observe, find in the documentation, and test on my side for your scenario. If you need a more thorough confirmation of the mapping, version coverage, and export-policy guarantees, you can open a case through Windows Developer Support and choose the option that best fits your setup. Including your SDDL, the readback masks, the Windows builds you qualify, and the status codes above should help the team address each point directly.

    I can see how much care went into scoping this question, and it is a reasonable expectation to want a documented guarantee before relying on a security-sensitive key policy. I hope the test results and references above help clarify at least part of the picture and make it easier to frame the remaining points if you decide to open a case. If you feel the information has helped you move forward, you are welcome to follow this guidance when convenient, as it can help others with the same question find it more easily. You are also always welcome to add any confirmation you receive here.

    Thank you.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.