Safeguard
Supply Chain•

How do Meson wrap files verify a downloaded C library?

Meson wrap files fetch dependency source and can check it with sha256 hashes. See which fields matter and how to review a wrap file in a pull request.

Safeguard Security Team
3 min read

A Meson wrap file tells the build how to fetch a dependency into the subprojects directory. For archive downloads it can carry a sha256 checksum for the source and for any patch overlay, and Meson checks the file's hash. A wrap without a hash is a download you are trusting blindly.

What a wrap file holds

Per the Meson wrap manual, wrap files are named after the project, end in .wrap, and live in the subprojects directory. A typical archive wrap names a source_url and a source_hash, the sha256 checksum of the downloaded source archive. It may also name a patch_url and patch_hash for an optional overlay archive, a source_fallback_url used when the first download fails, and local diff files applied after the overlay.

The manual also says that if a source or patch file already sits in subprojects/packagecache, that file is used instead of a download, and its hash is still checked.

Wraps can also point at a git repository with a revision, which the manual says must be a branch, tag or commit. That is a different trust model, covered below.

What the hash does and does not prove

A hash proves the file you got matches the one the wrap author recorded. It does not prove the upstream release is safe, only that it did not change between the day the wrap was written and today. If the wrap author recorded a bad file, the hash will faithfully verify the bad file.

Wrap typePinned byWeak spot
Archivesource_hashHash recorded from an untrusted source
GitrevisionA branch name moves, a commit does not
Patch overlaypatch_hashOverlay can change code you think is upstream

Review checklist for a wrap file change

  1. Does every archive wrap have a source_hash, and every overlay a patch_hash?
  2. Does the revision of a git wrap point to a commit rather than a branch? See pin FetchContent to a commit hash for the same idea in CMake.
  3. Where did the hash value come from? Ask the author to cite the upstream release page or signature.
  4. Is a fallback URL pointing somewhere you control or trust?
  5. Do the patch or diff files change security relevant code? They are your fork in disguise, so keep them visible in review.
  6. Record the library version somewhere a scanner can read it, because the wrap file alone may not say.

Scanner blind spots

Subproject sources fetched at configure time do not appear in a lockfile. A scanner that reads only package manifests will miss them. This is the same issue as in does CMake FetchContent hide dependencies from scanners.

Safeguard's dependency scanning and SBOM generation can inventory the libraries in a repository, and the free scan at gold.safeguard.sh/scan shows what it finds in yours.

Quick check

Which field holds the source checksum?

The source_hash field, a sha256 checksum of the downloaded source archive.

Is a cached file in packagecache trusted without a hash check?

No. The Meson manual says the file's hash will be checked.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.