Skip to content

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)

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 six
cere sandbox exec $ID -- python -c "import six; print(six.__version__)"
1.17.0

A 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.

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.py
cere sandbox exec $ID -- python fetch.py https://example.com/
cere sandbox exec $ID -- python fetch.py https://pypi.org/pypi/six/json
wrote fetch.py (409 B) to sb-01m89qx9w516mdxgcrf42tkzfp:/workspace/fetch.py
refused: Tunnel connection failed: 403 Forbidden
403 {"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 --denied
cere egress log --sandbox $ID --decision allowed --limit 3
TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON
2026-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 sandbox
2026-11-25T16:16:41Z sb-01m89qx9w516mdxgcrf42tkzfp denied CONNECT example.com - 403 - 0 B - host not in the sandbox's allow-list
TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON
2026-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.

A refused host’s entry has the method CONNECT and no path: the proxy refused the connection before any request.

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 example
cere secret set docs-echo --header Authorization --host httpbin.org --bearer-file docs-token.txt
cere secret list
Stored secret docs-echo (header Authorization, 39 bytes), sent only to httpbin.org. Name it in an egress rule: --allow httpbin.org:<METHODS>:<path>:docs-echo
NAME TYPE HEADER HOSTS UPDATED
ddc-inference header Authorization inference-gateway.compute.dev.ddcdragon.com 9h02m ago
docs-echo header Authorization httpbin.org 0s ago
github-readonly header Authorization api.github.com 9h25m ago
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.

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.py
cere sandbox exec $ID2 -- python fetch.py https://httpbin.org/headers
wrote fetch.py (409 B) to sb-01m89qxggkh44jz46w4ranq5xq:/workspace/fetch.py
200 {
"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 $ID2
no credential in the environment
grep exit code: 1
TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON
2026-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.

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 $ID
cere sandbox egress allow $ID pypi.org:HEAD:/simple/
cere sandbox egress remove $ID pypi.org --method HEAD
cere sandbox egress set $ID --none
HOST METHODS PATH CREDENTIAL
pypi.org GET /simple/ -
files.pythonhosted.org GET /packages/ -
HOST METHODS PATH CREDENTIAL
pypi.org GET,HEAD /simple/ -
files.pythonhosted.org GET /packages/ -
The rules apply from the sandbox's next request.
HOST METHODS PATH CREDENTIAL
pypi.org GET /simple/ -
files.pythonhosted.org GET /packages/ -
The rules apply from the sandbox's next request.
HOST METHODS PATH CREDENTIAL
No rules: the sandbox reaches no host.
The rules apply from the sandbox's next request.
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.

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 1
cere sandbox egress allow $ID example.com
cere sandbox exec $ID -- python fetch.py https://example.com/
cere egress log --sandbox $ID --decision policy --limit 1
refused: Tunnel connection failed: 403 Forbidden
TIME SANDBOX DECISION METHOD HOST PATH STATUS CREDENTIAL DOWN MS REASON
2026-11-25T16:18:24Z sb-01m89r0gdsaf0znm34yxes5ec9 denied CONNECT example.com - 403 - 0 B - host not in the sandbox's allow-list
HOST METHODS PATH CREDENTIAL
example.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 REASON
2026-11-25T16:18:30Z sb-01m89r0gdsaf0znm34yxes5ec9 policy GET example.com - - - 0 B - rule added

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/docs
cere sandbox exec $ID -- python fetch.py https://httpbin.org/anything/docs/report
cere sandbox exec $ID -- python fetch.py https://httpbin.org/anything/docs-private
HOST METHODS PATH CREDENTIAL
httpbin.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"}

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 TRACE
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 u
h = {'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 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.crt
HTTPS_PROXY=http://10.200.0.1:3128
HTTP_PROXY=http://10.200.0.1:3128
NODE_EXTRA_CA_CERTS=/etc/ddc/egress-ca.crt
NO_PROXY=localhost,127.0.0.1
REQUESTS_CA_BUNDLE=/etc/ddc/egress-ca.crt
SSL_CERT_FILE=/etc/ddc/egress-ca.crt

curl, 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.

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.

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-echo
rm docs-token.txt
cere sandbox exec $ID2 -- python fetch.py https://httpbin.org/headers
cere sandbox terminate $ID2
cere sandbox terminate $ID
Deleted secret docs-echo.
502 {"error":"DDC egress proxy: credential missing"}
sb-01m89qxggkh44jz46w4ranq5xq terminated: terminated by API
...
sb-01m89qx9w516mdxgcrf42tkzfp terminated: terminated by API
...