Skip to content

Fenrir Fix: Base64 stdin input is silently truncated at 8000 bytes - #286

Open
aidankeefe2022 wants to merge 3 commits into
wolfSSL:mainfrom
aidankeefe2022:fenrir-11088
Open

Fenrir Fix: Base64 stdin input is silently truncated at 8000 bytes#286
aidankeefe2022 wants to merge 3 commits into
wolfSSL:mainfrom
aidankeefe2022:fenrir-11088

Conversation

@aidankeefe2022

@aidankeefe2022 aidankeefe2022 commented Aug 31, 2026

Copy link
Copy Markdown
Member

Added read/write io functions that can be used to interact with any file pointer

Fix for Fenrir finding : https://fenrir.wolfssl.com/finding/11088

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #286

Scan targets checked: wolfclu-bugs, wolfclu-src

Findings: 4
4 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_base64.c Outdated
Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_base64.c Outdated
Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_io.c Outdated

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #286

Scan targets checked: wolfclu-bugs, wolfclu-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/tools/clu_io.c
Comment thread src/tools/clu_io.c
Comment thread src/tools/clu_io.c
Comment thread src/tools/clu_io.c

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #286

Scan targets checked: wolfclu-bugs, wolfclu-src

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/tools/clu_io.c
Comment thread src/tools/clu_io.c Outdated
Comment thread src/tools/clu_io.c
Comment thread src/tools/clu_io.c Outdated

@wolfSSL-Fenrir-bot wolfSSL-Fenrir-bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fenrir Automated Review — PR #286

Scan targets checked: wolfclu-src, wolfclu-bugs

Findings: 2
2 finding(s) posted as inline comments (see file-level comments below)

This review was generated automatically by Fenrir. Reported findings require changes before merge.

Comment thread src/tools/clu_io.c
break;
}

if (read == 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero-byte stdin read hides I/O errors as EOF · Incorrect error handling

StreamRead treats a zero BIO read as EOF, but wolfSSL's file BIO forwards fread, which also returns zero on input errors. The command reports success with a truncated Base64 prefix; unlike known #11088, this lacks EOF/error discrimination.

Related known finding #12926 (similar but distinct): Both mishandle BIO input-read failure conditions, but this is StreamRead treating a zero return as EOF without error discrimination; #12926 is wolfCLU_CRLVerify discarding the read result and using a seek-derived length. They have different functions, faulting operations, root causes, and required patches.

Suggested fix: Distinguish EOF from stream failure after a zero read and return WOLFCLU_FATAL_ERROR for failure.
Basis: ISO/IEC 9899:2018 §§7.21.8.1 and 7.21.10.3 require the stream indicators to distinguish fread end-of-file from error.

Comment thread src/tools/clu_io.c
wolfCLU_LogError("Could not get file pointer from BIO");
return WOLFCLU_FATAL_ERROR;
}
if (XFSEEK(innerFp, 0, SEEK_END) != 0) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FileRead bypasses the XFILE seek-origin abstraction · API contract violations

FileRead passes stdio SEEK_END to the selected XFSEEK backend instead of its paired XSEEK_END. Non-stdio backends use the wrong origin and fail or mis-size input; unlike known #6884, this is an abstraction mismatch, not integer truncation.

Suggested fix: Pass XSEEK_END to XFSEEK so the origin matches the selected XFILE backend.
Basis: wolfSSL wc_port.h defines XSEEK_END as the backend-specific seek-origin constant paired with XFSEEK.

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.

3 participants