CertNote/ Commute Study Notes
Roadmap
KOEN
CLF-C02 · FoundationalCloud Practitioner - Foundational
DVA-C02 · AssociateDeveloper - Associate
SAA-C03 · AssociateSolutions Architect - Associate
SOA-C02 · AssociateCloudOps Engineer - Associate
SAP-C02 · ProfessionalSolutions Architect - Professional
DOP-C02 · ProfessionalDevOps Engineer - Professional
Linux Master 2 · 2급KAIT Linux Master - Level 2
SCS-C03 · SpecialtySecurity - Specialty
Linux Master 1 · 1급KAIT Linux Master - Level 1
MLA-C01 · AssociateMachine Learning Engineer - Associate
AIF-C01 · FoundationalAI Practitioner - Foundational
DEA-C01 · AssociateData Engineer - Associate
MLS-C01 · SpecialtyMachine Learning - Specialty
  • Week 1
    • 1.The ML Lifecycle (from a Specialty Perspective)
    • 2.Data Storage for ML: S3, EFS, FSx for Lustre, and Data Formats
    • 3.Data Ingestion: Kinesis, Glue, Batch vs. Streaming
    • 4.Data Labeling: SageMaker Ground Truth, Active Learning, Label Quality
    • 5.Week 1 Comprehensive Review: ML Overview & Data Engineering 1
  • Week 2
  • Week 3
  • Week 4
  • Week 5
  • Week 6
  • Week 7
  • Week 8
  • Week 9
  • Week 10
  • Week 11
    • 1.Model Monitoring: SageMaker Model Monitor and Drift Response
    • 2.MLOps: SageMaker Pipelines, Model Registry, CI/CD
    • 3.ML Security: IAM Execution Roles, VPC Isolation, KMS Encryption
    • 4.Operations & Cost: Cost Optimization, Logging/Audit, Disaster Recovery
    • 5.Week 11 Comprehensive Review: Monitoring, MLOps, Security, Operations
  • Week 12
SQLD · 개발자SQL Developer (SQLD)

© CertNote · 주간랩스

  • About
  • Changelog
  • Contact
  • Terms
  • Privacy
← MLS-C01/Week 11/Day 3

Based on the MLS-C01 exam guide·Report an error

MLS-C01· AssociateWeek 11 · Day 3~28 min read

Day 3 - ML Security: IAM Execution Roles, VPC Isolation, KMS Encryption

📌 Key Takeaways

  • ML security rests on three pillars: IAM execution roles (who does what), VPC isolation (where traffic goes), and KMS encryption (who can unlock it).
  • SageMaker training jobs and endpoints run with an Execution Role, not the user's credentials. When you see AccessDenied, suspect the execution role first.
  • A requirement that "it must never reach the internet" is met by the combination of private subnets + VPC endpoints + enable_network_isolation.
  • With encryption, the key question is not turning it on but who can use the key. Decryption works only when the KMS key policy and the IAM policy both allow it.
  • Separating CMKs per team or project enforces data isolation: even with IAM permissions, the key policy blocks access.

The Three Security Pillars at a Glance

An ML system gathers sensitive training data, expensive model artifacts, and broad permissions in one place. If it leaks, data theft, model theft, and permission abuse all happen at once.

                    ┌──────────────────────────────────┐
                    │  SageMaker training / inference   │
                    │            workloads              │
                    └────────────────┬─────────────────┘
        ┌────────────────────────────┼────────────────────────────┐
        │                            │                            │
  ① IAM execution role         ② VPC isolation              ③ KMS encryption
  "who does what"              "where it communicates"      "who can unlock it"
        │                            │                            │
  - least-privilege policy     - private subnets            - S3 SSE-KMS
  - trust policy               - VPC endpoints              - volume_kms_key
  - scoped to S3/KMS paths     - security groups            - output_kms_key
                               - network isolation          - inter-node traffic encryption

IAM Execution Roles: The Principle of Least Privilege

SageMaker training jobs and endpoints run with the permissions of an Execution Role. If you grant this role too much, the damage from a breach grows accordingly. Give least privilege only for the S3 paths and KMS keys that are needed.

AspectUser credentialsSageMaker execution role
Who uses itPeople using the console, CLI, or SDKTraining containers, endpoints, processing jobs
When it is evaluatedWhen CreateTrainingJob is calledWhen accessing S3, KMS, and ECR while the job runs
Required permissionssagemaker:CreateTrainingJob, iam:PassRoles3:GetObject, kms:Decrypt, ecr:GetAuthorizationToken, etc.
Common symptomJob creation itself failsThe job starts but fails when reading data

If a user can read the bucket fine in the console but only the training job gets AccessDenied, it is almost always an execution role problem. For a user to pass a role to a service, iam:PassRole is also required separately.

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": ["s3:GetObject", "s3:PutObject"],
      "Resource": [
        "arn:aws:s3:::ml-train-bucket/data/*",
        "arn:aws:s3:::ml-train-bucket/output/*"
      ]
    },
    {
      "Effect": "Allow",
      "Action": ["kms:Decrypt", "kms:GenerateDataKey"],
      "Resource": "arn:aws:kms:us-east-1:111122223333:key/abcd-efgh"
    }
  ]
}
  • The key point is that it is narrowed by prefix, not to the whole bucket.
  • For an SSE-KMS bucket, S3 permissions alone are not enough. You need kms:Decrypt for reads and kms:GenerateDataKey for writes as well.

The Trust Policy separately restricts "who can assume this role."

{
  "Version": "2012-10-17",
  "Statement": [{
    "Effect": "Allow",
    "Principal": { "Service": "sagemaker.amazonaws.com" },
    "Action": "sts:AssumeRole"
  }]
}

AccessDenied Diagnosis Flow

Training job gets AccessDenied on S3
        │
① Are you looking at the "execution role" permissions, not the user's?
     └ No → check the execution role ARN first
        │
② Does the execution role policy include that bucket/prefix?
     └ No → fix the s3:GetObject resource scope
        │
③ Is there an explicit Deny in the bucket policy?
     └ Yes → Deny always wins. Fix the bucket policy
        │
④ Is the object SSE-KMS?
     └ Yes → check kms:Decrypt / GenerateDataKey + the key policy
        │
⑤ Is the job running inside a VPC?
     ├ Yes → check the VPC endpoint policy, routing, and security groups
     └ No  → check organization SCPs and the Permissions Boundary

On the exam, "the training job cannot access S3 (AccessDenied)" is usually insufficient execution role permissions, not a user permission problem. Conversely, "the role can access all buckets" violates least privilege. Remember that the principal of the permissions is the execution role.

⚠️ Pitfall: In IAM, an explicit Deny takes precedence over any Allow. If even one of the role policy, bucket policy, or SCP denies, opening up everything else will not let the request through.

VPC Isolation: Training Without the Internet

By default, SageMaker jobs can reach the internet from the AWS-managed network. For sensitive data you must block this. Use VpcConfig to place the job in a private subnet of your own VPC, and use VPC endpoints to reach S3 and other services without the internet.

estimator = Estimator(
    image_uri=image, role=role,
    instance_count=1, instance_type="ml.m5.xlarge",
    subnets=["subnet-priv-a", "subnet-priv-b"],
    security_group_ids=["sg-0123456789"],
    encrypt_inter_container_traffic=True,   # encrypt traffic between distributed training nodes
    enable_network_isolation=True,          # block the container's external network access
)

What Each Isolation Option Blocks

OptionWhat it doesWhat it blocksWhat it does not block
subnetsAttaches the job to an ENI in the specified VPC subnetsArbitrary paths through the managed networkIf the subnet has an internet route, traffic still goes out
security_group_idsInstance-level inbound/outbound filterPorts and destinations that are not allowedExfiltration to destinations that are already allowed
enable_network_isolationBlocks all network calls from the containerAll outbound communication from the container codeInput download and artifact upload done by the platform on its behalf
encrypt_inter_container_trafficEncrypts traffic between distributed training nodesPlaintext transfer between nodesData at rest (a separate KMS setting is needed)

When you run untrusted third-party code or models, turning on network isolation is the default.

Two Kinds of VPC Endpoints

AspectGateway endpointInterface endpoint (PrivateLink)
Supported servicesTwo: S3 and DynamoDBSageMaker API/Runtime, CloudWatch, ECR, STS, etc.
How it worksAdds a route to the route tableAn ENI (private IP) in the subnet + private DNS
PricingNo additional chargeHourly + data processing charges
Access scopeSame Region, inside the same VPCAlso reachable from on premises (Direct Connect, VPN)
Access controlEndpoint policyEndpoint policy + security group

A gateway endpoint is "a routing change that diverts the path to S3 inside AWS," while an interface endpoint is "creating a private-IP entry point for the service inside my subnet."

        [VPC]
 ┌────────────────────────────────────────────────────────────┐
 │  [Private Subnet A]                    [Private Subnet B]  │
 │   training container (ENI) ◀─ distributed training (SG self-reference) ─▶ training container │
 │        │     │                                             │
 │        │     └─(Interface Endpoint)─▶ SageMaker API        │
 │        │                              CloudWatch Logs      │
 │        └─(Gateway Endpoint · routing)─▶ S3 / DynamoDB      │
 │                                                            │
 │   ✗ No internet gateway           ✗ No NAT gateway         │
 └────────────────────────────────────────────────────────────┘
  • With distributed training, the security group needs a rule that references itself, because the nodes must communicate with each other.
  • Place at least two subnets in different AZs and keep spare IP addresses. Without spare IPs, instance placement fails.

⚠️ Pitfall: With enable_network_isolation=True, the code inside the container cannot call S3 directly. Training still runs because the platform, outside the container, handles the input channel download and artifact upload on its behalf. If the training script does a pip install at runtime or fetches more data from an external URL or S3, it fails at that point.

If you only place the job in a private subnet and do not create an S3 gateway endpoint, training cannot receive its data and stalls. "The job will not start after I isolated it" is usually a missing endpoint.

KMS Encryption: Protection at Rest and in Transit

Encrypt data and models both at rest and in transit. A KMS customer managed key (CMK) controls who can decrypt.

estimator = Estimator(
    ...,
    output_kms_key="arn:aws:kms:us-east-1:111122223333:key/abcd-efgh",   # encrypt model artifacts
    volume_kms_key="arn:aws:kms:us-east-1:111122223333:key/wxyz-1234",   # encrypt training EBS
)
Protection pointMethodNotes
Training data and models in S3Encrypt the bucket/objects with SSE-KMS (CMK)Read: kms:Decrypt, write: kms:GenerateDataKey
Training instance storageEncrypt EBS with volume_kms_keyNot applicable to local NVMe storage types
Model artifact outputoutput_kms_keymodel.tar.gz is encrypted with the specified CMK
Traffic between distributed training nodesencrypt_inter_container_traffic=TrueEncryption in transit
Endpoint communicationTLS (encryption in transit by default)Applied with no extra setup
Endpoint and processing job volumesKmsKeyId in the endpoint configuration / ProcessingInference and preprocessing follow the same principle

The Double Gate: Key Policy + IAM Policy

A double gate: decryption succeeds only when both the KMS key policy and the IAM permission policy allow it

  • Most resources are accessed with an IAM policy alone, but for KMS the key policy is the primary gate. If the key policy does not delegate to IAM, decryption does not work even with administrator permissions.

Per-Team CMK Isolation Pattern

AssetKeyPrincipals allowed by the key policyEffect
Team A data and modelscmk-team-aTeam A execution role and data scientistsTeam B cannot decrypt even with IAM permissions
Team B data and modelscmk-team-bTeam B execution role and data scientistsA breach of Team A does not spread to Team B
Shared audit logscmk-auditSecurity team onlyOperators cannot read or delete the logs

If you share an AWS managed key, there is effectively no isolation within the account. Remember: isolation requirement = CMK + separate key policies.

"Encryption is on, but who can use that key?" is the real control point. The KMS key policy and IAM work together, and if the key policy denies, decryption fails even with IAM permissions. The pattern of splitting CMKs per team or project to isolate data is within exam scope.

Supporting Services for Data and Model Protection

ServiceRoleTypical stem
Amazon MacieAutomatically detects and classifies PII and sensitive information in S3 using ML"Find out whether credit card numbers are mixed into the dataset"
SageMaker ClarifyDetects bias in data and models, explains predictions"Provide evidence of responsible AI and fairness"
AWS PrivateLinkCalls SageMaker privately without the internet"Call from on premises without going through the internet"
Secrets ManagerManages and rotates external DB and API credentials outside the code"A DB password is hardcoded in the notebook code"
CloudTrailAudit log of all API calls"Who deleted the endpoint and when" (next post)
Permissions Boundary / SCPA permission ceiling that a role cannot exceed"Keep teams from widening their own permissions"

SageMaker Studio and Notebook Security Options

TargetOptionEffect
Studio domainSet the network access mode to VPC onlyStudio traffic flows only into the user's VPC
Studio domainSeparate execution roles per user profileSeparates each user's data access scope
Notebook instanceDisable direct internet accessUses only the endpoint/NAT path
Notebook instanceDisable root access + lifecycle configurationEnforces standard security settings at startup

Security Review Checklist

  • Is the execution role restricted by prefix rather than to the whole bucket?
  • For an SSE-KMS bucket, are kms:Decrypt and kms:GenerateDataKey both present?
  • Is there an S3 gateway endpoint in the private subnet?
  • For distributed training, does the security group have a self-referencing rule?
  • Are notebooks and Studio not directly exposed to the internet?

Stem Clue → Answer Mapping

Stem clueAnswer to chooseWhy
"Only the training job gets AccessDenied; the user reads fine"Add S3 permissions to the execution roleThe job runs with the execution role's permissions
"Training must never reach the internet"Private subnet + VPC endpoint + network isolationOnly all three together remove the internet path
"Only S3 and DynamoDB need private access"Gateway endpointDedicated to those two services, no extra charge
"Call the SageMaker API privately from on premises"Interface endpoint (PrivateLink)ENI-based, so reachable from Direct Connect/VPN
"Data between distributed training nodes flows in plaintext"encrypt_inter_container_traffic=TrueThe encryption-in-transit option
"Encrypt model artifacts with a specific key"output_kms_keyThe parameter dedicated to output artifacts
"Encrypt the training instance disk"volume_kms_keyEncrypts the attached EBS volume
"Keep teams from decrypting each other's data"Per-team CMK + separate key policiesIAM alone cannot prevent key use
"Decryption fails even though IAM permissions were granted"Check the KMS key policyBoth the key policy and IAM must allow it
"Automatically detect whether PII is mixed into the dataset"Amazon MacieDedicated to detecting and classifying sensitive data in S3
"Run an untrusted third-party model"enable_network_isolation=TrueFully blocks the container's external communication

In the next post, we cover the other half of operations: cost optimization, CloudWatch/CloudTrail logging and auditing, and disaster recovery.

📖 Glossary

  • Execution Role: The IAM role that a training job or endpoint uses "on its own behalf." It is separate from a person's credentials.
  • Trust Policy: The role-side policy that defines "who can assume this role." It pairs with the permission policy.
  • iam:PassRole: The permission that lets a user hand a role to a service. Without it, job creation itself is blocked.
  • Network Isolation: A setting that prevents the container from making any outbound network calls. The platform moves inputs and outputs on its behalf.
  • VPC endpoint: A private channel that reaches AWS services without going through the internet. There is a gateway type for S3 and DynamoDB and an ENI-based interface type.
  • Customer managed key (CMK): A KMS key that you create yourself and whose key policy you also control. It is the core tool for per-team isolation.
  • Key Policy: The resource policy attached to a KMS key. Separate from IAM permissions; if it blocks here, decryption does not happen.
  • SSE-KMS: A method where S3 performs server-side encryption of objects with a KMS key. Reading and writing also require KMS permissions.
  • Encryption in transit: Encryption while data flows over the network. Endpoints use TLS, and traffic between distributed training nodes is enabled with a separate option.

📝 Practice Questions

Click a choice to reveal the answer and explanation.

Question 1

Due to regulatory requirements, a training job must never have access to the internet, and it must access the S3 bucket holding the training data without traversing the internet. Which configuration is MOST appropriate?

Question 2

A SageMaker training job receives AccessDenied when accessing an S3 bucket. The user can read the same bucket in the console without problems. What is the MOST likely cause?

Question 3

You want to isolate training data and model artifacts by project team so that teams cannot decrypt each other's data. Which approach is MOST effective?

Question 4

In distributed training, you want to ensure that training data passing between nodes does not flow over the network in plaintext. Which option should you set on the SageMaker Estimator?

Question 5

You want to automatically detect and classify whether PII such as credit card numbers is unintentionally included in a training dataset stored in S3. Which service is MOST appropriate?

PreviousMLOps: SageMaker Pipelines, Model Registry, CI/CDWeek 11 · Day 2Next Operations & Cost: Cost Optimization, Logging/Audit, Disaster RecoveryWeek 11 · Day 4

Official references

  • MLS-C01 official exam page(opens in a new tab)
  • AWS IAM documentation(opens in a new tab)
  • AWS KMS documentation(opens in a new tab)
  • Amazon VPC documentation(opens in a new tab)
  • Amazon S3 documentation(opens in a new tab)
  • Amazon SageMaker AI documentation(opens in a new tab)

On this page

  • Key Takeaways
  • The Three Security Pillars at a Glance
  • IAM Execution Roles: The Principle of Least Privilege
  • AccessDenied Diagnosis Flow
  • VPC Isolation: Training Without the Internet
  • What Each Isolation Option Blocks
  • Two Kinds of VPC Endpoints
  • KMS Encryption: Protection at Rest and in Transit
  • The Double Gate: Key Policy + IAM Policy
  • Per-Team CMK Isolation Pattern
  • Supporting Services for Data and Model Protection
  • SageMaker Studio and Notebook Security Options
  • Stem Clue → Answer Mapping
  • Glossary
  • Practice Questions