Skip to content

[Security] MavenBndRepository: Add Trusted Checksum Verification#7269

Draft
chrisrueger wants to merge 8 commits into
bndtools:masterfrom
chrisrueger:7236-trusted-checksum-verification
Draft

[Security] MavenBndRepository: Add Trusted Checksum Verification#7269
chrisrueger wants to merge 8 commits into
bndtools:masterfrom
chrisrueger:7236-trusted-checksum-verification

Conversation

@chrisrueger

Copy link
Copy Markdown
Contributor

Closes #7236

Work in progress draft

This pull request introduces support for trusted checksum verification of Maven artifacts in the repository system. It adds the ability to generate, store, and validate checksums for artifacts, enhancing security and integrity.

Introduce trusted checksum support for Maven-backed repositories.

- Add TrustedChecksums to read a sidecar checksum file and map Archive -> checksum entries.
- Add Configuration.checksumFile(...) to locate the checksum sidecar next to an index.
- MavenBndRepository loads and opens the trusted checksum file and injects it into remote backing repositories.
- MavenBackingRepository gains a trustedChecksums field, setTrustedChecksums(...), and checkTrustedChecksum(...) which computes MD5/SHA-1/SHA-256/SHA-512, deletes mismatched downloads and throws on mismatch (returns false if no trusted checksum applies).
- MavenRemoteRepository treats a matching trusted checksum as authoritative before other validation.
- Bumped provider package versions.

This change ensures downloaded artifacts can be validated against operator-provided checksums to protect against tampered or corrupted artifacts.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Because it could be useful there too if file system content is manipulated by evil actor

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
to use same digest comparison which is also more fault tolerant e.g. against spaces

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Add support for creating a trusted checksums sidecar for Maven index files. Introduces IndexFile.createTrustedChecksumsFile(), MbrUpdater#createTrustedChecksumsFile(), and a RepoActions UI entry to trigger generation. Implements TrustedChecksums.createTrustedChecksumFile(IMavenRepo, File, Collection<Archive>) which writes an UTF-8 .checksums file next to the index containing lines of the form "<archive>=sha1:<hex>" using repo.toLocalFile() and SHA1.digest(). Also adds a toString override and necessary imports and exception handling; repo.refresh() is invoked after generation.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Introduce TrustedChecksumException (TrustedChecksums.java) to represent fatal trusted-checksum verification failures. MavenBackingRepository now catches checksum validation errors and rethrows them as TrustedChecksumException so they can be distinguished from transient failures. MavenRemoteRepository's recovery logic detects this exception and bypasses retrying (logs and returns null), preventing retries on trusted checksum mismatches. Also minor adjustment to logging to use the captured failure for clearer messages.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
Centralize and improve trusted checksum support: TrustedChecksums is now final, stores its sidecar file as final and exposes getFile(); createTrustedChecksumFile now accepts an explicit checksum file and writes a header line. Added computeHash utility to TrustedChecksums to support sha1/sha256/sha512/md5 and improved parsing/error messages. Removed duplicate computeHash from MavenBackingRepository and switched to the shared implementation. Moved checksum file creation responsibility from IndexFile to MavenBndRepository (added loadTrustedChecksumFile and createTrustedChecksumsFile), updated MbrUpdater to call the repository-level creator, and made index/info output include the trusted checksums file when present.

Signed-off-by: Christoph Rueger <chrisrueger@gmail.com>
@chrisrueger chrisrueger force-pushed the 7236-trusted-checksum-verification branch from a7d9341 to d434f24 Compare June 9, 2026 21:28
@chrisrueger chrisrueger changed the title Add Trusted Checksum Verification [Security] MavenBndRepository: Add Trusted Checksum Verification Jun 14, 2026
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.

[security] Support trusted checksum verification for Maven repositories/index

1 participant