Files
floci/docs
Matheus Oliveira 9b4e27c80a fix(iam): authorize KMS operations against the key named in the request (#6458)
* fix(iam): authorize KMS operations against the key named in the request

KMS is JSON 1.1 posted to /, so the path-based key extraction never
found a key and every action was evaluated against key/*: a policy
allowing kms:Decrypt on one key refused that very key, and a policy
restricted to a key restricted nothing. Enforcement now derives the
request's resources the way the KMS permissions reference gives them:
the key-scoped operations name the key the KeyId member names, resolving
an id, an alias or an ARN to the stored key's own ARN; Decrypt without
a KeyId reads the key out of the CiphertextBlob; the alias operations
name the alias and the keys the alias pages give; CreateKey,
GenerateRandom, ListKeys, ListAliases and ListRetirableGrants stay at *.
A request nothing resolves falls back to key/* so the handler answers
its own NotFoundException. ReEncrypt stays the single action AWS splits
into ReEncryptFrom and ReEncryptTo, evaluated against both keys.

Closes #6256

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): authorize ReEncrypt and the grant operations against the keys they act on

A ReEncrypt without SourceKeyId resolved its source through Decrypt's
reader and trusted a KeyId member ReEncrypt does not even have, so a
caller allowed only on key B could send ciphertext encrypted by a
denied key A, name B everywhere, and get A's data back under B. The
source now resolves the way the handler decrypts: SourceKeyId when the
request names one, otherwise the key the CiphertextBlob itself names.
A RetireGrant carrying only a GrantToken was checked against key/*,
which a key-scoped policy never matches; it now answers the key its
grant belongs to, with the documented key/* fallback for a token nothing
resolves. RevokeGrant and the KeyId-plus-GrantId form of RetireGrant
now name the grant's own key beside the key the request names, so a
pair naming one key while the grant belongs to another can no longer
retire or revoke it.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): resolve a RevokeGrant target by its GrantId, never a GrantToken

The revoke target lookup preferred a GrantToken the RevokeGrant handler
never reads: a request could name the grant of an allowed key in a token
while its GrantId named the grant of a denied one, pass the check on the
token's key, and have the handler revoke the other grant. The lookup now
passes the GrantId alone, so the checked key is the key of the grant the
handler deletes.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(iam): fall back when a CiphertextBlob is not a string

A Decrypt or ReEncrypt carrying a CiphertextBlob that is not a string
made binaryValue answer null on the enforcement path and blow up before
the handler could answer its own client error. A blob that is not text
now names every key the account holds, the documented fallback, so the
request is authorized and the handler answers the error AWS answers for
a malformed blob.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

* fix(kms): share the grant token scan and its enforcement lookup

retireGrant scanned the region's grants for a token the same way the
enforcement lookup did; both now go through one findGrantByToken. The
builder's revoke target resolves through the shared grantKeyArn helper
with the members each handler actually reads, the token and the id for
RetireGrant and the id alone for RevokeGrant, whose handler never reads
a token. The two test javadocs that described the enforcement gap as a
review's finding now describe the gap itself.

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>

---------

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
2026-10-25 21:19:18 -04:00
..
2026-03-15 17:43:56 -05:00