Skip to content

fix(signing): keep repeated ELF signing idempotent - #339

Merged
alexey-igrychev merged 2 commits into
2from
fix/v2/elf-signing-idempotence
Sep 22, 2026
Merged

alexey-igrychev merged 2 commits into
2from
fix/v2/elf-signing-idempotence

Conversation

@alexey-igrychev

Copy link
Copy Markdown
Collaborator

Backport the ELF signing guards from #336 to the v2 line and update delivery-kit-sdk to v1.4.2.

  • skip bsign when the current hash is sound and the signer matches
  • verify the ELF hash after bsign writes the file
  • make in-house signing a no-op for an equivalent existing signature
  • use elfedit v0.1.1 for safe same-sized section replacement

Validation:

  • go mod verify
  • go test -count=1 -tags="dfrunsecurity dfrunnetwork dfrunmount dfssh containers_image_openpgp" ./pkg/build/signing/
  • go vet -tags="dfrunsecurity dfrunnetwork dfrunmount dfssh containers_image_openpgp" ./pkg/build/signing/

Prepared for review; do not merge automatically.

…336)

`signELFFile` only checked bsign's signing exit code. Astra bsign 1.4.2
can return 0 after rewriting a file that immediately fails its own hash
check, so a corrupt ELF shipped silently.

After `bsign -N -s`, delivery-kit now runs `bsign -cE` and fails the
build when the ELF-section hash does not pass. `-E` is required: without
it bsign also probes absent xattr/detached stores and returns 64 even
for a good ELF hash.

Measured on the incident binaries:
```
pause_2: bsign -cE -> good hash, rc=0
pause:   bsign -cE -> invalid hash, rc=66
```

Exit 73 (non-zero unused signature-section bytes) now has a descriptive
error instead of `unknown exit code`. That condition is intentionally
build-fatal; bsign also cannot verify those files.

Stub tests assert the exact ordered argv sequence and same path for
signing/checking, plus failures 66 and 73. Package unit/vet pass.
Related root-cause protections: deckhouse/delivery-kit-sdk#109 and
deckhouse/elfedit#4.

---------

Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
(cherry picked from commit 5515529)
Signed-off-by: Aleksei Igrychev <aleksei.igrychev@palark.com>
@alexey-igrychev
alexey-igrychev merged commit f349dd2 into 2 Sep 22, 2026
13 of 14 checks passed
@alexey-igrychev
alexey-igrychev deleted the fix/v2/elf-signing-idempotence branch September 22, 2026 12:28
alexey-igrychev pushed a commit that referenced this pull request Sep 22, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.78.1-dk.2](v2.78.1-dk.1...v2.78.1-dk.2)
(2026-09-22)


### Bug Fixes

* **signing:** keep repeated ELF signing idempotent
([#339](#339))
([f349dd2](f349dd2))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

1 participant