Files
w3cjandClaude Opus 5.5 fcbab78670 refactor(secrets): one path for secrets, placeholders on every tier
Every VM gets its CA, its proxy setup and placeholders, whatever its
tier, so even an open VM never holds a real secret: a request that goes
around its proxy carries only the placeholder.

- vm/sync.go: the open branches of stage go (the agents' logins copied
  as they are, the ClaudeCopy for unconfined VMs and its MCP warning,
  real values in ~/.config/devvm/env); stageNet is stageSecrets, run
  for every VM, and the salt is every VM's.
- netpolicy: Prepare readies the CAs, salt and secret files on every
  tier, and the proxy config carries the CAs and bindings on every tier;
  dropCA and its caller are gone, so a VM keeps its CAs as its tier
  changes.
- Removed without a caller left: the messages secret_unuse_copied,
  net_on_old_tokens and claude_mcp_secrets_copied;
  secrets.Store.ClaudeCopy and MCPSecrets; agentlogin.MCPSecrets,
  claudeSecrets and argsHoldSecrets; settings.CompanyProxy.ConfigOnly.
- Tests: TestPrepareOpen (open has CAs, salt, secrets; CAs kept across
  tiers), TestInterceptOpen (an open proxy puts secrets in, 421 for
  another host), TestStageSecretsEveryTier (every tier's setup sends
  the VM's CAs, the guard against a tier's own path); sync, ca, network
  and secret scripts for open VMs.
- e2e: network checks that an open VM holds no real secret (its proxy
  puts the token in over TLS the VM verifies, a direct request carries
  only the placeholder and gets a 401); project checks an open VM's
  placeholder, and its company-CA checks allow for the VM's own CAs in
  /etc/ssl/devvm.pem.
- Docs: safety/network (tiers, secrets), internals/network, the design
  note's tiers threat check, attack vectors, coding agents, first VM,
  staying safe, contributing; devvm secret's help.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-05 15:55:21 -07:00

109 lines
4.4 KiB
Plaintext

# The user's CAs (a company's): every *.pem and *.crt in devvm's CA
# folder reaches a VM's setup, only the certificates parsed out of it; a
# file holding anything else fails the launch, naming it; devvm doctor
# says where a proxy that inspects TLS needs its CA.
env CAS=$XDG_CONFIG_HOME/devvm/ca
# No folder: nothing sent but ca.sh and the VM's own CAs, an open VM's
# too, and every VM's environment points tools at the CAs all the same,
# set when it's made: its start's one edit adds its proxy, an open VM's
# included, the password's stand-in alone.
project none
exec devvm --network open --no-git-protect
exec tar -tf $STUB_DIR/sync.tar
stdout '^ca\.sh$'
stdout '^ca/devvm-proxy\.crt$'
stdout '^ca/devvm-proxy-next\.crt$'
! stdout '^ca/devvm-extra'
stub_calls
stdout '^limactl clone --tty=false \S+ devvm-none-[0-9a-f]{14} .* --set \.env = \{"NODE_EXTRA_CA_CERTS":"/etc/ssl/devvm\.pem","PIP_CERT":"/etc/ssl/certs/ca-certificates\.crt","REQUESTS_CA_BUNDLE":"/etc/ssl/certs/ca-certificates\.crt","SSL_CERT_FILE":"/etc/ssl/certs/ca-certificates\.crt","UV_SYSTEM_CERTS":"1"\}$'
stdout '^limactl edit --tty=false devvm-none-[0-9a-f]{14} --set \.env = \{"HTTPS_PROXY":"http://devvm:devvm-proxy-password@192\.168\.5\.2:[0-9]+",.*"NODE_EXTRA_CA_CERTS":"/etc/ssl/devvm\.pem",'
# A CA, in a file with text around it, and a file of another name, left
# alone: the certificate alone is sent.
mkdir $CAS
cp $WORK/company.pem $CAS/company.pem
cp $WORK/notes.txt $CAS/notes.txt
project one
exec devvm --network open --no-git-protect
exec tar -tf $STUB_DIR/sync.tar
stdout '^ca/devvm-extra-1\.crt$'
! stdout '^ca/devvm-extra-2'
exec tar -xOf $STUB_DIR/sync.tar ca/devvm-extra-1.crt
cmp stdout $WORK/ca-only.pem
# A private key fails the launch, naming the file; so does a certificate
# that isn't a CA's.
cp $WORK/key.pem $CAS/key.pem
project key
! exec devvm --network open --no-git-protect
stderr '^devvm: ca_not_certificate file=\S*/config/devvm/ca/key\.pem$'
rm $CAS/key.pem
cp $WORK/leaf.pem $CAS/leaf.crt
! exec devvm --network open --no-git-protect
stderr '^devvm: ca_not_ca file=\S*/config/devvm/ca/leaf\.crt$'
rm $CAS/leaf.crt
# doctor: with HTTPS_PROXY set and no CA in the folder, a line saying so.
exec devvm doctor
! stdout doctor_proxy_ca
env HTTPS_PROXY=http://proxy.example:3128
exec devvm doctor
! stdout doctor_proxy_ca
rm $CAS/company.pem
exec devvm doctor
stdout '^doctor_proxy_ca dir=\S*/config/devvm/ca$'
env HTTPS_PROXY=
exec devvm doctor
! stdout doctor_proxy_ca
# config.toml's company proxy counts as HTTPS_PROXY does.
cp $WORK/proxy.toml $CFG/config.toml
exec devvm doctor
stdout '^doctor_proxy_ca dir=\S*/config/devvm/ca$'
rm $CFG/config.toml
-- proxy.toml --
[proxy]
https = "http://proxy.example:3128"
-- company.pem --
# Company root, exported from the host's store
-----BEGIN CERTIFICATE-----
MIIBVjCB/aADAgECAhQ2DjUE5GCuu3ghlAaTzuuBTKpHPzAKBggqhkjOPQQDAjAY
MRYwFAYDVQQDDA1kZXZ2bSB0ZXN0IENBMCAXDTI2MTAzMTAwNDM1MloYDzIxMjYx
MDA3MDA0MzUyWjAYMRYwFAYDVQQDDA1kZXZ2bSB0ZXN0IENBMFkwEwYHKoZIzj0C
AQYIKoZIzj0DAQcDQgAEXBvNefEBySKRQIYneFCwVPU9XeTIb9BQmqWNOzHUUZ14
yJRSOti9OaVDmBkNGfc8s9Y6EH+kO0OUh7d/ZobZaKMjMCEwDwYDVR0TAQH/BAUw
AwEB/zAOBgNVHQ8BAf8EBAMCAgQwCgYIKoZIzj0EAwIDSAAwRQIgEzyH5x1Z+iba
nf2OXZ+UmygJuhGk1Wbhqk3OSSCAPKYCIQCSBQAoZ0blPVefpXNe9FNJEicksKlE
Ak+ibQllnrw4LA==
-----END CERTIFICATE-----
private notes after it
-- ca-only.pem --
-----BEGIN CERTIFICATE-----
MIIBVjCB/aADAgECAhQ2DjUE5GCuu3ghlAaTzuuBTKpHPzAKBggqhkjOPQQDAjAY
MRYwFAYDVQQDDA1kZXZ2bSB0ZXN0IENBMCAXDTI2MTAzMTAwNDM1MloYDzIxMjYx
MDA3MDA0MzUyWjAYMRYwFAYDVQQDDA1kZXZ2bSB0ZXN0IENBMFkwEwYHKoZIzj0C
AQYIKoZIzj0DAQcDQgAEXBvNefEBySKRQIYneFCwVPU9XeTIb9BQmqWNOzHUUZ14
yJRSOti9OaVDmBkNGfc8s9Y6EH+kO0OUh7d/ZobZaKMjMCEwDwYDVR0TAQH/BAUw
AwEB/zAOBgNVHQ8BAf8EBAMCAgQwCgYIKoZIzj0EAwIDSAAwRQIgEzyH5x1Z+iba
nf2OXZ+UmygJuhGk1Wbhqk3OSSCAPKYCIQCSBQAoZ0blPVefpXNe9FNJEicksKlE
Ak+ibQllnrw4LA==
-----END CERTIFICATE-----
-- notes.txt --
not read
-- key.pem --
-----BEGIN PRIVATE KEY-----
bm90IGEgcmVhbCBrZXk=
-----END PRIVATE KEY-----
-- leaf.pem --
-----BEGIN CERTIFICATE-----
MIIBLzCB1aADAgECAhQXr0UE++pou69U5JDtjV1zFBCNNzAKBggqhkjOPQQDAjAP
MQ0wCwYDVQQDDARsZWFmMCAXDTI2MTAzMTAwNDM1MloYDzIxMjYxMDA3MDA0MzUy
WjAPMQ0wCwYDVQQDDARsZWFmMFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAES69N
XrRKTXz5vBBJ55BJiCdDmSzO1oaNuhb3MWhJgqatEHisX2GRzGPyfLyKGSQFWb8N
UcvUhwEkgidSRuw75aMNMAswCQYDVR0TBAIwADAKBggqhkjOPQQDAgNJADBGAiEA
0xsMLZD1kLX0H8ik71fAVBLk+viVIhMhpL0PCo3wKK8CIQDYyLf0V4RtpXG+GMy5
3b0vAUwkAt/bJaI4N9lb0LZZLg==
-----END CERTIFICATE-----