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

@@ -1,7 +1,7 @@
package io.github.hectorvent.floci.services.bedrockagentcorecontrol;
import io.github.hectorvent.floci.config.EmulatorConfig;
import io.github.hectorvent.floci.core.common.AwsException;
import io.github.hectorvent.floci.core.common.RegionResolver;
import io.github.hectorvent.floci.core.common.TagHandler;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
@@ -21,17 +21,17 @@ public class BedrockAgentCoreTagHandler implements TagHandler {
private final BedrockAgentCoreControlService runtimeService;
private final BedrockAgentCoreGatewayService gatewayService;
private final BedrockAgentCoreMemoryService memoryService;
private final EmulatorConfig config;
private final RegionResolver regionResolver;
@Inject
public BedrockAgentCoreTagHandler(BedrockAgentCoreControlService runtimeService,
BedrockAgentCoreGatewayService gatewayService,
BedrockAgentCoreMemoryService memoryService,
EmulatorConfig config) {
RegionResolver regionResolver) {
this.runtimeService = runtimeService;
this.gatewayService = gatewayService;
this.memoryService = memoryService;
this.config = config;
this.regionResolver = regionResolver;
}
@Override
@@ -96,7 +96,7 @@ public class BedrockAgentCoreTagHandler implements TagHandler {
* validation error, so the response does not confirm what exists behind the foreign identity.
*/
private void requireLocalIdentity(String region, String arn, String[] parts) {
if (!region.equals(parts[3]) || !config.defaultAccountId().equals(parts[4])) {
if (!region.equals(parts[3]) || !regionResolver.getAccountId().equals(parts[4])) {
throw new AwsException("ResourceNotFoundException",
"AgentCore resource not found: " + arn, 404);
}