Skip to content

Fix BCRYPT_PROVIDER_HANDLE access violation in CNG.pkg - #3

Merged
DataFlex-dev merged 1 commit into
DataFlex-dev:26-0-package-managerfrom
thomas-verkeste-dae:26-0-package-manager
Aug 7, 2026
Merged

DataFlex-dev merged 1 commit into
DataFlex-dev:26-0-package-managerfrom
thomas-verkeste-dae:26-0-package-manager

Conversation

@thomas-verkeste-dae

Copy link
Copy Markdown

BCryptDuplicateHash and BCryptDuplicateKey fetched BCRYPT_PROVIDER_HANDLE via BCryptNamedUIntegerPropertyValue, which only accepts 4-byte values. BCRYPT_PROVIDER_HANDLE is a native Handle, 8 bytes on x64, so the size check silently returned 0 and the next BCryptGetProperty call dereferenced a null handle.

Both call sites now fetch the handle via raw BCryptNamedPropertyValue and copy it in only when the returned size matches SizeOfType(Handle).

BCryptGetProperty's blanket 8-to-4 truncation is removed since it was corrupting the newly fetched 8-byte handle. The same tolerance is re-added scoped to BCryptNamedUIntegerPropertyValue, the one caller that legitimately wants 4 bytes. NCryptNamedUIntegerPropertyValue gets the same tolerance for symmetry, though it has no current callers.

BCryptDuplicateHash and BCryptDuplicateKey fetched BCRYPT_PROVIDER_HANDLE
via BCryptNamedUIntegerPropertyValue, which only accepts 4-byte values.
BCRYPT_PROVIDER_HANDLE is a native Handle, 8 bytes on x64, so the size
check silently returned 0 and the next BCryptGetProperty call
dereferenced a null handle.

Both call sites now fetch the handle via raw BCryptNamedPropertyValue
and copy it in only when the returned size matches SizeOfType(Handle).

BCryptGetProperty's blanket 8-to-4 truncation is removed since it was
corrupting the newly fetched 8-byte handle. The same tolerance is
re-added scoped to BCryptNamedUIntegerPropertyValue, the one caller
that legitimately wants 4 bytes. NCryptNamedUIntegerPropertyValue gets
the same tolerance for symmetry, though it has no current callers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants