nasa / nasa/cFS

[SECURITY] Integer Underflow in CFE_FS_ParseInputFileNameEx

Open
#893 4 comments 0 reactions 1 assignee View on GitHub

@ddstewar is already working on this.

Since Aug 31, 2026.

bug security
Dominant language
C
Stars
1.5k
Forks
391
Avg merge
1d 11h
Merged PRs (30d)
19

Description

Summary

Integer underflow vulnerability in CFE_FS_ParseInputFileNameEx() function that can lead to RCE, information disclosure, or DoS.

Affected File

cfe/modules/fs/fsw/src/cfe_fs_api.c lines 443-454

Description

When input filename contains NO '/' character, the function falls back to using DefaultPath. The ComponentLen is set to strlen(DefaultPath) which can be larger than InputLen. Since InputLen is unsigned (size_t), subtracting a larger value causes integer underflow to ~2⁶⁴-1.

Proof of Concept

#include <stdio.h>

int main() {
    unsigned long InputLen = 7;      // strlen("EXPLOIT")
    unsigned long ComponentLen = 12;  // strlen("/cf/scripts/")
    
    printf("Input: EXPLOIT (no slash)\n");
    printf("InputLen: %lu\n", InputLen);
    printf("DefaultPath: /cf/scripts/ (len %lu)\n", ComponentLen);
    
    if (ComponentLen > InputLen) {
        printf("\n🔥 UNDERFLOW OCCURS!\n");
        printf("Before: %lu\n", InputLen);
        InputLen -= ComponentLen;
        printf("After: %lu (0x%lX)\n", InputLen, InputLen);
    }
    return 0;
}

Impact

· Memory corruption (out-of-bounds write)
· Information leak (out-of-bounds read)
· Denial of Service (crash)
· Potential RCE (function pointer overwrite)

Suggested Fix

if (ComponentLen > InputLen) {
    return CFE_FS_INVALID_PATH;
}
InputLen -= ComponentLen;

Related Issues Found

  1. Path traversal - No filter for ".."
  2. Unsafe sprintf in cfe_es_cds.c and cfe_sb_priv.c

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.