mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(kms): refuse a key or alias ARN that names another account (#7111)
A key or alias ARN naming another account resolved against the caller's own keys, so an alias ARN from account A, used by account B with an alias of the same name, answered with B's key. Floci does not evaluate key policies, so another account's key is never usable: answer NotFoundException with the ARN as given. Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
1 parent
504c9d23bb
commit
b7e96c4be8
2 files changed
+59
-3
No files matched your search
@@ -2258,9 +2258,16 @@ public class KmsService implements ResourceProvider {
|
||||
ensureAwsManagedKeys(region);
|
||||
}
|
||||
if (AwsArnUtils.isArnFor(keyIdOrArn, "kms")) {
|
||||
String arnRegion = AwsArnUtils.parse(keyIdOrArn).region();
|
||||
if (!region.equals(arnRegion)) {
|
||||
throw new AwsException("NotFoundException", "Invalid arn " + arnRegion, 400);
|
||||
AwsArnUtils.Arn arn = AwsArnUtils.parse(keyIdOrArn);
|
||||
if (!region.equals(arn.region())) {
|
||||
throw new AwsException("NotFoundException", "Invalid arn " + arn.region(), 400);
|
||||
}
|
||||
// Floci does not evaluate key policies, so another account's key is never usable here;
|
||||
// without this the store would answer with the caller's own key or alias of that name.
|
||||
if (!arn.accountId().equals(regionResolver.getAccountId())) {
|
||||
throw new AwsException("NotFoundException", arn.resource().startsWith("alias/")
|
||||
? "Alias " + keyIdOrArn + " is not found."
|
||||
: "Key '" + keyIdOrArn + "' does not exist", 400);
|
||||
}
|
||||
}
|
||||
String id = keyIdOrArn;
|
||||
|
||||
Reference in new issue
Block a user