Skip to content

[FEATURE/SECURITY/BUG] Add hash key validation to check the files downloaded from external projects #3418

Description

@acassis

Description / Steps to reproduce the issue

Currently all external projects are downloaded/compiled without checking if their MD5/SHA are valid, so if their content get modified we will not know, ie:

LVGL_UNPACKNAME = lvgl
UNPACK ?= unzip -o $(if $(V),,-q)
CURL ?= curl -L -O $(if $(V),,-Ss)

LVGL_UNPACKDIR = $(WD)/$(LVGL_UNPACKNAME)

$(LVGL_TARBALL):
$(ECHO_BEGIN)"Downloading: $(LVGL_TARBALL)"
$(Q) $(CURL) $(CONFIG_GRAPH_LVGL_URL)/$(LVGL_TARBALL)
$(ECHO_END)

$(LVGL_UNPACKNAME): $(LVGL_TARBALL)
$(ECHO_BEGIN)"Unpacking: $(LVGL_TARBALL) -> $(LVGL_UNPACKNAME)"
$(Q) $(UNPACK) $(LVGL_TARBALL)
$(Q) mv lvgl-$(LVGL_VERSION) $(LVGL_UNPACKNAME)
$(Q) touch $(LVGL_UNPACKNAME)
$(ECHO_END)

On which OS does this issue occur?

[OS: Linux]

What is the version of your OS?

Ubuntu 24.04

NuttX Version

mainline

Issue Architecture

[Arch: all]

Issue Area

[Area: Examples]

Host information

No response

Verification

  • I have verified before submitting the report.

Activity

  1. changed the title [-][FEATURE/SECURITY/BUG] Add harsh key validation to check the files downloaded from external projects[/-] [+][FEATURE/SECURITY/BUG] Add hash key validation to check the files downloaded from external projects[/+] on Mar 4, 2026
  2. Swatantra-66 commented on Oct 10, 2026

    @Swatantra-66
    Contributor

    Hi @acassis,

    I would like to take this up!

    Looking into the repository, we actually already have apps/tools/check-hash.sh in tree (added around NuttX 7.29), but currently only 5 packages (inih, psmq, embedlog, rtttl-c, morsey) utilize it. Flagship packages like LVGL, zlib, and others still download archives without validation.

    I propose the following approach:

    1. Enhance apps/tools/check-hash.sh:

      • Add md5 support alongside sha1|sha224|sha256|sha384|sha512.
      • Replace legacy which checks with POSIX command -v.
      • Add a fallback to Python 3's hashlib if neither <algo>sum nor shasum is available on the host build environment.
      • Normalize hash comparison to be case-insensitive.
    2. Standardize Makefile & CMake Integration:

      • Define CHECKHASH ?= $(APPDIR)/tools/check-hash.sh centrally in apps/Make.defs so individual Makefiles do not need ad-hoc tool paths.
      • Allow optional hash overrides (e.g., LVGL_SHA256 ?= ...), skipping validation gracefully only if an upstream hash is explicitly cleared or pointing to an unversioned dev branch.
      • Add matching URL_HASH validation in CMakeLists.txt (FetchContent_Declare).
    3. Rollout:

      • Start with graphics/lvgl (and optionally system/zlib) as the primary pilot PR, followed by rolling it out systematically to the remaining external packages.

    Please let me know if this plan looks good to you, and feel free to assign this issue to me.

  3. cederom commented on Oct 11, 2026

    @cederom
    Contributor

    Thanks @Swatantra-66 yes please provide the PR with solution proposition :-)

    • MD5 is not considered secure, we should use SHA256+ where possible.
    • okay to replace which with command -v.
    • For now I would avoid Python in the *.sh scripts. We have clear separation of interpreters and dependencies. Python became moving target while shell is stable. We may want to fallback to pythoh when we hit a wall with existing problem, or create a dedicated python script for that. For now please avoid mixing the Python in.
    • okay with lowercase hash comaprison.
    • okay with CHECKHASH centralization in apps/Make.defs.
    • okay with optional overrides.
    • okay with example implementation in graphics/lvgl and system/zlib.

    Thank you and have fun! :-)

  4. Swatantra-66 commented on Oct 11, 2026

    @Swatantra-66
    Contributor

    Thanks @cederom! I have submitted the proposal in #3833 incorporating all the points discussed. Looking forward to your review! :-)

  5. added 2 commits that reference this issue on Oct 11, 2026
    0239c5b
    1185607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: BugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions