[SECURITY] Missing length validation for CFE_ES_SEND_HK_MID in ES TaskPipe

Open Beginner friendly
#986 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
c
Domain
security

Research direction

Start in cfe/modules/es/fsw/src/cfe_es_dispatch.c at CFE_ES_TaskPipe(), and compare the SEND_HK_MID path with the other command paths in CFE_ES_ProcessGroundCmd(). Reproduce with a packet smaller than sizeof(CFE_ES_SendHkCmd_t); done means the message length is checked before the buffer is cast and truncated packets no longer reach the field accesses.

Written by the indexing model from the issue text.

Description

bug

Describe the bug
CFE_ES_TaskPipe() processes SEND_HK_MID messages by directly casting the buffer to CFE_ES_SendHkCmd_t * without calling CFE_ES_VerifyCmdLength(). All other command codes in CFE_ES_ProcessGroundCmd() use VerifyCmdLength before casting. A malformed/truncated packet can cause OOB read when ES accesses the struct fields.

This is the same root cause as #971 (TIME DATA_CMD_MID missing length validation).

To Reproduce

  1. Send a CFE_ES_SEND_HK_MID packet with size < sizeof(CFE_ES_SendHkCmd_t)
  2. ES processes it without validation
  3. OOB read when fields are accessed

Expected behavior
CFE_ES_TaskPipe() should call CFE_ES_VerifyCmdLength(&SBBufPtr->Msg, sizeof(CFE_ES_SendHkCmd_t)) before casting.

Code snips
File: cfe/modules/es/fsw/src/cfe_es_dispatch.c, function CFE_ES_TaskPipe():

if (CFE_SB_MsgId_Equal(MessageID, SEND_HK_MID))
{
    CFE_ES_SendHkCmd((const CFE_ES_SendHkCmd_t *)SBBufPtr); // بدون VerifyCmdLength!
}

Reporter Info
Erfan, Independent Space Software Security Researcher
Dominant language
C
Stars
1.5k
Forks
391
Avg merge
1d 11h
Merged PRs (30d)
19

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nasa/cFS

All issues in nasa/cFS

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.