Diagnosing Key Access Failures with IBM Cloud Hyper Protect Crypto Services
A diagnostic guide for 401/403 and key-state failures when calling IBM Cloud Hyper Protect Crypto Services, with ordered IAM, key-ring, and key-lifecycle checks.
07 Nov 2025, 11:57 UTC

Applications that encrypt data with IBM Cloud Hyper Protect Crypto Services (HPCS) typically fail in one of two ways: the caller gets an HTTP 403 when invoking a key operation, or the key itself is in a state that blocks the operation (for example, a deactivated or destroyed key being asked to wrap new data). Both conditions look similar from the application side — an encryption call throws — but the fixes are completely different. This guide helps you separate IAM and policy problems from key-lifecycle problems, then fix the right one.
HPCS is IBM Cloud's managed hardware security module (HSM) offering: key material is generated and used inside FIPS-validated hardware and never leaves the module in plaintext. Because every operation crosses both an IAM authorization check and a key-state check inside the HSM, diagnosis has to cover both layers.
Recognizing the condition
Common symptoms reported by teams integrating HPCS (directly via the Key Protect-compatible API, or indirectly through services like Cloud Object Storage using a customer-managed root key):
- Wrap/unwrap or encrypt/decrypt calls return 401 or 403.
- Calls succeed for some keys but fail for others under the same service ID.
- A previously working integration starts failing after a key rotation or after someone edited IAM policies.
- A dependent service (for example, a COS bucket configured with a customer root key) reports it can no longer read or write objects.
Cause and diagnostic table
| Symptom | Likely cause | First check |
|---|---|---|
| 401 Unauthorized on every call | Expired or invalid IAM access token; wrong endpoint or instance | Confirm the token is fresh and the request targets the correct regional API endpoint for your HPCS instance |
| 403 on all keys in the instance | Service ID or user lacks an IAM policy on the HPCS service instance | List IAM policies for the caller scoped to the HPCS instance |
| 403 on some keys only | Policy scoped to a key ring or specific key set that excludes the target key | Check whether the caller's policy is narrowed by key ring or resource attributes |
| Wrap works, unwrap fails | Caller has a Writer-type role but lacks the Reader/Manager role needed to unwrap or decrypt | Compare assigned role against the operation: wrap vs. unwrap vs. key management actions map to different roles |
| Key exists but operation rejected with a state error | Key is deactivated, suspended, or destroyed (only metadata retained) | Retrieve the key and inspect its state field |
| Dependent service (e.g., COS) lost access after rotation | Service-to-service authorization between the storage service and HPCS was removed, or the root key version changed unexpectedly | Check the service authorization policy and the key's rotation history |
Ordered checks
1. Confirm you are talking to the right instance and region
HPCS instances are regional, and keys are not portable across regions without an explicit export/import process (which itself may violate data-residency policy — treat cross-region key movement as a compliance decision, not a convenience). Verify the instance GUID and regional endpoint in the IBM Cloud console before debugging anything else. A surprising number of 403s are actually requests against the wrong instance.
2. Validate the caller's token and identity
Run these with the IBM Cloud CLI, authenticated as the identity that is failing (or a service ID API key):
# Show which account/identity the CLI is using
ibmcloud target
# Inspect IAM access policies for a service ID
ibmcloud iam service-policies <service-id-name>Look for a policy whose service matches your HPCS instance (service name for the HPCS offering) and whose roles include what the operation needs. As a rule of thumb: Reader permits reading key metadata and unwrap/decrypt operations, Writer adds wrap/encrypt and key creation, and Manager adds administrative actions such as deletion and rotation policy changes. Verify the exact role-to-action mapping against the current IBM Cloud documentation, since role definitions can change.
3. Check for key-ring or resource scoping
If the policy exists but only some keys fail, inspect whether the policy is restricted to a key ring or a resource group narrower than expected. Granting a policy at the whole-instance level for a quick test (in a non-production instance) is a fast way to confirm scoping is the issue — then narrow it back deliberately.
4. Inspect the key's state and rotation status
Retrieve the key through the HPCS key-management API or the console and check:
- State: Active keys can wrap and unwrap. Deactivated keys can typically unwrap (to support reading existing data) but not wrap. Destroyed keys are gone — only metadata remains, and data encrypted solely under that key is unrecoverable.
- Rotation history: confirm the root key version your dependent service expects still exists.
- Deletion date: keys pending deletion may be restorable within the retention window.
5. Check service-to-service authorizations
When a service like Cloud Object Storage uses an HPCS root key, access flows through an IAM service authorization granting the storage service access to the key. List authorizations and confirm one exists between the dependent service and your HPCS instance:
ibmcloud iam authorization-policiesIf the authorization was deleted, recreate it with the minimal role the dependent service needs.
Fixes tied to findings
- Missing IAM policy: create one scoped as narrowly as practical — to the instance, and to a key ring if your design uses them. Avoid account-wide Manager grants on HPCS; broad cryptographic access is a real attack-surface increase, not a theoretical one.
- Wrong role for the operation: add the role that covers unwrap/decrypt rather than elevating to Manager.
- Deactivated key blocking writes: reactivate the key if that matches your intent, or rotate callers to a new active key. Do not reactivate a key that was deactivated for cause (suspected compromise) without a security review.
- Destroyed key: if data was encrypted only under that key, restore from backup. There is no recovery path from the service itself once destruction completes.
- Missing service authorization: recreate the authorization policy and retry a read/write through the dependent service to confirm.
Verifying the fix
After each change, perform a real wrap/unwrap round-trip (or a write-then-read through the dependent service) using the failing identity — not your admin identity. Also review the audit trail: HPCS activity is captured through IBM Cloud Activity Tracker events, so confirm the successful operation appears there with the expected caller identity. That closes the loop for compliance reporting as well.
Escalation criteria
Open an IBM Cloud support case when: the key state shown in the API contradicts your records (for example, a key shows destroyed with no corresponding deletion event in Activity Tracker); FIPS mode status on the instance does not match what your compliance documentation requires; or audit events for cryptographic operations are missing from Activity Tracker entirely. Include the instance GUID, region, key ID, timestamps in UTC, and the exact error response body. Note that exact CLI subcommands and role names for HPCS evolve — verify them against the current IBM Cloud CLI reference before scripting against this guide.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.