Egress and secrets
A sandbox reaches only the hosts its egress rules allow, through the cluster’s egress proxy. A rule can name a secret; the proxy then adds that secret to the requests the rule allows, and the sandbox never sees it (Use a secret in a sandbox). For the model behind this, see Egress and credentials in Concepts.
The examples use a small script, fetch.py, that prints a URL’s status and body, or why the request was refused.
Save it in your working directory:
import sys, urllib.request, urllib.error
url = sys.argv[1]method = sys.argv[2] if len(sys.argv) > 2 else "GET"try: with urllib.request.urlopen(urllib.request.Request(url, method=method), timeout=30) as r: print(r.status, r.read().decode()[:400])except urllib.error.HTTPError as e: print(e.code, e.read().decode().strip())except urllib.error.URLError as e: print("refused:", e.reason)Allow hosts at create
Section titled “Allow hosts at create”Each --allow (egress=[cere.Allow(...)]) adds a rule. This sandbox may install packages from PyPI and reach
nothing else:
ID=$(cere sandbox create --image python:3.12-slim --timeout 300 -q \ --allow pypi.org:GET:/simple/ --allow files.pythonhosted.org:GET:/packages/)cere sandbox exec $ID -- pip install --root-user-action=ignore --disable-pip-version-check -q sixcere sandbox exec $ID -- python -c "import six; print(six.__version__)"1.17.0import cere
sb = cere.Sandbox.create( image="python:3.12-slim", timeout=300, egress=[cere.Allow("pypi.org", ["GET"], path_prefix="/simple/"), cere.Allow("files.pythonhosted.org", ["GET"], path_prefix="/packages/")],)p = sb.exec("pip", "install", "--root-user-action=ignore", "--disable-pip-version-check", "-q", "six")print(p.wait())print(sb.exec("python", "-c", "import six; print(six.__version__)").stdout.read(), end="")01.17.0A rule is host[:METHODS[:path_prefix[:credential]]] in the CLI, and cere.Allow(host, methods, path_prefix=, credential=) in Python. cere.Allow.parse("pypi.org:GET:/simple/") reads the CLI’s form, and sb.allow() and
sb.set_egress() also take it as a string; Sandbox.create takes cere.Allow objects.
| Part | Rule | Example |
|---|---|---|
host |
An exact host, or *.example.com for any name under example.com (not example.com itself) |
pypi.org |
METHODS |
Comma-separated, upper case; * for any. Default GET |
GET,HEAD |
path_prefix |
Optional. Matches whole path segments (below) | /simple/ |
credential |
Optional. A secret the proxy adds to these requests (below) | github-readonly |
api.github.com:GET::github-readonly is GET on any path of api.github.com, with the secret github-readonly.
See what was refused
Section titled “See what was refused”A request to a host no rule allows is refused when the sandbox opens the connection; a request to an allowed host
with a method or path no rule allows gets 403 from the proxy. Each request reaches the egress log a second or two after it
is made.
cere sandbox put $ID fetch.py /workspace/fetch.pycere sandbox exec $ID -- python fetch.py https://example.com/cere sandbox exec $ID -- python fetch.py https://pypi.org/pypi/six/jsonwrote fetch.py (409 B) to sb-01m89qx9w516mdxgcrf42tkzfp:/workspace/fetch.pyrefused: Tunnel connection failed: 403 Forbidden403 {"error":"DDC egress proxy: GET pypi.org/pypi/six/json is not allowed for this sandbox"}sb.write_file("/workspace/fetch.py", open("fetch.py").read())print(sb.exec("python", "fetch.py", "https://example.com/").stdout.read(), end="")print(sb.exec("python", "fetch.py", "https://pypi.org/pypi/six/json").stdout.read(), end="")refused: Tunnel connection failed: 403 Forbidden403 {"error":"DDC egress proxy: GET pypi.org/pypi/six/json is not allowed for this sandbox"}The egress log has every request the bucket’s sandboxes made, allowed or refused, and every change of their rules.
Filter it by sandbox, decision (allowed, denied, error, policy) and time:
cere egress log --sandbox $ID --deniedcere egress log --sandbox $ID --decision allowed --limit 3TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON2026-11-25T16:16:42Z sb-01m89qx9w516mdxgcrf42tkzfp denied GET pypi.org /pypi/six/json 403 - 0 B - GET pypi.org/pypi/six/json is not allowed for this sandbox2026-11-25T16:16:41Z sb-01m89qx9w516mdxgcrf42tkzfp denied CONNECT example.com - 403 - 0 B - host not in the sandbox's allow-listTIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON2026-11-25T16:16:40Z sb-01m89qx9w516mdxgcrf42tkzfp allowed GET pypi.org /simple/six/ 200 - 6.4 KiB 20 -2026-11-25T16:16:40Z sb-01m89qx9w516mdxgcrf42tkzfp allowed GET files.pythonhosted.org /packages/b7/ce/.../six-1.17.0-py2.py3-none-any.whl 200 - 10.8 KiB 4 -2026-11-25T16:16:40Z sb-01m89qx9w516mdxgcrf42tkzfp allowed GET files.pythonhosted.org /packages/b7/ce/.../six-1.17.0-py2.py3-none-any.whl.metadata 200 - 1.6 KiB 18 ---denied is --decision denied. --since takes a duration back (1h) or an RFC 3339 time; --limit N
(default 100) or --all.
for e in cere.egress_log(sb.object_id, decision="denied"): print(e["ts"], e["decision"], e["method"], e["host"], e["path"], e["status"], e["reason"])2026-11-25T16:18:41.440508Z denied GET pypi.org /pypi/six/json 403 GET pypi.org/pypi/six/json is not allowed for this sandbox2026-11-25T16:18:40.830357Z denied CONNECT example.com None 403 host not in the sandbox's allow-listEach entry is a dict with ts, sandbox_id, host, method, path (never the query string), status,
decision, reason, credential, bytes_up, bytes_down and duration_ms. since= and until= take a
datetime or an RFC 3339 string; limit=None reads every entry.
A refused host’s entry has the method CONNECT and no path: the proxy refused the connection before any request.
Store a secret
Section titled “Store a secret”A secret is a header value the egress proxy holds for your bucket, bound to the hosts it may be sent to. It is read from standard input or a file, never from an argument, and never shown again.
openssl rand -hex 16 > docs-token.txt # a dummy token for this examplecere secret set docs-echo --header Authorization --host httpbin.org --bearer-file docs-token.txtcere secret listStored secret docs-echo (header Authorization, 39 bytes), sent only to httpbin.org. Name it in an egress rule: --allow httpbin.org:<METHODS>:<path>:docs-echoNAME TYPE HEADER HOSTS UPDATEDddc-inference header Authorization inference-gateway.compute.dev.ddcdragon.com 9h02m agodocs-echo header Authorization httpbin.org 0s agogithub-readonly header Authorization api.github.com 9h25m agoimport secrets
token = secrets.token_hex(16) # a dummy token for this examplecere.Secret.set("docs-echo", header="Authorization", value="Bearer " + token, hosts=["httpbin.org"])print([s for s in cere.Secret.list() if s["name"] == "docs-echo"])[{'name': 'docs-echo', 'type': 'header', 'header': 'Authorization', 'hosts': ['httpbin.org'], 'created_at': '2026-11-25T16:17:47.956649Z', 'updated_at': '2026-11-25T16:17:47.956649Z'}]cere secret set |
cere.Secret.set |
|
|---|---|---|
NAME |
name |
Lower-case letters, digits and -, up to 63 characters |
--header |
header= |
The request header the proxy sets, for example Authorization |
--host (repeat it) |
hosts=[...] |
The only hosts the value is sent to: exact, or *.example.com for one more label; up to 32 |
--value-stdin, --value-file F |
value= |
The header value as it is, up to 8 KiB |
--bearer-stdin, --bearer-file F |
value="Bearer " + token |
A token, sent as Bearer <token> |
Storing a secret again replaces its value and its hosts together. cere secret list (cere.Secret.list()) shows
names, headers and hosts, never values.
Use a secret in a sandbox
Section titled “Use a secret in a sandbox”Name the secret in a rule. The proxy adds it to each request that rule allows, on the hosts the secret is bound to.
Here the host is httpbin.org, whose /headers page answers with the headers it received, so you can see the
credential arrive:
ID2=$(cere sandbox create --image python:3.12-slim --timeout 300 -q \ --allow httpbin.org:GET:/headers:docs-echo)cere sandbox put $ID2 fetch.py /workspace/fetch.pycere sandbox exec $ID2 -- python fetch.py https://httpbin.org/headerswrote fetch.py (409 B) to sb-01m89qxggkh44jz46w4ranq5xq:/workspace/fetch.py200 { "headers": { "Accept-Encoding": "identity", "Authorization": "Bearer 0b4a8447824ecb3c95f5bc51ad739f0c", "Host": "httpbin.org", "User-Agent": "Python-urllib/3.12" }}The sandbox itself never had the value: it is not in its environment, and no file in it contains it.
cere sandbox exec $ID2 -- sh -c 'env | grep -i -e authorization -e bearer || echo "no credential in the environment"'cere sandbox exec $ID2 -- grep -rlF --exclude-dir=proc --exclude-dir=sys "$(cat docs-token.txt)" /; echo "grep exit code: $?"cere egress log --sandbox $ID2no credential in the environmentgrep exit code: 1TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON2026-11-25T16:16:46Z sb-01m89qxggkh44jz46w4ranq5xq allowed GET httpbin.org /headers 200 docs-echo 188 B 308 -grep exits 1 when no file matches. The egress log names the secret the proxy added to the request.
sb2 = cere.Sandbox.create( image="python:3.12-slim", timeout=300, egress=[cere.Allow("httpbin.org", ["GET"], path_prefix="/headers", credential="docs-echo")],)sb2.write_file("/workspace/fetch.py", open("fetch.py").read())print(sb2.exec("python", "fetch.py", "https://httpbin.org/headers").stdout.read(), end="")200 { "headers": { "Accept-Encoding": "identity", "Authorization": "Bearer e9d8f4a6d2f52846dc503e474e02d0ac", "Host": "httpbin.org", "User-Agent": "Python-urllib/3.12" }}The sandbox itself never had the value: it is not in its environment, and no file in it contains it.
env = sb2.exec("env").stdout.read()print("token in environment:", token in env, "| Authorization in environment:", "authorization" in env.lower())print("grep exit code:", sb2.exec("grep", "-rlF", "--exclude-dir=proc", "--exclude-dir=sys", token, "/").wait())for e in cere.egress_log(sb2.object_id, decision="allowed"): print(e["host"], e["path"], e["status"], e["credential"])token in environment: False | Authorization in environment: Falsegrep exit code: 1httpbin.org /headers 200 docs-echogrep exits 1 when no file matches. The egress log names the secret the proxy added to the request.
Change egress while a sandbox runs
Section titled “Change egress while a sandbox runs”A running sandbox’s rules can change. The proxy applies a change from the sandbox’s next request, also inside a connection it already has open, and the egress log records each rule added or removed.
cere sandbox egress list $IDcere sandbox egress allow $ID pypi.org:HEAD:/simple/cere sandbox egress remove $ID pypi.org --method HEADcere sandbox egress set $ID --noneHOST METHODS PATH CREDENTIALpypi.org GET /simple/ -files.pythonhosted.org GET /packages/ -HOST METHODS PATH CREDENTIALpypi.org GET,HEAD /simple/ -files.pythonhosted.org GET /packages/ -The rules apply from the sandbox's next request.HOST METHODS PATH CREDENTIALpypi.org GET /simple/ -files.pythonhosted.org GET /packages/ -The rules apply from the sandbox's next request.HOST METHODS PATH CREDENTIALNo rules: the sandbox reaches no host.The rules apply from the sandbox's next request.print(sb.egress())print(sb.allow(cere.Allow("pypi.org", ["HEAD"], path_prefix="/simple/")))print(sb.remove_egress("pypi.org", methods=["HEAD"]))print(sb.set_egress([]))[Allow(host='pypi.org', methods=['GET'], path_prefix='/simple/', credential=None), Allow(host='files.pythonhosted.org', methods=['GET'], path_prefix='/packages/', credential=None)][Allow(host='pypi.org', methods=['GET', 'HEAD'], path_prefix='/simple/', credential=None), Allow(host='files.pythonhosted.org', methods=['GET'], path_prefix='/packages/', credential=None)][Allow(host='pypi.org', methods=['GET'], path_prefix='/simple/', credential=None), Allow(host='files.pythonhosted.org', methods=['GET'], path_prefix='/packages/', credential=None)][]| CLI | Python | What it does |
|---|---|---|
cere sandbox egress list ID |
sb.egress() |
The rules now |
cere sandbox egress allow ID RULE... |
sb.allow(*rules) |
Add rules. A rule for the same host, path prefix and credential as an existing one adds its methods to it; any other is put first |
cere sandbox egress remove ID HOST [--method M]... |
sb.remove_egress(host, methods=None) |
Remove a host’s rules, or only these methods of them (a rule left with no method goes) |
cere sandbox egress set ID RULE..., --none |
sb.set_egress(rules), sb.set_egress([]) |
Replace all rules; with none, the sandbox reaches no host |
allow and remove read the rules, change them and write the whole list back, so a change made elsewhere in
between is overwritten. A rule that names a secret is checked as at create.
Allow a host that was refused
Section titled “Allow a host that was refused”When a sandbox needs a host it was not given, the egress log shows the refusal, and you allow the host without restarting the sandbox:
cere sandbox exec $ID -- python fetch.py https://example.com/cere egress log --sandbox $ID --denied --limit 1cere sandbox egress allow $ID example.comcere sandbox exec $ID -- python fetch.py https://example.com/cere egress log --sandbox $ID --decision policy --limit 1refused: Tunnel connection failed: 403 ForbiddenTIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON2026-11-25T16:18:24Z sb-01m89r0gdsaf0znm34yxes5ec9 denied CONNECT example.com - 403 - 0 B - host not in the sandbox's allow-listHOST METHODS PATH CREDENTIALexample.com GET - -The rules apply from the sandbox's next request.200 <!doctype html><html lang=en><head><meta charset=utf-8>...TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON2026-11-25T16:18:30Z sb-01m89r0gdsaf0znm34yxes5ec9 policy GET example.com - - - 0 B - rule addedprint(sb.exec("python", "fetch.py", "https://example.com/").stdout.read(), end="")print(sb.allow("example.com"))print(sb.exec("python", "fetch.py", "https://example.com/").stdout.read()[:60])for e in cere.egress_log(sb.object_id, decision="policy", limit=1): print(e["ts"], e["method"], e["host"], e["path"], e["reason"])refused: Tunnel connection failed: 403 Forbidden[Allow(host='example.com', methods=['GET'], path_prefix=None, credential=None)]200 <!doctype html><html lang=en><head><meta charset=utf-8><2026-11-25T16:17:55.476502Z GET example.com None rule addedPath prefixes match whole segments
Section titled “Path prefixes match whole segments”A path prefix admits the path itself and everything under it, not paths that only start with the same letters. A
prefix that ends in / admits whatever starts with it.
cere sandbox egress set $ID httpbin.org:GET:/anything/docscere sandbox exec $ID -- python fetch.py https://httpbin.org/anything/docs/reportcere sandbox exec $ID -- python fetch.py https://httpbin.org/anything/docs-privateHOST METHODS PATH CREDENTIALhttpbin.org GET /anything/docs -The rules apply from the sandbox's next request.200 { "args": {}, ... "url": "https://httpbin.org/anything/docs/report", ...}403 {"error":"DDC egress proxy: GET httpbin.org/anything/docs-private is not allowed for this sandbox"}sb.set_egress(["httpbin.org:GET:/anything/docs"])for path in ("/anything/docs/report", "/anything/docs-private"): print(sb.exec("python", "fetch.py", "https://httpbin.org" + path).stdout.read()[:120])200 { "args": {}, "headers": { "Accept-Encoding": "identity", "Host": "httpbin.org", "User-Agent": "Pyth403 {"error":"DDC egress proxy: GET httpbin.org/anything/docs-private is not allowed for this sandbox"}What is never forwarded
Section titled “What is never forwarded”Some requests are refused whatever the rules say, and some headers never leave the sandbox:
| Request | Answer |
|---|---|
TRACE, TRACK, and CONNECT inside a connection, * rules included |
405; a rule that names one of them is refused |
| WebSocket and other protocol upgrades | 501 |
| A rule’s credential over plain HTTP | 403: secrets go only over HTTPS |
| HTTPS to a port other than 443, or to a host that resolves to a private or local address | 403 at the connection |
The headers Authorization, Proxy-Authorization, X-Api-Key, X-Auth-Token, Cookie, Forwarded, X-Forwarded-For |
Removed from every request; the only credential a request carries is the secret its rule names |
cere sandbox exec $ID -- python fetch.py https://httpbin.org/anything/docs TRACE405 {"error":"DDC egress proxy: TRACE is never forwarded"}print(sb.exec("python", "fetch.py", "https://httpbin.org/anything/docs", "TRACE").stdout.read(), end="")405 {"error":"DDC egress proxy: TRACE is never forwarded"}A request that sets its own credentials loses them on the way, and the host sees only the other headers:
cere sandbox exec $ID -- python -c "import urllib.request as uh = {'Authorization': 'Bearer mine', 'Cookie': 'a=b', 'X-Api-Key': 'k', 'X-Custom': 'kept'}print(u.urlopen(u.Request('https://httpbin.org/anything/docs', headers=h), timeout=20).read().decode())"{ "args": {}, "headers": { "Accept-Encoding": "identity", "Host": "httpbin.org", "User-Agent": "Python-urllib/3.12", "X-Custom": "kept" }, "method": "GET", ...}The proxy’s CA in the sandbox
Section titled “The proxy’s CA in the sandbox”The egress proxy terminates each HTTPS connection and presents a certificate signed by the cluster’s CA. The
sandbox has that CA at /etc/ddc/egress-ca.crt, and its environment points the usual variables at the proxy and
the CA:
cere sandbox exec $ID -- sh -c 'env | grep -E "PROXY|CERT|CA_" | sort'CURL_CA_BUNDLE=/etc/ddc/egress-ca.crtHTTPS_PROXY=http://10.200.0.1:3128HTTP_PROXY=http://10.200.0.1:3128NODE_EXTRA_CA_CERTS=/etc/ddc/egress-ca.crtNO_PROXY=localhost,127.0.0.1REQUESTS_CA_BUNDLE=/etc/ddc/egress-ca.crtSSL_CERT_FILE=/etc/ddc/egress-ca.crtprint(sb.exec("sh", "-c", 'env | grep -E "PROXY|CERT|CA_" | sort').stdout.read(), end="")CURL_CA_BUNDLE=/etc/ddc/egress-ca.crtHTTPS_PROXY=http://10.200.0.1:3128HTTP_PROXY=http://10.200.0.1:3128NODE_EXTRA_CA_CERTS=/etc/ddc/egress-ca.crtNO_PROXY=localhost,127.0.0.1REQUESTS_CA_BUNDLE=/etc/ddc/egress-ca.crtSSL_CERT_FILE=/etc/ddc/egress-ca.crtcurl, git, Node.js, pip, and Python’s ssl, urllib and requests read these. A program that verifies
against its own root set (Python’s certifi bundle, as httpx uses; Java’s trust store; a Go client with pinned
roots) must add /etc/ddc/egress-ca.crt itself. Agents: bring your own image
shows an entrypoint that does it for Python.
Errors
Section titled “Errors”The errors the tasks on this page can hit:
| Error | When | Example message |
|---|---|---|
400 credential_not_bound |
A rule names a secret for a host the secret is not bound to (at create or when changing egress) | secret "docs-echo" is not bound to host "postman-echo.com"; store it again with hosts ["httpbin.org", "postman-echo.com"] |
400 unknown_credential |
A rule names a secret the bucket does not have | unknown credential: docs-missing (set it with PUT /v1/secrets/docs-missing) |
409 not_running |
Changing the egress of a sandbox that has ended | sandbox sb-... is terminated: its egress rules no longer apply |
A secret’s hosts cannot change without its value: to send a secret to another host, store it again with every host it may go to. Every error code of the API is in HTTP API: errors.
Delete a secret
Section titled “Delete a secret”cere secret delete (cere.Secret.delete) removes a secret. A running sandbox whose rule names it gets 502 on
that host from then on. Delete the example’s secret and terminate both sandboxes:
cere secret delete docs-echorm docs-token.txtcere sandbox exec $ID2 -- python fetch.py https://httpbin.org/headerscere sandbox terminate $ID2cere sandbox terminate $IDDeleted secret docs-echo.502 {"error":"DDC egress proxy: credential missing"}sb-01m89qxggkh44jz46w4ranq5xq terminated: terminated by API...sb-01m89qx9w516mdxgcrf42tkzfp terminated: terminated by API...cere.Secret.delete("docs-echo")print(sb2.exec("python", "fetch.py", "https://httpbin.org/headers").stdout.read(), end="")sb2.terminate()sb.terminate()502 {"error":"DDC egress proxy: credential missing"}Related
Section titled “Related”- Next: Agents
- Egress and credentials: default deny, rules, secrets bound to hosts
- CLI:
cere sandbox egress,cere secret,cere egress log - Python SDK:
cere.Allow,cere.Secret,cere.egress_log