aws-emr-studio-notebook-inject
Write to EMR Studio workspace S3 backing to inject code into notebooks; notebook execution runs as Studio service role or attached cluster's JobFlowRole.
match
A conjunctive graph pattern. Variables (?x) bind node ids; every clause must hold.
{'principal': None}
CanWrite {'s3object': None}
{'studio': None} ContainsResourceReference {'s3object': None}
where
node_type(?studio) ==
AnalyticsService
?studio provider_type == AWS::EMR::Studio
?s3object is part of the Studio DefaultS3Location
?studio or a linked ?cluster has an ExecutesAs edge to ?studioRole or ?jobflowRole
emit
| source type | Identity |
|---|---|
| target type | Identity |
| source | ?principal |
| target | ?studioRole or ?jobflowRole |
| permissions | s3:PutObject |
| conditions | iam_permission trigger_exists |
| state logic | CONDITIONAL(trigger_exists) when the principal can write to the Studio workspace S3 location — code execution requires a user to open/execute a notebook from the Studio workspace. POTENTIAL(trigger_exists) if the notebook execution trigger cannot be confirmed. ACTIVE if the principal can both write the notebook AND invoke it (admin or workspace owner). |
Narrative
{principal.name} can write to the S3 location backing EMR Studio {studio.name} (s3:PutObject on {s3_location}); an attacker can inject malicious code into notebooks stored there. When a user opens/executes such a notebook from the Studio workspace, the code runs as {role.name} (Studio service role or linked cluster's instance profile role).
Raw rule rules/derived/aws/emr.yaml
id: aws-emr-studio-notebook-inject
emits: CanExecuteAs
description: Write to EMR Studio workspace S3 backing to inject code into notebooks; notebook execution
runs as Studio service role or attached cluster's JobFlowRole.
match:
- - principal: null
- CanWrite
- s3object: null
- - studio: null
- ContainsResourceReference
- s3object: null
where:
- node_type(?studio) == AnalyticsService
- ?studio provider_type == AWS::EMR::Studio
- ?s3object is part of the Studio DefaultS3Location
- ?studio or a linked ?cluster has an ExecutesAs edge to ?studioRole or ?jobflowRole
emit:
source_type: Identity
target_type: Identity
source: ?principal
target: ?studioRole or ?jobflowRole
permissions:
- s3:PutObject
conditions:
- iam_permission
- trigger_exists
state_logic: "CONDITIONAL(trigger_exists) when the principal can write to the Studio workspace S3 location\
\ \u2014 code execution requires a user to open/execute a notebook from the Studio workspace. POTENTIAL(trigger_exists)\
\ if the notebook execution trigger cannot be confirmed. ACTIVE if the principal can both write the\
\ notebook AND invoke it (admin or workspace owner)."
confidence: min(contributing_confidences) * 0.85
derived_from:
- <CanWrite(s3:PutObject) edge_id>
- <ContainsResourceReference(aws-emr-studio-workspace-s3-url) edge_id>
- <ExecutesAs(studio or linked cluster) edge_id>
false_positive_note: This is a conditional code-injection path. The principal can write arbitrary code
(notebooks, Python scripts, .jar files) to the Studio workspace S3 location, but execution requires
a user to open/execute the notebook. If the Studio is unused or if the attached clusters are all in
TERMINATED state, downgrade to POTENTIAL. The code runs as the Studio service role (for control-plane
operations) or the linked cluster's JobFlowRole (for notebook execution on a running cluster).
narrative: '{principal.name} can write to the S3 location backing EMR Studio {studio.name} (s3:PutObject
on {s3_location}); an attacker can inject malicious code into notebooks stored there. When a user
opens/executes such a notebook from the Studio workspace, the code runs as {role.name} (Studio service
role or linked cluster''s instance profile role).'