azure-containerapps-execute-as-via-attach-mi
Attach a privileged user-assigned MI to a controlled/new app or job, run it, and execute as the MI.
match
A conjunctive graph pattern. Variables (?x) bind node ids; every clause must hold.
where
?principal can run/deploy the app (Microsoft.App/containerApps/write to create a revision, or Microsoft.App/jobs/start/action for a job)
?userMI.privilege_level > ?principal.privilege_level # strict escalation only (equal-privilege lateral excluded)
emit
| source type | Identity |
|---|---|
| target type | Identity |
| source | <principal> |
| target | <user-assigned managed identity> |
| permissions | Microsoft.ManagedIdentity/userAssignedIdentities/assign/action Microsoft.App/containerApps/write |
| conditions | role_compatibility |
Narrative
{principal.name} can attach user-assigned MI {userMI.name} to a Container App/job it can run, executing as {userMI.name}.
Raw rule rules/derived/azure/containerapps.yaml
id: azure-containerapps-execute-as-via-attach-mi
emits: CanCreateWorkloadAs
description: Attach a privileged user-assigned MI to a controlled/new app or job, run it, and execute
as the MI.
match:
- - principal: null
- CanAttachIdentity
- app: null
where:
- ?principal can run/deploy the app (Microsoft.App/containerApps/write to create a revision, or Microsoft.App/jobs/start/action
for a job)
- '?userMI.privilege_level > ?principal.privilege_level # strict escalation only (equal-privilege lateral
excluded)'
emit:
source_type: Identity
target_type: Identity
source: <principal>
target: <user-assigned managed identity>
permissions:
- Microsoft.ManagedIdentity/userAssignedIdentities/assign/action
- Microsoft.App/containerApps/write
conditions:
- role_compatibility
derived_from:
- <CanAttachIdentity edge_id>
false_positive_note: Requires the attach chain (assign/action + app/job write) AND the ability to run
the workload. Escalation only if the attached MI out-privileges the caller.
narrative: '{principal.name} can attach user-assigned MI {userMI.name} to a Container App/job it can
run, executing as {userMI.name}.'