Skip to content

fix(sbom): take wolfSSL version from WOLFSSL_DIR, not pkg-config - #26

Open
MarkAtwood wants to merge 1 commit into
masterfrom
fix/sbom-version-from-tree
Open

fix(sbom): take wolfSSL version from WOLFSSL_DIR, not pkg-config#26
MarkAtwood wants to merge 1 commit into
masterfrom
fix/sbom-version-from-tree

Conversation

@MarkAtwood

Copy link
Copy Markdown
Contributor

When WOLFSSL_DIR names a tree, the wolfSSL dependency version came only from wolfssl/version.h. That header is generated by configure as well as tracked, so make distclean removes it. With it gone wv stayed empty, --dep-version was never passed, and gen-sbom fell back to pkg-config --modversion wolfssl, which reports the installed wolfSSL.

On a host whose installed build differs from WOLFSSL_DIR, the SBOM recorded that unrelated version and still exited 0. That is a compliance artifact attesting a component the product was not built against. Found against wolfSSH (wolfSSL/wolfssh#1050), where a distclean-ed tree produced 9.9.9 instead of 5.9.2, by running make sbom by hand. No CI caught it.

Change

  • Fall back to AC_INIT in WOLFSSL_DIR/configure.ac, which survives distclean.
  • Fail when a named tree yields neither source, rather than letting an installed copy answer for it.
  • SBOM_WOLFSSL_VERSION still overrides both.

The test -n "$(WOLFSSL_DIR)" guard is preserved deliberately. With no WOLFSSL_DIR there is no tree to consult, so gen-sbom pkg-config lookup remains the intended source and the vendored path is unchanged.

Verification

The recipe has no test coverage, so I exercised the shipped bytes directly by extracting the block from share/sbom.am and running every path:

WOLFSSL_DIR result
tree with version.h 5.9.2
distclean-ed, configure.ac only 5.9.2 (the reported bug)
tree with neither exit 1, explicit error
unset (vendored) exit 0, no --dep-version, pkg-config preserved
SBOM_WOLFSSL_VERSION=1.2.3 1.2.3

The fourth row is the regression check that matters: wolfBoot vendors this file and does not always set WOLFSSL_DIR. All four existing test suites pass.

Two things for a follow-up, not this PR

  1. share/sbom.am has no test coverage. selftest.yml runs four Python suites and never exercises the Make fragment that wolfBoot, wolfssl, wolfTPM and wolfSSH all vendor. That is why this survived in the canonical copy. The check that finds it needs an adversarial environment: a stub pkg-config returning a sentinel plus a distclean-ed tree, so a wrong source is distinguishable from a right one. On a runner where the installed and source wolfSSL agree, a naive assertion passes either way.

  2. The same defect is still live downstream. wolfssl/scripts/sbom.am, wolfTPM/scripts/sbom.am and wolfBoot/tools/sbom/sbom.am all carry the identical logic today. wolfBoot copy is byte-identical to canonical, so its wolfglass_drift job is green while faithfully carrying the bug, and it will stay green after this merges because it checks against its own pinned rev rather than wolfGlass HEAD. wolfBoot needs a re-pin to pick this up.

When WOLFSSL_DIR named a tree, the version came only from
wolfssl/version.h. That header is generated by configure as well as
tracked, so `make distclean` removes it. With it gone, wv stayed empty,
--dep-version was never passed, and gen-sbom fell back to
`pkg-config --modversion wolfssl`, which reports the *installed*
wolfSSL. On a host whose installed build differs from WOLFSSL_DIR the
SBOM recorded that unrelated version and still exited 0, attesting a
component the product was not built against. Reported against wolfSSH,
where a distclean'd tree yielded 9.9.9 instead of 5.9.2.

Fall back to AC_INIT in WOLFSSL_DIR/configure.ac, which survives
distclean, and fail when a named tree yields neither source rather than
letting an installed copy answer for it. With no WOLFSSL_DIR there is no
tree to consult, so gen-sbom's pkg-config lookup stays the intended
source and the vendored path is unchanged. SBOM_WOLFSSL_VERSION still
overrides both.
@MarkAtwood
MarkAtwood requested review from sameehj and a lite review from Copilot August 26, 2026 19:44

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

Updates the shared Automake SBOM recipe so that when WOLFSSL_DIR points at a wolfSSL source tree, the recorded wolfSSL dependency version is taken from that tree (and the build fails if it can’t be determined), rather than silently falling back to the host’s installed wolfSSL via pkg-config.

Changes:

  • When SBOM_WOLFSSL_VERSION is unset and WOLFSSL_DIR is set, derive wolfSSL version from wolfssl/version.h, falling back to configure.ac if needed.
  • Fail the sbom target if a WOLFSSL_DIR tree is provided but yields no version, preventing incorrect SBOM attribution to an installed wolfSSL.
  • Expand inline documentation to describe the detection/fallback and failure behavior.
Suppressed comments (1)

share/sbom.am:214

  • This error path triggers whenever wv is still empty, which can happen not only when the files are unreadable/missing, but also when their contents don’t match the expected patterns. The current wording says they were not readable, which can be misleading and complicates debugging.
	                echo "       Neither wolfssl/version.h (generated by configure, so"; \
	                echo "       'make distclean' removes it) nor configure.ac was"; \
	                echo "       readable. Refusing to fall back to pkg-config: that"; \
	                echo "       reports the *installed* wolfSSL, which may be a"; \

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread share/sbom.am
Comment on lines +200 to +207
if test -f "$(WOLFSSL_DIR)/wolfssl/version.h"; then \
wv=`sed -n 's/.*LIBWOLFSSL_VERSION_STRING[[:space:]]*"\([^"]*\)".*/\1/p' \
"$(WOLFSSL_DIR)/wolfssl/version.h"`; \
fi; \
if test -z "$$wv" && test -f "$(WOLFSSL_DIR)/configure.ac"; then \
wv=`sed -n 's/^AC_INIT(\[[^]]*\],\[\([^]]*\)\].*/\1/p' \
"$(WOLFSSL_DIR)/configure.ac" | sed -n 1p`; \
fi; \
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.

2 participants