azure-containerapps-execute-as-via-sessionpool

Executing code in a custom-container session that binds a reachable MI => execute as that MI (read the identity endpoint from the session).

derived azure emits CanExecuteAs

match

A conjunctive graph pattern. Variables (?x) bind node ids; every clause must hold.

{'principal': None} CanExecuteCommand {'pool': None} {'pool': None} ExecutesAs {'mi': None}

where

node_type(?pool) == ContainerService ?mi.privilege_level > ?principal.privilege_level # strict escalation only (equal-privilege lateral excluded) ?mi reachable from the session container (identitySettings.lifecycle in [All, Main] or unset)

emit

source typeIdentity
target typeIdentity
source<principal>
target<managed identity>
permissionsMicrosoft.App/sessionPools/executeSessionCommand/action
conditionsservice_state
state logicACTIVE if a session is allocated/ready; else CONDITIONAL(service_state) until a session is allocated

Narrative

{principal.name} can execute code in a session of pool {pool.name} and mint the token of its identity {mi.name} from the local identity endpoint, executing as {mi.name}.

Raw rule rules/derived/azure/containerapps.yaml

id: azure-containerapps-execute-as-via-sessionpool
emits: CanExecuteAs
description: Executing code in a custom-container session that binds a reachable MI => execute as that
  MI (read the identity endpoint from the session).
match:
- - principal: null
  - CanExecuteCommand
  - pool: null
- - pool: null
  - ExecutesAs
  - mi: null
where:
- node_type(?pool) == ContainerService
- '?mi.privilege_level > ?principal.privilege_level   # strict escalation only (equal-privilege lateral
  excluded)'
- ?mi reachable from the session container (identitySettings.lifecycle in [All, Main] or unset)
emit:
  source_type: Identity
  target_type: Identity
  source: <principal>
  target: <managed identity>
  conditions:
  - service_state
  state_logic: ACTIVE if a session is allocated/ready; else CONDITIONAL(service_state) until a session
    is allocated
  conditions_from:
  - pool: null
  - mi: null
  permissions:
  - Microsoft.App/sessionPools/executeSessionCommand/action
  derived_from:
  - <CanExecuteCommand edge_id>
  - <ExecutesAs edge_id>
  false_positive_note: Requires the session-execute DATA ACTION AND a custom-container pool that binds
    an MI reachable from session code. Escalation only if the MI out-privileges the caller. If session
    pools cannot bind a reachable MI, this rule never fires (the ExecutesAs fact is absent).
  narrative: '{principal.name} can execute code in a session of pool {pool.name} and mint the token of
    its identity {mi.name} from the local identity endpoint, executing as {mi.name}.'
move · open · esc close