azure-batch-execute-as-via-task

Submit a data-plane task + the pool runs as an MI => execute as that MI (via IMDS).

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) in [ContainerCluster, BatchJob] ?mi.privilege_level >= ?principal.privilege_level

emit

source typeIdentity
target typeIdentity
source<principal>
target<user-assigned managed identity>
permissionsMicrosoft.Batch/batchAccounts/jobs/write
state logicif ?pool has active nodes: ACTIVE else: CONDITIONAL(service_state)

Narrative

{principal.name} can submit a task to pool {pool.name} (jobs/write or shared key) whose commandLine mints the token of its identity {mi.name} from IMDS, executing as {mi.name}.

Raw rule rules/derived/azure/batch.yaml

id: azure-batch-execute-as-via-task
emits: CanExecuteAs
description: Submit a data-plane task + the pool runs as an MI => execute as that MI (via IMDS).
match:
- - principal: null
  - CanExecuteCommand
  - pool: null
- - pool: null
  - ExecutesAs
  - mi: null
where:
- node_type(?pool) in [ContainerCluster, BatchJob]
- ?mi.privilege_level >= ?principal.privilege_level
emit:
  source_type: Identity
  target_type: Identity
  source: <principal>
  target: <user-assigned managed identity>
  state_logic: 'if ?pool has active nodes: ACTIVE

    else: CONDITIONAL(service_state)

    '
  conditions_from:
  - pool: null
  - mi: null
  permissions:
  - Microsoft.Batch/batchAccounts/jobs/write
  derived_from:
  - <CanExecuteCommand edge_id>
  - <ExecutesAs edge_id>
  false_positive_note: Requires a task-submit primitive (jobs/write data action OR shared key) AND a pool
    MI that out-privileges the caller. Zero-node pool -> CONDITIONAL(service_state).
  narrative: '{principal.name} can submit a task to pool {pool.name} (jobs/write or shared key) whose
    commandLine mints the token of its identity {mi.name} from IMDS, executing as {mi.name}.'
move · open · esc close