Skip to content

fix: clamp PktLen in CFE_MSG_ComputeCheckSum to MAX_SB_MSG_SIZE#2756

Open
stark256-spec wants to merge 1 commit into
nasa:devfrom
stark256-spec:fix/msg-computechecksum-bound
Open

fix: clamp PktLen in CFE_MSG_ComputeCheckSum to MAX_SB_MSG_SIZE#2756
stark256-spec wants to merge 1 commit into
nasa:devfrom
stark256-spec:fix/msg-computechecksum-bound

Conversation

@stark256-spec
Copy link
Copy Markdown

Fixes nasa/cFS#2699. CFE_MSG_GetSize() reads the loop bound from the attacker-controlled CCSDS Length field. Without an upper-bound check, while(PktLen--) iterates over an attacker-chosen number of bytes regardless of the actual buffer, enabling an OOB heap read. Clamps PktLen to CFE_MISSION_SB_MAX_SB_MSG_SIZE before the loop; a larger value indicates a malformed message and is treated as zero.

CFE_MSG_GetSize() reads the loop bound directly from the attacker-
controlled CCSDS Length field. Without an upper-bound check the
while(PktLen--) loop iterates over PktLen bytes regardless of the
actual allocated buffer, enabling an OOB heap read proportional to
the difference between the claimed and actual message size.

Clamp PktLen to CFE_MISSION_SB_MAX_SB_MSG_SIZE (the largest valid
SB message) before entering the loop. A larger value indicates a
malformed message and is treated as zero (returns 0xFF checksum),
which will fail the subsequent validity check in the caller.

Fixes nasa/cFS#2699
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