--- a/libhdf5/hdf5open.c
+++ b/libhdf5/hdf5open.c
@@ -2336,6 +2336,17 @@
     if (NC_findreserved(att_name))
         return NC_NOERR;
 
+    /* netCDF names are limited to NC_MAX_NAME bytes, and callers of
+     * nc_inq_attname() provide an NC_MAX_NAME + 1 byte buffer. An HDF5
+     * file not written by netCDF may contain longer attribute names;
+     * skip them rather than storing a name that would overflow those
+     * buffers later (CVE-2026-86095). */
+    if (strlen(att_name) > NC_MAX_NAME)
+    {
+        LOG((2, "%s: skipping attribute with name longer than NC_MAX_NAME", __func__));
+        return NC_NOERR;
+    }
+
     /* Add to the end of the list of atts for this var. */
     if ((retval = nc4_att_list_add(list, att_name, &att)))
         BAIL(-1);
