Skip to content

Conversation

@glennsong09
Copy link
Collaborator

@glennsong09 glennsong09 commented Dec 16, 2025

Here are the current changes to the code, this does not include the tests I'm working on yet, and parallel might not be fully functional yet, but it is close.

Tasks:

  • add documentation about the feature to the user's guide.

Important

Add digital signature verification for plugins in HDF5, with build configuration and new functions for handling signatures using OpenSSL.

  • Build Configuration:
    • Added HDF5_REQUIRE_SIGNED_PLUGINS option in CMakeLists.txt to require digitally signed plugins.
    • Links ssl and crypto libraries when HDF5_REQUIRE_SIGNED_PLUGINS is enabled.
  • Plugin Management:
    • In H5PLint.c, added digital signature verification in H5PL__open() using H5PL__openssl_verify_signature().
    • Introduced functions for signature handling: H5PL__get_sig_name_from_path(), H5PL__create_public_RSA(), H5PL__RSA_verify_signature(), H5PL__openSSL_read_file(), H5PL__check_filename(), and H5PL__openssl_verify_signature().
  • Header Changes:
    • Updated H5PLprivate.h to declare new functions for digital signature verification.
    • Included OpenSSL headers conditionally based on H5_REQUIRE_DIGITAL_SIGNATURE.

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

@glennsong09 glennsong09 requested a review from brtnfld as a code owner December 16, 2025 17:28
@github-project-automation github-project-automation bot moved this to To be triaged in HDF5 - TRIAGE & TRACK Dec 16, 2025
@glennsong09 glennsong09 marked this pull request as draft December 16, 2025 17:28
@glennsong09 glennsong09 changed the title Plugin Digital Signature Feature Add Plugin Digital Signature Feature Dec 16, 2025
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.

Avoid calling MPI_Finalize() inside H5PL__open; MPI lifetime must be managed by the application.

Suggested change
MPI_Finalize();

*authentic = 0;

/* Create EVP_PKEY structure and assign RSA key to it */
if (NULL == (pub_key = EVP_PKEY_new()))
Copy link

Choose a reason for hiding this comment

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

Memory leak: The EVP_PKEY allocated in H5PL__RSA_verify_signature is never freed.

snprintf(remove_sig, maxPathLen, "objcopy %s --remove-section=sig", copied_file_name);

/* Execute commands to extract signature from plugin binary */
system(copy_elf_file);
Copy link

Choose a reason for hiding this comment

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

Check and validate all system() call results in H5PL__openssl_verify_signature to mitigate potential command injection and ensure proper error handling.

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: The function name H5PL__openSSL_read_file uses an inconsistent case (openSSL) compared to H5PL__openssl_verify_signature in the following line. Consider renaming it to H5PL__openssl_read_file for consistency.

@brtnfld
Copy link
Collaborator

brtnfld commented Dec 16, 2025

You will also want to add documentation about the feature to the user's guide. I added a task.

Copy link
Collaborator

@brtnfld brtnfld left a comment

Choose a reason for hiding this comment

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

Avoid system calls, and address other issues discussed offline.

@github-project-automation github-project-automation bot moved this from To be triaged to In progress in HDF5 - TRIAGE & TRACK Dec 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

3 participants