Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Memory Allocation for DACL in createWindowsDACL() Function #10713

Closed
idrassi opened this issue May 8, 2024 · 1 comment · Fixed by #10712
Closed

Incorrect Memory Allocation for DACL in createWindowsDACL() Function #10713

idrassi opened this issue May 8, 2024 · 1 comment · Fixed by #10712

Comments

@idrassi
Copy link
Contributor

idrassi commented May 8, 2024

Overview

There is a bug in the createWindowsDACL() function where the memory allocation for the DACL is incorrectly calculated. This miscalculation leads to insufficient memory allocation for the ACCESS_ALLOWED_ACE structures, potentially causing buffer overflows and undefined behavior when these structures are used.

Expected Behavior

The function should allocate sufficient memory for the DACL by including the size of the ACCESS_ALLOWED_ACE structure for each ACE in the total memory calculation. The correct calculation should sum up the sizes of the ACL, all ACCESS_ALLOWED_ACE structures, and the SIDs involved.

Actual Behavior

The current implementation of the createWindowsDACL() function incorrectly calculates the total memory required for the DACL. The existing code is:

cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid)
        + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pLocalSystemSid) + GetLengthSid(pOwnerRightsSid);

This calculation mistakenly adds the size of ACCESS_ALLOWED_ACE twice while adding the lengths of all three SIDs.

Context

Discovered during code review

@droidmonkey
Copy link
Member

Ugh, this precacluation of the size is so archaic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants