Skip to content

kms: CustomerMasterKeySpec is a CreateKey request parameter too, so an older-SDK caller asking for RSA_4096 silently gets a symmetric key #985

Closed

Description

@scttfrdmn

CustomerMasterKeySpec is a request parameter on CreateKey, not only a response member, and substrate decodes only the response half. So a caller using an SDK old enough to still send the deprecated name asks for an RSA_4096 key and silently gets a symmetric one — with KeySpec: "SYMMETRIC_DEFAULT" in the response it reads back.

Found while verifying API_CreateKey for #977. #974 answered the response member; this is its request-side twin, and it is the more consequential of the two, because a wrong response member misinforms a caller while a wrong request member hands them a key of the wrong type.

What substrate does today

createKey (emulator/kms_plugin.go) decodes KeySpec and nothing else in that family:

if input.KeySpec == "" {
	input.KeySpec = kmsSymmetricDefaultKeySpec
}

A request body of {"CustomerMasterKeySpec": "RSA_4096"} therefore leaves KeySpec empty, the default fires, and the key is symmetric. Every downstream observation follows from that one silent substitution: Encrypt succeeds where the caller expected it to be unavailable, Sign refuses, GetPublicKey has nothing to answer, and #974's builder reports EncryptionAlgorithms where the caller expected SigningAlgorithms.

The failure is quiet in the worst way — a 200 with a complete, well-formed KeyMetadata whose CustomerMasterKeySpec (which #974 now emits) reads SYMMETRIC_DEFAULT, i.e. substrate echoes the deprecated member back with a value contradicting the one it was sent.

What AWS publishes

API_CreateKey's Request Parameters list CustomerMasterKeySpec alongside KeySpec, Type String, Valid Values the same 13 as its response counterpart:

RSA_2048 | RSA_3072 | RSA_4096 | ECC_NIST_P256 | ECC_NIST_P384 | ECC_NIST_P521 | ECC_SECG_P256K1 | SYMMETRIC_DEFAULT | HMAC_224 | HMAC_256 | HMAC_384 | HMAC_512 | SM2

— four fewer than KeySpec's 17, the four post-deprecation specs (ML_DSA_44, ML_DSA_65, ML_DSA_87, ECC_NIST_EDWARDS25519) being absent for the reason #974 already recorded on the response side.

The parameter is marked deprecated with the same sentence the response member carries — "the KeySpec and CustomerMasterKeySpec fields have the same value… to avoid breaking changes, AWS KMS supports both fields" — which is exactly why it must be decoded rather than treated as obsolete: AWS still accepts it, so a caller sending it is not doing anything wrong.

API_CreateKey publishes no ValidationException. The code for a conflicting or malformed value has to be chosen and recorded, the same open question #977 carries; ValidationError/400 from CommonErrors.html is the in-tree precedent (#969).

What needs deciding

AWS does not document what happens when both members are sent with different values. The available readings:

  1. Refuse the conflict. The two members are documented to have the same value, so disagreeing values are a malformed request. Most defensible, and it cannot silently mislead.
  2. KeySpec wins. The newer member takes precedence and the deprecated one is ignored when both are present.
  3. Last-writer-wins by JSON order — not a real option; it makes the answer depend on member order in a JSON object, which is not a thing a caller controls meaningfully.

Reading 1 is the recommendation, with the code stated as substrate's reading since AWS publishes none for it.

Also to decide: a CustomerMasterKeySpec value outside its own 13 — ML_DSA_44, say, which is valid under KeySpec and not under this member. Refusing it is the narrow reading and matches what #974 does on the response side, where such a key omits the member entirely rather than reporting a value outside its published set.

Relationship to #977

#977 validates KeySpec and KeyUsage against their published enums, and this issue adds a third member to the same validation surface with a narrower enum than the one beside it. They touch the same handler and the same decision about which error code a malformed enum member gets. Either land this inside #977, or land it immediately after and reuse whatever code #977 settles on — what must not happen is two different codes for the same class of malformed input on one operation.

Acceptance criteria

Activity

  1. added this to the v0.119.0 milestone on Sep 17, 2026
  2. added
    type: bug
    on Sep 17, 2026
  3. modified the milestones: v0.119.0, v0.118.0 on Sep 17, 2026
  4. scttfrdmn commented on Sep 17, 2026

    @scttfrdmn
    OwnerAuthor

    Shipped in #987, merged to main at 135fb40, and moved from v0.119.0 to v0.118.0 — the milestone should name the release the work actually appears in, and this landed inside the v0.118.0 cycle rather than being deferred past it.

    The move was not a scheduling convenience. This issue's own instruction was "either land this inside #977, or land it immediately after and reuse whatever code #977 settles on — what must not happen is two different codes for the same class of malformed input on one operation." #977 is a v0.118.0 issue, so honouring that instruction meant landing here too; leaving the milestone at v0.119.0 would have recorded the opposite of what happened, with the two halves of one validation surface split across two releases.

    What shipped:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions