Skip to content

🔒 Security: Windows authentication with swallowed exceptions and unmanaged resource leak#92

Open
halinhtvn3a wants to merge 1 commit intoAlachisoft:masterfrom
halinhtvn3a:contribai/fix/security/windows-authentication-with-swallowed-ex
Open

🔒 Security: Windows authentication with swallowed exceptions and unmanaged resource leak#92
halinhtvn3a wants to merge 1 commit intoAlachisoft:masterfrom
halinhtvn3a:contribai/fix/security/windows-authentication-with-swallowed-ex

Conversation

@halinhtvn3a
Copy link
Copy Markdown

Problem

The VerifyWindowsUserForRole method calls LogonUser (P/Invoke) but:

  1. Swallows ALL exceptions in a bare catch block, hiding authentication failures and system errors.
  2. Does not close the Windows token handle (IntPtr) obtained from LogonUser, causing a resource leak.
  3. Does not check the return value of LogonUser; it assumes success and proceeds to use the token.
    Impact: Resource exhaustion over time, inability to diagnose authentication issues, and potential use of invalid token if LogonUser fails.

Severity: high
File: Src/NCCommon/Util/SecurityUtil.cs

Solution

Replace the method with:

Changes

  • Src/NCCommon/Util/SecurityUtil.cs (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…nmanaged resource leak

The VerifyWindowsUserForRole method calls LogonUser (P/Invoke) but:
1. Swallows ALL exceptions in a bare catch block, hiding authentication failures and system errors.
2. Does not close the Windows token handle (IntPtr) obtained from LogonUser, causing a resource leak.
3. Does not check the return value of LogonUser; it assumes success and proceeds to use the token.
Impact: Resource exhaustion over time, inability to diagnose authentication issues, and potential use of invalid token if LogonUser fails.


Affected files: SecurityUtil.cs

Signed-off-by: halinhtvn3a <77691576+halinhtvn3a@users.noreply.github.com>
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.

1 participant