Skip to content

Fix unmanaged resource leak in NTLM RC4 key generation#1989

Closed
rustamque wants to merge 1 commit intojstedfast:masterfrom
rustamque:ntlm-csp-handles-leak-fix
Closed

Fix unmanaged resource leak in NTLM RC4 key generation#1989
rustamque wants to merge 1 commit intojstedfast:masterfrom
rustamque:ntlm-csp-handles-leak-fix

Conversation

@rustamque
Copy link
Copy Markdown

RandomNumberGenerator.Create() allocates unmanaged cryptographic resources (e.g., CSP handles on Windows) in RC4.GenerateKey(), but Dispose() is not explicitly called.

In high-throughput scenarios or cyclic calls, this can lead to resource exhaustion before the Garbage Collector has a chance to run the finalizers.

Wrapped the RandomNumberGenerator.Create() instantiation in a using block to ensure deterministic disposal of the cryptographic resources.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

jstedfast added a commit that referenced this pull request Mar 16, 2026
@jstedfast
Copy link
Copy Markdown
Owner

Thanks

@jstedfast jstedfast closed this Mar 16, 2026
@jstedfast jstedfast added the bug Something isn't working label Mar 16, 2026
jstedfast added a commit that referenced this pull request Mar 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants