More Info:
SageMaker Notebook Instance should not have direct internet accessRisk Level
MediumAddress
SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- ISO 27001
- ISO/IEC 27018
- ISO/IEC 27701
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remove direct internet access from a SageMaker Notebook Instance via the AWS Console, you must:
- Ensure the notebook runs inside a VPC without direct internet access
- Use VPC endpoints so it can still reach required AWS services (S3, SageMaker, etc.)
1. Prepare a Private VPC Environment (if you don’t already have one)
You need:- A VPC
- Private subnets (no route to an Internet Gateway)
- Optional: NAT Gateway (if you still want outbound internet for package installs; if you want no internet at all, skip NAT)
1.1 Check or Create VPC and Subnets
- Go to VPC Console → Your VPCs.
- Use an existing VPC or click Create VPC.
- In Subnets, make sure you have at least one subnet that:
- Does not have a route to an Internet Gateway.
- Optionally has a route to a NAT Gateway (if limited outbound internet is acceptable).
- Has DNS support/hostnames enabled at the VPC level (for endpoints).
- Go to Route Tables, find the route table associated with that subnet.
- Ensure there is no route like
0.0.0.0/0→igw-xxxx.- If present, remove/edit this route for the private subnet or create a separate private route table.
2. Create VPC Endpoints for Required AWS Services
To let the notebook access AWS services without internet:- Go to VPC Console → Endpoints → Create endpoint.
2.1 S3 Gateway Endpoint
- Service category: AWS services
- Service name:
com.amazonaws.<region>.s3(type: Gateway) - VPC: select your VPC.
- Route tables: select the route tables used by your private subnets.
- Policy: use Full access (or a custom restrictive one).
- Click Create endpoint.
2.2 Interface Endpoints (PrivateLink)
Repeat Create endpoint for each:com.amazonaws.<region>.sagemaker.apicom.amazonaws.<region>.sagemaker.runtimecom.amazonaws.<region>.sagemaker.notebookcom.amazonaws.<region>.sts- Optionally:
com.amazonaws.<region>.logs(CloudWatch Logs)com.amazonaws.<region>.monitoring(CloudWatch Metrics)com.amazonaws.<region>.ecr.apiandecr.dkr(if using custom images)
- Service category: AWS services.
- Service name: pick the specific interface service.
- VPC: select your VPC.
- Subnets: select the private subnets where notebooks will run.
- Security group: choose or create an SG that allows:
- Inbound from notebook instance SG on TCP 443.
- Outbound to anywhere or at least to the VPC.
- Click Create endpoint.
3. Configure Security Groups
- Go to VPC Console → Security groups.
- For the notebook’s security group:
- Outbound: allow HTTPS (TCP 443) to the VPC CIDR or
0.0.0.0/0(traffic stays inside via endpoints). - Inbound: typically not required from internet; SageMaker proxy handles access. Keep it restrictive.
- Outbound: allow HTTPS (TCP 443) to the VPC CIDR or
4. Update an Existing SageMaker Notebook Instance
- Go to Amazon SageMaker Console.
- In left menu, select Notebook instances.
- Select your notebook instance.
- Click Stop and wait until status is Stopped.
- With it selected, click Edit (or Update settings depending on console version).
-
Network:
- VPC: select your prepared VPC.
- Subnets: choose a private subnet (no direct IGW route).
- Security group: select the SG configured above.
-
Direct internet access:
- Set to Disable.
- Save the changes.
- After configuration updates, click Start to start the instance.
5. Create a New Notebook Instance with No Direct Internet
If creating new instead of updating:- In SageMaker Console → Notebook instances → Create notebook instance.
- Fill in instance name and type.
- Under Network:
- VPC: choose your VPC.
- Subnets: choose your private subnet.
- Security group: select the configured SG.
- Under Permissions and encryption, choose an appropriate IAM role.
- Under Network or Additional configuration:
- Direct internet access: set to Disable.
- Click Create notebook instance.
6. Validate
- Start the notebook and open Jupyter/JupyterLab from the console.
- Confirm:
- It can access S3 buckets (e.g., list objects via boto3).
- It cannot reach arbitrary public internet (e.g.,
!ping google.comshould fail if no NAT/internet). - SageMaker operations (training, inference) still work via endpoints.
Using CLI
Using CLI
You can’t turn off DirectInternetAccess on an existing SageMaker notebook instance. You must create a new notebook instance with internet access disabled and move your workloads to it, then delete the old one.Below are step‑by‑step AWS CLI instructions.
Note down:
Ensure there is no route like:If such a route exists, either:
Notes:
Delete:
Output should be:Optionally, from inside the notebook, test that:
1. Identify the notebook instance and its current settings
NotebookInstanceNameRoleArnInstanceTypeSubnetIdSecurityGroupsVolumeSizeInGBNotebookInstanceLifecycleConfigName(if any)KmsKeyId(if any)
2. Ensure you have a VPC subnet and security group without direct internet
Requirements for no direct internet access:- Notebook must be in a VPC (
--subnet-idand--security-group-ids). - No route in the subnet’s route table directly to an internet gateway.
- If outbound access is needed, use a NAT gateway or VPC endpoints (e.g., for S3, SageMaker API, etc.), not an internet gateway.
- Use a different subnet without an IGW route, or
- Adjust the route table (e.g., point 0.0.0.0/0 to a NAT gateway instead of an IGW), depending on your network design.
3. Create a new notebook instance with DirectInternetAccess disabled
Use--direct-internet-access Disabled and specify VPC parameters:- Omit flags whose values you don’t need (e.g.,
--kms-key-id,--notebook-instance-lifecycle-config-name). --no-root-accessis optional but often a good security practice; you can remove it if you require root access.
4. Migrate notebooks / code
From the old instance:- Download notebooks and data, or
- Push them to S3, Git, or CodeCommit.
- Pull notebooks from S3 or your repo, or upload them.
5. Stop and delete the old notebook instance
Stop:6. Validate that the new notebook has no direct internet access
Describe:- You cannot reach public internet directly (e.g.,
ping 8.8.8.8orcurl https://google.comfails), and - You can reach necessary AWS services via VPC endpoints or NAT (e.g., access to S3 buckets used by SageMaker).
Using Python
Using Python
To remove direct internet access from a SageMaker notebook via Python, you need to:
Adjust IDs/region as needed. Do similar for other endpoints (CloudWatch, STS, etc.) as required.
If it is not yet in a VPC, you must attach it:Then start it again:
Optionally, wait until it’s
Summary in one line:Use
- Ensure VPC access is in place (subnet + security group + VPC endpoints)
- Update or recreate the notebook instance with
DirectInternetAccess='Disabled'
1. Prerequisites (VPC Setup – one-time)
You must have:- A VPC with at least one private subnet (no direct route to an Internet Gateway).
- A security group that allows needed traffic (typically to internal resources or endpoints).
- VPC endpoints for services the notebook needs, most importantly:
- S3 interface or gateway endpoint
- SageMaker API/Runtime endpoints if needed
- Other services as needed (e.g., CloudWatch Logs, ECR, STS)
2. Disable Direct Internet Access for an Existing Notebook
You can change an existing notebook’s internet access configuration usingupdate_notebook_instance.Important:- You must stop the notebook before updating.
- Notebook must already (or after update) be attached to a subnet and security group so it can function without direct internet.
2.1. Stop the notebook instance
2.2. Update notebook instance to disable direct internet
If the notebook is already configured with a subnet and security group, you can just flipDirectInternetAccess:3. Create a New Notebook With No Direct Internet Access
If you’re provisioning new notebooks, setDirectInternetAccess='Disabled' at creation time and attach to your private subnet/security group.InService:4. Verify Configuration
Usedescribe_notebook_instance to confirm:Summary in one line:Use
boto3.client('sagemaker').update_notebook_instance(..., DirectInternetAccess='Disabled', SubnetId=..., SecurityGroupIds=[...]) (after stopping the notebook) and ensure required VPC endpoints exist so the notebook can function without direct internet.
