Skip to content

feat: implement network out allow/deny list support - #1016

Merged
dobrac merged 13 commits into
mainfrom
add-allow-deny-network-out-support
Nov 15, 2025
Merged

dobrac merged 13 commits into
mainfrom
add-allow-deny-network-out-support

Conversation

@dobrac

@dobrac dobrac commented Nov 10, 2025 •

Copy link
Copy Markdown
Contributor

Add Network Outbound Traffic Control for Sandboxes

Users can now configure network restrictions when creating sandboxes using the new network configuration option with allowOut and denyOut parameters.

Key Features

  • Allow List: Specify IP addresses, CIDR blocks that sandboxes can connect to
  • Deny List: Specify IP addresses, CIDR blocks that sandboxes cannot connect to
  • Priority Rules: allowOut takes precedence over denyOut when there are conflicts
  • Helper Const: New ALL_TRAFFIC helper to easily deny/allow all network traffic (0.0.0.0/0)

Usage Examples

JavaScript/TypeScript:

import { Sandbox, ALL_TRAFFIC } from 'e2b'

// Block all traffic except specific IPs
const sandbox = await Sandbox.create('template-id', {
  network: {
    denyOut: [ALL_TRAFFIC],
    allowOut: ['1.1.1.1', '8.8.8.0/24']
  }
})

// Block specific IPs only
const sandbox = await Sandbox.create('template-id', {
  network: {
    denyOut: ['8.8.8.8']
  }
})

Python:

from e2b import AsyncSandbox, ALL_TRAFFIC

# Block all traffic except specific IPs
sandbox = await AsyncSandbox.create(
    network={
        "allow_out": ["8.8.8.8"],
        "deny_out": [ALL_TRAFFIC]
    }
)

Note

Adds sandbox network allow/deny egress, optional public traffic protection with access token and host masking, updates template build/list APIs, and integrates these across JS/Python SDKs with tests.

  • SDKs (JS & Python):
    • Add network config to sandboxes with allowOut, denyOut, allowPublicTraffic, maskRequestHost; export ALL_TRAFFIC helper.
    • Surface trafficAccessToken on sandbox instances; wire through create/connect flows.
    • Update exports and types in packages/js-sdk/src/index.ts, sandbox/sandboxApi.ts, Python e2b/__init__.py, and sandbox base.
  • API/Spec & Generated Clients:
    • Extend NewSandbox with network and clarify allow_internet_access; add SandboxNetworkConfig schema.
    • Add trafficAccessToken to Sandbox responses.
    • Introduce GET /templates/{templateID} returning TemplateWithBuilds; split build models into TemplateBuild (summary) and TemplateBuildInfo (status/logs); adjust GET /templates/{templateID}/builds/{buildID}/status to return TemplateBuildInfo.
    • Add pagination params (limit, nextToken) components; update /v2/sandboxes to use them.
    • Regenerate JS TS types and Python client models/endpoints accordingly.
  • Tests:
    • New egress control tests and public traffic token/mask tests in packages/js-sdk/tests/sandbox/network.test.ts and Python async/sync tests.
  • Tooling:
    • Adjust openapi-typescript generation flag (--default-non-nullable false).

Written by Cursor Bugbot for commit 2b7e715. This will update automatically on new commits. Configure here.

@dobrac dobrac added the feature New feature or request label Nov 10, 2025
@changeset-bot

changeset-bot Bot commented Nov 10, 2025 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 2b7e715

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Minor
e2b Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@sitole

sitole commented Nov 11, 2025

Copy link
Copy Markdown
Member

I like this api 👍

@dobrac
dobrac force-pushed the add-allow-deny-network-out-support branch from 1fda7e7 to f2251b0 Compare November 11, 2025 16:08
@dobrac
dobrac marked this pull request as ready for review November 11, 2025 17:14

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@mishushakov mishushakov left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't checked the tests yet - feedback for the SDK so far

Comment thread packages/js-sdk/src/sandbox/network.ts Resolved
Comment thread .changeset/moody-carpets-speak.md Resolved
@dobrac
dobrac force-pushed the add-allow-deny-network-out-support branch from 820b8f0 to 20f27bf Compare November 14, 2025 23:27
Comment thread packages/python-sdk/tests/conftest.py Resolved
@dobrac
dobrac force-pushed the add-allow-deny-network-out-support branch from 7d3f37c to 57b2a42 Compare November 15, 2025 10:29
Comment thread packages/js-sdk/tests/setup.ts Resolved
@dobrac
dobrac merged commit 4c61288 into main Nov 15, 2025
@dobrac
dobrac deleted the add-allow-deny-network-out-support branch November 15, 2025 22:35

This branch was previously deployed

1 inactive deployment
Preview — 2b7e7155 Deployed Nov 15, 2025 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants