Skip to content

fix: bound unauthenticated image size before RAM load#802

Merged
dgarske merged 6 commits into
wolfSSL:masterfrom
rizlik:fix_oob_ramboot
Jun 18, 2026
Merged

fix: bound unauthenticated image size before RAM load#802
dgarske merged 6 commits into
wolfSSL:masterfrom
rizlik:fix_oob_ramboot

Conversation

@rizlik

@rizlik rizlik commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

ZD#21988

@rizlik rizlik requested review from Copilot and dgarske and removed request for Copilot June 17, 2026 12:02
@rizlik rizlik self-assigned this Jun 17, 2026
@rizlik rizlik force-pushed the fix_oob_ramboot branch from 4793d14 to d12f1f0 Compare June 17, 2026 12:42
Copilot AI review requested due to automatic review settings June 17, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses a security-hardening issue in wolfBoot’s RAM-load paths by bounding an unauthenticated image length (read from a decrypted-but-not-yet-authenticated header) before it can drive RAM copies/decryption. This is especially important for EXT_ENCRYPTED stream-cipher configurations where ciphertext malleability can attacker-influence the decrypted length field.

Changes:

  • Introduces a shared wolfBoot_ramboot_check_size() helper to validate payload size against the RAM load region.
  • Uses the helper to reject oversized images in both wolfBoot_ramboot() (RAM load) and wolfBoot_ram_decrypt() (MMU ramboot decrypt path) before copying/decrypt loops run.
  • Adds new unit tests (and Makefile targets) to regress oversized length, wraparound length, and ciphertext bit-flip manipulation of the length field.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
tools/unit-tests/unit-update-ram-enc.c Adds regression tests for encrypted/MMU RAM decrypt size-bounding (including wrap and malleation cases).
tools/unit-tests/Makefile Adds build/run targets for the new encrypted RAM decrypt unit tests (fixed partitions + nopart/RAMBOOT_MAX_SIZE variants).
src/update_ram.c Switches RAM-load size validation to the shared wolfBoot_ramboot_check_size() helper.
src/libwolfboot.c Adds bounds checking in wolfBoot_ram_decrypt() before the decrypt/copy loop.
include/image.h Adds the wolfBoot_ramboot_check_size() inline helper for consistent bounds validation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/libwolfboot.c Outdated
Comment thread src/update_ram.c
Comment thread include/image.h Outdated
Comment thread tools/unit-tests/unit-update-ram-enc.c
Comment thread tools/unit-tests/unit-update-ram-enc.c
Comment thread tools/unit-tests/unit-update-ram-enc.c
Comment thread tools/unit-tests/unit-update-ram-enc.c
Comment thread tools/unit-tests/unit-update-ram-enc.c
@rizlik rizlik force-pushed the fix_oob_ramboot branch from d12f1f0 to 9449dfa Compare June 17, 2026 13:29

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Skoll Multi-Scan Review

Modes: review + review-securityOverall recommendation: COMMENT
Findings: 4 total — 4 posted, 0 skipped
4 finding(s) posted as inline comments (see file-level comments below)

Posted findings

  • [Medium] [review] Bound-check edge cases not exercised: exact max-valid length and FIXED underflow guardtools/unit-tests/unit-update-ram-enc.c:118-300
  • [Low] [review+review-security] WOLFBOOT_RAMBOOT_MAX_SIZE silently ignored when WOLFBOOT_FIXED_PARTITIONS is also definedsrc/libwolfboot.c:2418-2429
  • [Low] [review-security] New length bound does not account for ENCRYPT_BLOCK_SIZE rounding of the decrypt copy loopsrc/libwolfboot.c:2418-2439
  • [Low] [review] Overflow-length tcase is missing its tcase_set_timeout calltools/unit-tests/unit-update-ram-enc.c:323-326

Review generated by Skoll

Comment thread tools/unit-tests/unit-update-ram-enc.c
Comment thread src/libwolfboot.c Outdated
Comment thread src/libwolfboot.c Outdated
Comment thread tools/unit-tests/unit-update-ram-enc.c

@dgarske dgarske left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@rizlik rizlik removed their assignment Jun 18, 2026
@rizlik rizlik requested a review from dgarske June 18, 2026 11:40
@dgarske dgarske merged commit 08c8bdd into wolfSSL:master Jun 18, 2026
385 checks passed
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