Skip to content

Conversation

@brtnfld
Copy link
Collaborator

@brtnfld brtnfld commented Jan 12, 2026

  1. Build System (CMakeLists.txt)
    Adds a new build option HDF5_REQUIRE_SIGNED_PLUGINS (defaulting to ON).
    Links the HDF5 library against OpenSSL (libssl, libcrypto) when this option is enabled.
    Defines the H5_REQUIRE_DIGITAL_SIGNATURE preprocessor macro.
  2. Plugin Loading Logic (src/H5PLint.c)
    Interception: Modifies the H5PL__open function to intercept the plugin loading process.
    MPI Coordination: In parallel builds, Rank 0 performs the verification and broadcasts the result to other ranks using MPI_Bcast.
    Verification Workflow:
    It relies on external shell commands (system()) and GNU objcopy to copy the plugin file and extract a signature section named "sig".
    It reads the extracted signature and the "clean" plugin binary into memory.
    It uses OpenSSL routines (EVP_DigestVerify, SHA-256) to verify the digital signature against a public key file.
    Helper Functions: Adds several internal functions to handle file reading, RSA key parsing, and filename validation.
  3. Headers
    Updates private headers to include OpenSSL dependencies and declare the new internal verification functions.

Important

Adds digital signature verification for HDF5 plugins using OpenSSL, with build system and plugin loading logic updates.

  • Build System:
    • Adds HDF5_REQUIRE_SIGNED_PLUGINS option in CMakeLists.txt (default OFF).
    • Links against libssl and libcrypto when enabled.
    • Defines H5_REQUIRE_DIGITAL_SIGNATURE macro.
  • Plugin Loading Logic:
    • Modifies H5PL__open() in H5PLint.c to verify plugin signatures using OpenSSL.
    • In parallel builds, rank 0 verifies and broadcasts result using MPI_Bcast.
    • Adds functions for file reading, RSA key parsing, and filename validation.
  • Headers:
    • Updates H5PLprivate.h to include OpenSSL headers and declare new functions.
    • Adds OpenSSL-related definitions to H5pubconf.h.in.

This description was created by Ellipsis for 579ce87. You can customize this summary. It will automatically update as commits are pushed.

glennsong09 and others added 2 commits January 9, 2026 17:52
* Add working code to verify signed plugins.

* Committing clang-format changes

* Adding changes to test branch

* Committing clang-format changes

* Moving to repo

* Committing clang-format changes

* Make fixes

* Committing clang-format changes

* Add

* Committing clang-format changes

* Finish up security changes

* Committing clang-format changes

* Fix bad conflict

* Add last 2 snprintfs

* Add changes to code

* Committing clang-format changes

* Remove bad file validation check

* Committing clang-format changes

---------

Co-authored-by: Glenn Song <[email protected]>
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
add_compile_definitions(H5_REQUIRE_DIGITAL_SIGNATURE)
# link_libraries(gpgme)
# link_libraries(gpg-error)
link_libraries(ssl)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using target_link_libraries() on specific targets instead of the global link_libraries() command for better modern CMake integration and dependency propagation.

HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "verification check failed");
}
#ifdef H5_HAVE_PARALLEL
MPI_Finalize();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling MPI_Finalize() within the plugin open routine can prematurely shut down MPI. Finalizing MPI should be done at program termination, not within plugin loading.

Suggested change
MPI_Finalize();

signature = H5PL__get_sig_name_from_path(path, "sig");
publickey = H5PL__get_sig_name_from_path(path, "key");
verify_result = H5PL__openssl_verify_signature(path, signature, publickey);
free(signature);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Memory allocated in H5PL__get_sig_name_from_path() is done via H5MM_calloc, so it should be freed with H5MM_xfree rather than free() to maintain consistency with HDF5’s memory management.

Suggested change
free(signature);
signature = (char *)H5MM_xfree(signature);

H5_DLL int H5PL__RSA_verify_signature(RSA *rsa, unsigned char *msg_hash, size_t msg_hash_len, const char *msg,
size_t msg_len, int *authentic);
H5_DLL RSA *H5PL__create_public_RSA(const char *key);
H5_DLL char *H5PL__openSSL_read_file(const char *file_path, int *file_length);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typographical suggestion: The function name H5PL__openSSL_read_file uses 'openSSL' with mixed capitalization, whereas H5PL__openssl_verify_signature uses all lowercase for 'openssl'. For consistency, consider using a uniform naming convention (e.g. H5PL__openssl_read_file).

@github-actions
Copy link
Contributor

✅ Maven Staging Tests Passed

Maven artifacts successfully generated and validated.

Ready for Maven deployment to GitHub Packages.

1 similar comment
@github-actions
Copy link
Contributor

✅ Maven Staging Tests Passed

Maven artifacts successfully generated and validated.

Ready for Maven deployment to GitHub Packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To be triaged

Development

Successfully merging this pull request may close these issues.

3 participants