Guard against uint16 overflow when marshalling oversized ACLs and ACEs (#79)#87
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Linked Issue
Closes #79Motivation
AclSize(ACL header) andHeader.Size(ACE header) areuint16fields. The marshallers computed them with unchecked conversions (uint16(8 + len(...))anduint16(len(...) + headerSize)). A DACL with many/large ACEs, or an ACE with a largeApplicationDatapayload (resource-attribute / conditional-expression ACEs), can legitimately exceed 64 KB, at which point the cast wraps modulo 65536 and writes a structurally invalid, too-small size. Returning an error is far safer than emitting silently corrupt output a reader would then truncate.What Changed
DiscretionaryAccessControlList.MarshalandSystemAccessControlList.MarshalcomputetotalSize = 8 + len(body)and return an error if it exceeds0xFFFFbefore assigningHeader.AclSize.AccessControlEntry.MarshalcomputestotalSize = len(body) + headerSizeand returns an error if it exceeds0xFFFF; the existing size comparison and theHeader.Sizeassignment now both use that validated value, so the guard covers the comparison branch as well as the assignment.Acceptance Criteria Check
TestDACL_Marshal_OversizedAclSize,TestSACL_Marshal_OversizedAclSize.TestACE_Marshal_OversizedApplicationData.TestDACL_Marshal_NormalSizeOK,TestACE_Marshal_NormalSizeOK, plus the full existing suite including the real-dataset involution test.acl/andace/cover the overflow boundary.How Verified
ace/AccessControlEntry_overflow_test.goandacl/AccessControlList_overflow_test.go(oversized cases error; normal cases succeed).go build ./...andgo test ./...pass.Test Coverage
Scope of Change
acl/DiscretionaryAccessControlList.go,acl/SystemAccessControlList.go,ace/AccessControlEntry.go,acl/AccessControlList_overflow_test.go,ace/AccessControlEntry_overflow_test.goMarshalmay now return an error in the overflow case where it previously returned silently-wrong bytesRisk and Rollout
Low. Normal-sized data marshals byte-identically (verified by the dataset involution test); only inputs that genuinely cannot fit the 16-bit size fields now error instead of producing corrupt output. Safe to merge.