Skip to content

fix(hsm): support strict-template HSMs - #7068

Merged
varonix0 merged 2 commits into
mainfrom
daniel/hsm-strict-fix
Jun 29, 2026
Merged

varonix0 merged 2 commits into
mainfrom
daniel/hsm-strict-fix

Conversation

@varonix0

Copy link
Copy Markdown
Member

Context

Adds explicit-false usage attributes (CKA_WRAP/UNWRAP/DERIVE, and CKA_SIGN/VERIFY on AES and CKA_ENCRYPT/DECRYPT on HMAC) to both generate templates so HSMs with strict template validation no longer reject key creation with CKR_TEMPLATE_INCONSISTENT. Also relaxes the HMAC find to match on class + label only so vendor-specific generic-secret subtypes (e.g. nShield's CKK_SHA256_HMAC) are accepted. AES stays pinned to CKK_AES.

Type

  • Fix
  • Feature
  • Improvement
  • Breaking
  • Docs
  • Chore

Checklist

  • Title follows the conventional commit format: type(scope): short description (scope is optional, e.g., fix: prevent crash on sync or fix(api): handle null response).
  • Tested locally
  • Updated docs (if needed)
  • Updated CLAUDE.md files (if needed)
  • Read the contributing guide

@varonix0
varonix0 marked this pull request as ready for review June 29, 2026 13:29
@infisical-review-police

Copy link
Copy Markdown

💬 Discussion in Slack: #pr-review-infisical-7068-fix-hsm-support-strict-template-hsms

Posted by Review Police — reviews, comments, new commits, and CI failures will stream into this channel.

@varonix0 varonix0 self-assigned this Jun 29, 2026
@greptile-apps

greptile-apps Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR improves HSM compatibility by adding explicit false values for inapplicable usage attributes on both AES and HMAC key generation templates (fixing CKR_TEMPLATE_INCONSISTENT on strict-template HSMs), and relaxing the HMAC key search to match on CKA_CLASS + CKA_LABEL only to support vendor-specific generic-secret subtypes like nShield's CKK_SHA256_HMAC.

Confidence Score: 4/5

The change is a targeted compatibility fix with no new control paths or external data flows; the relaxed HMAC key search is intentional and the label is distinctive enough for normal deployments.

Both the AES and HMAC template additions are additive false-attribute declarations that follow PKCS#11 spec and do not alter the keys' functional properties. The relaxed HMAC find trades search precision for HSM portability, which is the stated goal and is well-commented. The only minor risk is the broader HMAC label-only search silently matching an unintended key if label collisions exist on the HSM, but this is an unlikely operational scenario.

backend/src/ee/services/hsm/hsm-service.ts — specifically the relaxed HMAC $findKey template.

Important Files Changed

Filename Overview
backend/src/ee/services/hsm/hsm-service.ts Adds explicit false attributes to AES and HMAC key generation templates for strict-template HSM compatibility; relaxes HMAC find query to match on class+label only to support vendor-specific key subtypes (e.g. nShield CKK_SHA256_HMAC).

Reviews (1): Last reviewed commit: "Update hsm-service.ts" | Re-trigger Greptile

Comment thread backend/src/ee/services/hsm/hsm-service.ts

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4a8f510245

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread backend/src/ee/services/hsm/hsm-service.ts
@varonix0
varonix0 merged commit 87b727c into main Jun 29, 2026
13 checks passed
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.

2 participants