fix(bedrock-agentcore): check tag ARNs against the request account (#6802)

ListTagsForResource, TagResource and UntagResource compared the ARN's
account with the configured default account, while the create calls mint
ARNs with the request's account. Any caller outside the default account
was answered ResourceNotFoundException for its own resources.

Compare with the request account instead. An ARN naming another account
or region is still answered ResourceNotFoundException.

Closes #6008
This commit is contained in:
Mohith authored and GitHub committed 2026-10-28 07:13:41 -04:00
1 parent 548788840c
commit ad2089e662
4 files changed
+87 -5

No files matched your search

@@ -76,6 +76,41 @@ class BedrockAgentCoreTaggingIdentityIntegrationTest {
.then().statusCode(404);
}
@Test
void nonDefaultAccountCanTagItsMemoryAndRejectsForeignIdentity() {
String authorization = "AWS4-HMAC-SHA256 Credential=111111111111/20261028/us-east-1/bedrock-agentcore/aws4_request";
String arn = given().header("Authorization", authorization).contentType("application/json")
.body("{\"name\":\"accountTagMem\",\"eventExpiryDuration\":30}")
.when().post("/memories/create").then().statusCode(202).extract().path("memory.arn");
try {
given().header("Authorization", authorization).contentType("application/json")
.body("{\"tags\":{\"env\":\"dev\"}}")
.when().post("/tags/" + arn).then().statusCode(204);
given().header("Authorization", authorization).when().get("/tags/" + arn)
.then().statusCode(200).body("tags.env", equalTo("dev"));
given().header("Authorization", authorization).when().delete("/tags/" + arn + "?tagKeys=env")
.then().statusCode(204);
given().header("Authorization", authorization).when().get("/tags/" + arn)
.then().statusCode(200).body("tags.env", nullValue());
for (String foreign : new String[] {arn.replace(":111111111111:", ":222222222222:"),
arn.replace(":us-east-1:", ":eu-west-1:")}) {
given().header("Authorization", authorization).when().get("/tags/" + foreign)
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
given().header("Authorization", authorization).contentType("application/json")
.body("{\"tags\":{\"env\":\"stolen\"}}")
.when().post("/tags/" + foreign).then().statusCode(404)
.body("__type", equalTo("ResourceNotFoundException"));
given().header("Authorization", authorization).when().delete("/tags/" + foreign + "?tagKeys=env")
.then().statusCode(404).body("__type", equalTo("ResourceNotFoundException"));
}
} finally {
String memoryId = arn.substring(arn.lastIndexOf('/') + 1);
given().header("Authorization", authorization).when().delete("/memories/" + memoryId + "/delete")
.then().statusCode(202);
}
}
@Test
@Order(3)
void workloadIdentityCrud() {