Skip to content

fix(aps): check Amazon Managed Service for Prometheus requests under IAM enforcement - #9085

Open
mrfelek wants to merge 3 commits into
floci-io:mainfrom
mrfelek:fix/aps-iam-enforcement-v2
Open

mrfelek wants to merge 3 commits into
floci-io:mainfrom
mrfelek:fix/aps-iam-enforcement-v2

Conversation

@mrfelek

@mrfelek mrfelek commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Under IAM enforcement, no Amazon Managed Service for Prometheus request was checked. botocore's amp model wasn't among the vendored REST routes and the aps namespace's request resources weren't read, so no request mapped to an action and every call went through: CreateWorkspace, DeleteWorkspace, the rule groups namespace calls, TagResource.

amp is now vendored by regen_rest_routes.py (its 44 routes, under the aps scope), and the request-resources, tag-on-create and passed-role generators read aps, the way #8518 did for S3 Vectors. Nothing in IAM is written by hand for it:

  • A workspace call is checked on the workspace its path's workspaceId names, arn:aws:aps:<region>:<account>:workspace/<id>, the ARN ApsService already mints.
  • A rule groups namespace call is checked on the namespace its workspaceId and name give, .../rulegroupsnamespace/<workspaceId>/<name>, and ListRuleGroupsNamespaces on its workspace.
  • CreateWorkspace and ListWorkspaces act on no resource type, so they are checked on *.
  • A create that tags what it makes (CreateWorkspace, CreateRuleGroupsNamespace) also needs aps:TagResource, with its tags as aws:RequestTag/<key> and aws:TagKeys, as the Service Reference lists.
  • Floci tags AMP's workspaces and namespaces through the shared tags controller, so amp joins Control Tower, FIS, Resource Explorer and Signer in SHARED_ROUTES: a tag call is checked on the ARN it names whether the ARN is encoded in the path, sent with its slashes unencoded, or given in the body or query of the bare /tags.
  • CreateScraper and UpdateScraper pass the roles in roleConfiguration.sourceRoleArn and targetRoleArn, which the passed-role table now lists. Floci doesn't serve scrapers yet.

A commit of its own first regenerates the authorized-action, passed-role and tag-on-create tables, which picks up what the Service Reference changed since they were generated on 2026-11-16: Glue's ListIntegrationTableProperties and Lambda's ListRuntimes act on no resource type; logs:PutIntegration passes a role, and so do Glue's CreateDataQualityEvaluationConfig and UpdateDataQualityEvaluationConfig, which the pinned botocore doesn't have yet; the tag-on-create table gains EC2's CreateTransitGatewayNetworkFunctionAttachment, Glue's CreateDataQualityEvaluationConfig, Kinesis's CreateChannel and CreateQueue and SageMaker's CreateInferenceRouter, and kinesisanalytics:CreateSnapshot and lambda:CreateRuntime take the request's tags; among the namespaces not read, continuum joins and appstream leaves, the reference no longer giving any AppStream operation a passed role or a tagging action. Leaving them out would mean editing the generated tables by hand, and the AMP commit's diff is then AMP's alone.

The reference now also lists iam:PassRole for WAF v2's CreateWebACL and UpdateWebACL, so a plain regeneration fails PassedRoleNamespacesIntegrationTest: Floci serves wafv2, which the passed-role generator neither read nor named as not read. That commit adds wafv2 to its NAMESPACES and names both operations in NOT_READ as passing a role no member of their request names (NO_ROLE_MEMBER, as for dms:CreateInstanceProfile): neither request has a member naming a role in botocore's model, the pinned 1.43.118 or the latest 1.44.4.

EmrServerlessIamIntegrationTest, Route53HostedZonesIamEnforcementIntegrationTest, S3TablesIamIntegrationTest and S3VectorsIamIntegrationTest each kept the same private allow(actions, resource) policy that this test would have copied a fifth time. It is now IamTestPolicies.allow, in a commit of its own.

Not in this PR, each a follow-up:

  • Resource tags: a condition on aws:ResourceTag has no value to match yet, since AMP gives IAM no stored tags: there is no StoredResourceArns for aps, so an allow or a deny conditioned on a workspace's or a namespace's tags doesn't match it. Giving it one, as fix(s3tables): give resource-tag conditions the tags of the bucket or table a request names #8505 did for S3 Tables after fix(s3tables): check S3 Tables requests under IAM enforcement #8424, is the next PR.
  • Collection calls: AWS checks ListWorkspaces and CreateWorkspace, and the aps:TagResource of a CreateWorkspace with tags, on arn:aws:aps:<region>:<account>:/workspaces, not on *: a policy allowing aps:ListWorkspaces on that ARN lets the call through, one on workspace/* doesn't, and one on * does (measured). Floci checks them on *, so only a policy whose resource matches * allows them there, and its denial names *. /workspaces is the ARN format of no resource type the Service Reference gives aps, so the request-resources generator's MEASURED table, which gives dsql:ListClusters its cluster/*, can't give it either; #9039 covers such calls across services.
  • Scrapers: CreateScraper names its workspace and EKS cluster only inside destination and source, which the request-resources table doesn't read, so it is checked on *, and UpdateScraper on its scraper but not on its destination workspace. Floci doesn't serve scrapers, alert manager definitions, logging configurations, anomaly detectors or resource policies; their routes are vendored with the rest.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

Amazon Managed Service for Prometheus authorizes each operation as aps:<Operation> on the workspace or rule groups namespace it names, as the Service Authorization Reference lists, and a create with tags also as aps:TagResource. Measured on AWS (us-east-1, 2026-11-19, as a role made for the probe and deleted afterwards): a caller without permissions is refused ListWorkspaces, CreateWorkspace and DescribeWorkspace with HTTP 403 AccessDeniedException, "User: is not authorized to perform: aps: on resource: because no identity-based policy allows the aps: action", DescribeWorkspace naming arn:aws:aps:us-east-1:<account>:workspace/<id>; and a caller allowed aps:CreateWorkspace alone is refused a CreateWorkspace with tags, naming aps:TagResource, with no workspace created.

Checklist

  • ./mvnw test: the full suite passes on Temurin 25 in CI's five shards (79,269 tests), with checkstyle. IamRestRouteCoverageTest and the three tables' members and namespaces tests (RequestResourceMembersTest, RequestResourceNamespacesIntegrationTest, TagOnCreateMembersTest, TagOnCreateNamespacesIntegrationTest, PassedRoleMembersTest, PassedRoleNamespacesIntegrationTest) pass with the new namespace.
  • New or updated tests added: ApsIamIntegrationTest, under SignedIamEnforcementProfile, with its six tests failing on main at the first refusal each expects (Expected status code <403> but was <200>, or <202> for a create):
    • A caller is refused DescribeWorkspace without a policy, allowed it once a policy allows it on the workspace's ARN, and refused again once that policy is deleted.
    • A caller without permissions is refused CreateWorkspace, ListWorkspaces and DeleteWorkspace; nothing is created and the workspace stays.
    • An allow on one workspace's ARN describes it, changes its alias and lists its namespaces. The same user is refused those calls on another workspace, and DeleteWorkspace.
    • An allow on rulegroupsnamespace/<workspaceId>/* describes, replaces and creates namespaces in that workspace. The same user is refused them in another workspace, and DeleteRuleGroupsNamespace.
    • A user allowed CreateWorkspace and CreateRuleGroupsNamespace, and aps:TagResource only for aws:RequestTag/team metrics, is refused both creates with the tag team=logs, naming aps:TagResource, and neither the workspace nor the namespace is created. Both creates pass with team=metrics.
    • An allow of TagResource and ListTagsForResource on one workspace's ARN tags it by an encoded ARN, an unencoded ARN and the bare /tags. The same user is refused tagging another workspace each of those ways, listing its tags, and UntagResource; the other workspace keeps no tag.
    • test_regen_rest_routes.py checks the shared tags routes of amp as those of the other four models.
  • Commit messages follow Conventional Commits
  • I have no more than 2 open, non-draft pull requests and no more than 4 open pull requests in total (drafts included) in this repository (maintainers and dependency bots are exempt).

EmrServerlessIamIntegrationTest, Route53HostedZonesIamEnforcementIntegrationTest,
S3TablesIamIntegrationTest and S3VectorsIamIntegrationTest each built
the same identity policy, one or more actions allowed on one resource,
in a private allow(actions, resource). It is now IamTestPolicies.allow,
and the four tests use it.
The generators give what the Service Reference changed since the tables
were last generated: Glue's ListIntegrationTableProperties and Lambda's
ListRuntimes act on no resource type; logs:PutIntegration passes a role,
and so do Glue's CreateDataQualityEvaluationConfig and
UpdateDataQualityEvaluationConfig, which the pinned botocore doesn't
have yet; the tag-on-create table gains EC2's
CreateTransitGatewayNetworkFunctionAttachment, Glue's
CreateDataQualityEvaluationConfig, Kinesis's CreateChannel and
CreateQueue and SageMaker's CreateInferenceRouter, and
kinesisanalytics:CreateSnapshot and lambda:CreateRuntime take the
request's tags. Among the namespaces not read, continuum joins and
appstream leaves, the reference no longer giving any AppStream
operation a passed role or a tagging action.

The reference now also lists iam:PassRole for WAF v2's CreateWebACL and
UpdateWebACL, which PassedRoleNamespacesIntegrationTest requires the
passed-role generator to read or name as not read, since Floci serves
WAF v2. It reads wafv2, and names both operations as passing a role no
member of their request names: botocore's model, the pinned release and
the latest one alike, has no member naming a role in either request.
…IAM enforcement

Under IAM enforcement no Amazon Managed Service for Prometheus request
was checked: botocore's amp model was not among the vendored REST routes
and the aps namespace's request resources were not read, so no request
mapped to an action and every call went through. regen_rest_routes.py
now vendors its routes, and the request-resources, tag-on-create and
passed-role generators read the namespace, so a workspace call is
checked on the workspace its path names, a rule groups namespace call on
the namespace its workspace and name give, CreateWorkspace and
ListWorkspaces on *, and a create that tags what it makes also as
aps:TagResource. Floci tags AMP's resources through the shared tags
controller, so amp joins SHARED_ROUTES: a tag call is checked on the ARN
it names, sent encoded or unencoded in the path or in the bare /tags.
Nothing in IAM is written by hand for it.
@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR Summary by Qodo

Enforce IAM permissions for Amazon Managed Prometheus requests

🐞 Bug fix 🧪 Tests ⚙️ Configuration changes 🕐 40+ Minutes

Grey Divider

AI Description

• Check APS requests against operation permissions and workspace or namespace resources instead of
 letting them through unchecked.
• Enforce tagging permissions on tagged creates and authorize tag calls against their target ARN.
• Regenerate IAM metadata and add signed-request tests covering denials, scoped access, and tagging.
Merge Risk 🟡 Medium

Blast radius 🔴 High 💥 2 capabilities

  • 2 affected capabilities span independent functional scopes: APS service IAM integration, shared IAM authorization integration for supported service APIs.
  • The route table, APS ARN/resource metadata, tag-on-create metadata, and passed-role metadata jointly govern the end-to-end authorization of APS workspace, namespace, scraper, and tag operations.
  • These are distinct API operations but one bounded APS integration; the generated tables are propagation hops, not separate capabilities.
  • This is the same bounded APS end-to-end authorization capability; denial is a separate consequence of the same originating metadata fault, not a separate technical capability.
  • The changed generated resources are consumed by the common IAM enforcement path, but their affected end-to-end behaviors include independent service integrations such as Glue, Kinesis, Lambda, Logs, and WAFv2.
  • They are grouped here because the PR changes one shared integration contract while preserving the service-specific operation paths.
  • A false denial affects the same shared IAM integration capability and is separated only because its recovery and consequence differ from an authorization bypass.
Behavioral complexity 🟡 Medium 🧩 Multiple interactions

  • Before: APS requests were not represented in the shared generated REST route and IAM metadata.
  • After: method/path/query matching, path-label extraction, alternative encoded/bare ARN locations, workspace-versus-child ARN construction, tag-on-create checks, and two-role PassRole checks participate in one authorization decision.
  • New correctness conditions: the selected operation must agree with the actual route, every path/body/query representation must identify the same resource, child resources must remain scoped to their workspace, and create-time tag and role checks must be applied only when the invocation carries those effects.
  • The route matcher itself is established infrastructure, but the PR introduces a new model and new compatibility alternatives into it.
Potential damage 🔴 High 🩹 Confidentiality

  • If a resource path or ARN mapping is too broad, a caller with permission on one workspace or namespace could access or mutate another resource.
  • If the mapping is too narrow or the route selects the wrong action, legitimate APS operations fail instead.
  • The confidentiality/integrity failure is confined to APS resources; no evidence shows that APS metadata changes unrelated service authorization.
  • A code or metadata rollback restores the prior authorization behavior, but any unauthorized operation performed while the fault is active is not automatically undone.
  • Recovery requires identifying affected APS resources and compensating for external state changes or reviewing access logs.
Assessed commit 6bef1cf
Diagram

graph TD
  G["AWS generators"] --> R["REST routes"] --> M["Signed route matching"] --> Q["Request resources"] --> I["IAM evaluation"] --> H["APS handlers"]
  G --> T["Tag and role rules"] --> I
Loading
High-Level Assessment

Extending the existing generated REST and IAM metadata pipeline is the appropriate approach. Hand-written APS authorization was considered but would duplicate shared routing and resource logic and drift from the Service Reference.

Files changed (16) +408 / -46

Bug fix (6) +119 / -14
iam-request-resources.jsonGenerate APS resource authorization rules +48/-4

Generate APS resource authorization rules

• Adds APS ARN formats and operation rules that resolve workspaces, rule groups namespaces, scrapers, and other applicable resources from request inputs. Resource-independent operations use no resource, while tag operations read their target ARN.

src/main/resources/aws/iam-request-resources.json

iam-tag-on-create.jsonRequire APS tagging permission on tagged creates +15/-6

Require APS tagging permission on tagged creates

• Adds generated 'aps:TagResource' requirements and request-tag extraction for tagged APS creates. Regeneration also incorporates newer EC2, Glue, Kinesis, Lambda, and SageMaker tagging entries.

src/main/resources/aws/iam-tag-on-create.json

rest-routes.jsonVendor AMP routes under the APS credential scope +51/-0

Vendor AMP routes under the APS credential scope

• Adds 44 AMP operations with their methods and paths so signed requests can map to APS IAM actions. Tag operations include bare '/tags' alternatives that locate the ARN in the body or query.

src/main/resources/aws/rest-routes.json

regen_iam_request_resources.pyDerive APS request resources from REST routes +1/-2

Derive APS request resources from REST routes

• Moves APS from the uncovered REST namespaces into the request-resource generator's covered namespaces.

tools/aws/regen_iam_request_resources.py

regen_iam_tag_on_create.pyDerive APS creation-tag permissions +2/-2

Derive APS creation-tag permissions

• Moves APS into the covered namespaces so its tagged creates receive generated tagging rules.

tools/aws/regen_iam_tag_on_create.py

regen_rest_routes.pyGenerate AMP routes and recognize shared tag endpoints +2/-0

Generate AMP routes and recognize shared tag endpoints

• Maps botocore's 'amp' model to the 'aps' credential scope. Adds its tag operations to shared-route handling so the common tags controller's requests can be authorized.

tools/aws/regen_rest_routes.py

Tests (7) +256 / -23
ApsIamIntegrationTest.javaExercise APS IAM enforcement with signed requests +240/-0

Exercise APS IAM enforcement with signed requests

• Tests default denial, policy changes, workspace and namespace resource scoping, and rejection before unauthorized mutations. Also tests tag-on-create conditions and encoded, unencoded, and bare tag routes against allowed and disallowed ARNs.

src/test/java/io/floci/aws/services/aps/ApsIamIntegrationTest.java

EmrServerlessIamIntegrationTest.javaReuse the shared IAM allow-policy fixture +1/-5

Reuse the shared IAM allow-policy fixture

• Replaces this test's duplicate allow-policy builder with 'IamTestPolicies.allow'.

src/test/java/io/floci/aws/services/emrserverless/EmrServerlessIamIntegrationTest.java

Route53HostedZonesIamEnforcementIntegrationTest.javaReuse the shared IAM allow-policy fixture +1/-6

Reuse the shared IAM allow-policy fixture

• Removes the hosted-zone test's private policy builder in favor of 'IamTestPolicies.allow'.

src/test/java/io/floci/aws/services/route53/Route53HostedZonesIamEnforcementIntegrationTest.java

S3TablesIamIntegrationTest.javaReuse the shared IAM allow-policy fixture +1/-5

Reuse the shared IAM allow-policy fixture

• Uses 'IamTestPolicies.allow' instead of constructing the same identity policy locally.

src/test/java/io/floci/aws/services/s3tables/S3TablesIamIntegrationTest.java

S3VectorsIamIntegrationTest.javaReuse the shared IAM allow-policy fixture +1/-5

Reuse the shared IAM allow-policy fixture

• Replaces a duplicate allow-policy method with the shared test utility.

src/test/java/io/floci/aws/services/s3vectors/S3VectorsIamIntegrationTest.java

IamTestPolicies.javaProvide a reusable scoped allow-policy helper +11/-1

Provide a reusable scoped allow-policy helper

• Adds 'allow(actions, resource)' for IAM service tests granting one or several actions on a resource.

src/test/java/io/floci/aws/testing/IamTestPolicies.java

test_regen_rest_routes.pyCover AMP shared tag-route generation +1/-1

Cover AMP shared tag-route generation

• Adds AMP to the parameterized test for shared tag endpoints and their alternative ARN locations.

tools/aws/test_regen_rest_routes.py

Other (3) +33 / -9
iam-authorized-actions.jsonRefresh resource-independent authorized actions +9/-1

Refresh resource-independent authorized actions

• Adds APS operations authorized on '*', including workspace creation and listing. Also picks up Glue and Lambda actions from the newer Service Reference.

src/main/resources/aws/iam-authorized-actions.json

iam-passed-roles.jsonRecord APS scraper roles and refreshed pass-role metadata +20/-5

Record APS scraper roles and refreshed pass-role metadata

• Adds the source and target roles supplied by APS scraper requests. Regeneration also adds Logs and Glue entries and records WAF v2 operations whose requests expose no role member.

src/main/resources/aws/iam-passed-roles.json

regen_iam_passed_roles.pyInclude APS when deriving passed roles +4/-3

Include APS when deriving passed roles

• Moves APS into the covered namespaces now that its REST routes are vendored. Also includes WAF v2 and documents that its listed WebACL operations expose no role member.

tools/aws/regen_iam_passed_roles.py

@qodo-code-review

qodo-code-review Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)

Grey Divider


Remediation recommended

1. Collection calls ignore their ARN ✗ Dismissed
Description
The request-resources table reads aps ("aps": ["amp"]), but aps:ListWorkspaces and
aps:CreateWorkspace still resolve to the literal * because the measurement mechanism was not
extended to the /workspaces ARN that AWS checks. A policy scoped to workspace/* is refused here
though AWS would allow it, and a policy on * is allowed here though AWS would not, and the PR
discloses this as a follow-up tied to #9039.

Grey Divider

Context sources
✅ Linked PRs:
  🌐 PR #8518
  🌐 PR #8505
  🌐 PR #8424
✅ Compliance rules (platform): 21 rules
✅ Cross-repo context — repo relationships
  Explored: repo: floci-io/testcontainers-floci (sha: e900a79e) — View relationship
  Explored: repo: floci-io/floci-ui (sha: 11c808ad) — View relationship
✅ Context preparation
  Commit messages: summarized; full text retained for this review
Review mode: Auto: ⚖️ Balanced: Standard: security-sensitive IAM changes, but tests cover the main paths.

Grey Divider

Tip of the day
💡 Did you know, you can turn on the rule miner and Qodo learns your standards from review history

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@pgermosen pgermosen added aps Amazon Managed Service for Prometheus (APS) bug Something isn't working iam AWS Identity and Access Management (IAM) labels Nov 20, 2026

@pgermosen pgermosen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mrfelek thanks, vendoring amp and reading aps in the three generators checks each workspace and namespace call on the ARN ApsService mints, and the probe matches.

  • Adding amp to SHARED_ROUTES makes Floci serve and authorize its tagging on the bare /tags and on an unencoded ARN, which AWS does not have. With aps now read, TagDispatcher.resolveHandler(arn, uriInfo) already serves it on its model's /tags/{resourceArn} alone and refuses the rest with the existing 400, as for S3 Vectors, so the entry can go and the tagging test can expect that 400 for the other two forms.
  • The regeneration of the other services' tables, wafv2 with it, is a change of its own; could it go first as its own PR?
  • iam-request-resources.json now conflicts with main after #9074, so it needs a rebase and a regeneration.

@pgermosen pgermosen added the waiting-author Review posted; waiting on the PR author to respond label Nov 20, 2026

This branch has not been deployed

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

Labels

aps Amazon Managed Service for Prometheus (APS) bug Something isn't working iam AWS Identity and Access Management (IAM) waiting-author Review posted; waiting on the PR author to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants