fix: reject empty symbol table from ReadTable#333
Conversation
A Go binary always has functions in its pclntab (runtime, etc.). An empty symbol table (0 funcs) indicates a corrupt or incorrectly parsed pclntab — for example, when the magic bytes match at a coincidental offset in the wrong ELF section. Without this guard, an empty table causes isUsingCryptoModule to return false, setting GoNoCrypto=true, which silently skips all subsequent FIPS validation (CGO, symbols, tags, static linking, OpenSSL checks). Co-authored-by: Cursor <cursoragent@cursor.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jiridanek The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
@jiridanek: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
|
/lgtm just doing some testing to ensure this doesn't break anything with various ocp versions |
https://redhat.atlassian.net/browse/RHAIENG-4982
Summary
Follow-up to #330. Add a guard in
_loadGoSymbolsto reject symbol tableswith zero functions.
A Go binary always has functions in its pclntab — even a trivial
func main() {}produces hundreds of runtime functions. An empty symbol table indicates the
pclntab was parsed from corrupt or unrelated data (e.g., a coincidental magic
byte match in the wrong ELF section).
Problem
Without this guard, an empty table causes
isUsingCryptoModuleto returnfalse(no functions to iterate → nocryptofound), settingGoNoCrypto=true.This silently skips all subsequent FIPS validation:
validateGoSymbols— skippedvalidateGoCgo— skippedvalidateGoCGOInit— skippedvalidateGoStatic— skippedvalidateGoOpenssl— skippedThe binary passes check-payload with no errors and no warnings, even though
no actual validation was performed.
How we discovered this
During analysis for #329, we found that on amd64 Go 1.26 PIE binaries, the
old buggy section lookup read
.data.rel.roinstead of.gopclntab. The BEmagic
ff ff ff f1matched at a coincidental offset in.data.rel.ro,producing an empty
gosym.Table(0 funcs). The scan appeared to succeedbut performed zero Go FIPS validation.
Change
Made with Cursor