Skip to sessions and notes

These session notes are AI-generated and may contain mistakes. Verify important details against the original recording.

Protect your PC from AI coding agents while modernising legacy .NET apps

Justin Yoo

Session · 29:08 recording · 13 min read

At a glance

  • Solving the agent security dilemma: Permission to Run (Approval) vs. Permission to Reach (Boundary)
  • The peril of --allow-all (YOLO mode): bypasses prompt confirmations without restricting resource reach
  • Threat model of legacy modernization (Contoso University): .NET 4.8, MVC 5, LocalDB, MSMQ, web.config secrets
  • The Three Imperatives: Protect PC filesystem, Protect Credentials & Tokens, and Control Outbound Egress
  • Tier 1: Local Sandboxing: Built into GitHub Copilot CLI (/sandbox enable); enforces repo root boundary on Windows host

Executive Summary

As AI coding agents like GitHub Copilot CLI, Claude Code, and agentic IDE plugins evolve from simple autocompletion into autonomous systems performing complex workflows—such as multi-step legacy application modernization—developers face an acute security dilemma. When modernizing monolithic .NET Framework applications (.NET 4.8, ASP.NET MVC 5, WCF, MSMQ, LocalDB), agents require broad tooling access: reading project files, inspecting web.config and packages.config, invoking compilers, querying databases, running shell scripts, and calling Model Context Protocol (MCP) servers.

To prevent fatigue from constant confirmation prompts, developers frequently resort to --allow-all (informally termed "YOLO mode"). However, permission to run is not permission to reach. Bypassing interactive prompts does nothing to constrain the agent's blast radius; an unconstrained agent can read arbitrary files outside the repository, exfiltrate API tokens and connection strings, or make unauthorized external network connections.

In this session, Justin Yoo systematically analyzes the threat boundaries of autonomous coding agents and presents three sandboxing architectures:

  1. Local Sandboxing (Built-in Copilot CLI Sandbox): Restricts file access and command boundaries directly on the developer's Windows host. Essential when modernization requires Windows-only build tools (MSBuild, .NET 4.8 targeting packs, IIS Express).
  2. Docker Sandboxes (sbx Linux MicroVM): Encapsulates Copilot CLI, plugins, local MCP servers, and cloned code inside an isolated Linux virtual machine with its own kernel, private Docker daemon, credential masking proxy, and network filtering.
  3. Azure Container Apps (ACA) Dynamic Sandboxes: Runs isolated microVMs in the cloud, offloading compute from local developer machines, enabling team collaboration, and confining blast radius entirely within Azure.

Yoo demonstrates these patterns in action against Contoso University, proving how to isolate filesystem access, mask credentials via proxy headers, enforce strict network policies, and ensure that changes made inside sandboxes are audited through Git before merging into the host codebase.


Visual Timeline & Key Moments

Timestamp Screenshot Core Technical Topic
00:00:18 01-title-protect-pc-ai-agents.jpg Session introduction: Justin Yoo on securing developer PCs during AI-driven modernization.
00:01:25 02-permission-to-run-vs-reach.jpg "Permission to Run vs. Permission to Reach": The fatal flaw of relying solely on /allow-all.
00:02:18 03-legacy-app-trust-boundaries.jpg Contoso University trust boundaries: .NET Framework 4.8, MVC 5, LocalDB, MSMQ, web.config.
00:03:30 04-three-protection-imperatives.jpg The Three Imperatives: Protect PC filesystem, Protect Credentials & Tokens, Control Egress.
00:05:15 05-three-sandbox-models-compared.jpg Architectural comparison: Local Sandbox vs. Docker MicroVM vs. Azure Container Apps Sandbox.
00:07:20 06-local-sandbox-architecture.jpg Local Sandbox internals: Windows OS restrictions, harness policy interception, built-in tool enforcement.
00:09:55 07-demo1-sandbox-enable-status.jpg Demo 1: Enabling local sandbox (/sandbox enable), inspecting active policy with /sandbox status.
00:11:45 08-demo1-plan-generated-in-boundary.jpg Demo 1: Copilot generating sandbox-demo-plan.md safely inside the repository boundary.
00:12:35 09-demo1-out-of-bound-access-denied.jpg Demo 1: Attempted access outside the repo boundary denied; SHA-256 hash verified unchanged (077...).
00:14:45 10-docker-sandbox-architecture.jpg Docker Sandbox Architecture: MicroVM, private Docker daemon, cloned repository, auth proxy.
00:17:35 11-demo2-docker-sbx-credential-proxy.jpg Demo 2: Launching sbx run --clone Contoso; verifying masked token gho_sbx_proxy_managed_0000....
00:19:15 12-demo2-network-policy-enforcement.jpg Demo 2: Network egress policy blocking bing.com & google.com, while permitting local MCP tools.
00:21:40 13-demo2-sandbox-git-commit-isolation.jpg Demo 2: Assessment report generated & committed to sandbox branch app-mode-assessment (FFBA...).
00:23:15 14-demo2-host-remote-review-merge.jpg Demo 2: Host repository intact at 7C1B; fetching sandbox-contoso remote for human audit & merge.
00:26:45 15-sandbox-model-selection-guide.jpg Selection Guide: Matching Windows tooling, local VM isolation, or cloud scale to project constraints.
00:28:15 16-constrain-observe-review-summary.jpg Summary: The Triad of Defense—Constrain, Observe, and Review.

1. The Core Problem: Permission to Run vs. Permission to Reach

Autonomous coding agents need autonomy to execute complex, multi-turn goals. In a legacy modernization engagement, an agent may need to:

  • Read hundreds of .cs, .csproj, packages.config, and web.config files.
  • Invoke command-line tools (dotnet, msbuild, nuget restore, git).
  • Call Model Context Protocol (MCP) tools for semantic code search, dependency vulnerability auditing, and documentation retrieval.

The Danger of --allow-all (YOLO Mode)

When developers grow weary of approving every shell command or file edit, they trigger /allow-all (or pass --allow-all on CLI startup).

┌─────────────────────────────────────────────────────────────┐
│                    PERMISSION TO RUN                        │
│            (Approval Side / Human Prompts)                  │
│                                                             │
│   [Normal Mode]  ──Prompt──> "Allow agent to execute cmd?"  │
│   [/allow-all]   ──Bypass──> Automatically answers "Yes"    │
└──────────────────────────────┬──────────────────────────────┘
                               │ DOES NOT RESTRICT
                               ▼
┌─────────────────────────────────────────────────────────────┐
│                   PERMISSION TO REACH                       │
│            (Boundary Side / Isolation Scope)                │
│                                                             │
│   • Can agent read C:\Users\<name>\.ssh or .aws\credentials?│
│   • Can agent scan the local subnet / intranet databases?   │
│   • Can agent curl external webhooks with exfiltrated data? │
│   • Can agent mutate files in other repositories?           │
└─────────────────────────────────────────────────────────────┘

[!WARNING]
Setting /allow-all without a sandbox grants the agent unrestricted user-level access to everything the developer account can reach: private keys, environment variables, local Docker sockets, corporate VPN-accessible intranets, and parent directories.


2. Threat Modeling a Legacy .NET Modernization Target

The session centers on modernizing Contoso University, an archetypal legacy enterprise application:

  • Target Runtime: .NET Framework 4.8.
  • Web Layer: ASP.NET MVC 5 running under IIS Express.
  • Dependencies: Legacy packages.config with hundreds of transitive NuGet packages stored in local machine package caches (%USERPROFILE%\.nuget\packages and solution-level packages/).
  • Configuration & Secrets: web.config containing plain-text connection strings to LocalDB, app keys, and API secrets.
  • Enterprise Messaging: Microsoft Message Queuing (MSMQ) dependencies.
  • Lifecycle: Monolithic Global.asax.cs handling application startup, session state, and security filters.

The Three Imperatives of Agent Sandboxing

graph TD
    subgraph Imperatives["The 3 Sandboxing Imperatives"]
        P1["1. Protect Your PC<br/>• Restrict filesystem scope<br/>• Deny writes outside repo root<br/>• Prevent host daemon compromise"]
        P2["2. Protect Credentials & Tokens<br/>• Mask Git & Copilot auth tokens<br/>• Redact connection strings<br/>• Intercept credential reads via proxy"]
        P3["3. Control Egress Traffic<br/>• Block arbitrary external HTTP/HTTPS<br/>• Deny untrusted web search<br/>• Force traffic through verified MCP gateways"]
    end
  1. Protect the Host PC: The agent must be restricted to a strictly bounded workspace. It must not be permitted to read or mutate files outside the defined project tree.
  2. Protect Tokens and Credentials: Modernization tools and configurations frequently contain secrets. An agent reading web.config or checking .git/config can easily expose corporate credentials. Tokens passed to agents must be ephemeral or masked by a credential proxy.
  3. Control Egress Traffic: Isolate the execution environment from the open internet. Just because an agent runs inside a container does not prevent it from opening outbound HTTP connections to exfiltrate code or download malicious payloads.

3. Sandboxing Architecture Comparison

Justin Yoo breaks down three distinct sandboxing tiers:

flowchart TD
    subgraph LocalSandbox["Tier 1: Local Sandbox"]
        direction TB
        L_Host["Windows Host OS"]
        L_CLI["GitHub Copilot CLI"]
        L_Pol["Harness / CLI Policy Layer"]
        L_FS["Host File System (Policy Guarded)"]
        L_Host --- L_CLI --> L_Pol --> L_FS
    end

    subgraph DockerSandbox["Tier 2: Docker Sandbox (sbx)"]
        direction TB
        D_Host["Host Machine (Git Review / Merge)"]
        D_VM["Linux MicroVM (Isolated Kernel)"]
        D_Proxy["Credential & Network Proxy"]
        D_CLI["Copilot CLI + Local MCPs"]
        D_Docker["Private VM Docker Daemon"]
        D_Repo["Cloned Repo Copy"]
        D_Host <== "Git Remote Fetch / Diff" ==> D_VM
        D_VM --- D_Proxy --> D_CLI --> D_Repo
        D_CLI --> D_Docker
    end

    subgraph ACASandbox["Tier 3: Azure Container Apps Sandbox"]
        direction TB
        A_Dev["Developer PC (Control & Policy Review)"]
        A_Cloud["Azure Dynamic Sandbox MicroVM"]
        A_CLI["Copilot CLI + Build Chain"]
        A_Egress["Explicit Ingress / Egress Rules"]
        A_Dev <== "Secure Management Channel" ==> A_Cloud
        A_Cloud --- A_Egress --> A_CLI
    end

Architectural Feature Matrix

Feature Tier 1: Local Sandbox Tier 2: Docker Sandbox (sbx) Tier 3: Azure Container Apps
Host Boundary Same OS process tree; software intercept Isolated Linux MicroVM kernel Cloud MicroVM (Hyper-V / Azure hypervisor)
Windows Tooling Support Full (MSBuild, .NET 4.8, IIS Express) Linux only (Wine/mono or cross-platform .NET) Linux only (Ubuntu base image)
Docker Daemon Isolation Shared with host Docker daemon Private VM Docker daemon (zero host risk) Isolated containerized runtime
Credential Protection OS user-level permissions Proxy Managed Token (gho_sbx_proxy...) Managed Identity / Secret Store injection
Egress Filtering Policy-dependent Deny-by-default Proxy Open by default; requires explicit network policy
Filesystem Safety Host filesystem; in-place edits Cloned isolated repository; git remote merge Remote cloud filesystem; push to git branch
Ideal Use Case Legacy .NET Framework Windows-only builds Local developer deep isolation & Linux apps Team collaboration, overnight batch jobs, CI/CD

4. Deep Dive: Tier 1 — Local Sandboxing

When modernizing a .NET Framework 4.8 application, the build system often requires native Windows components:

  • Full MSBuild (C:\Program Files\Microsoft Visual Studio\...\MSBuild\Current\Bin\MSBuild.exe).
  • Windows-specific targeting packs and SDK references.
  • LocalDB / SQL Server Express instances registered with Windows Named Pipes.

In this scenario, running the agent inside a Linux container fails because the build tools are Windows-only. The Local Sandbox feature built directly into GitHub Copilot CLI provides policy-based enforcement on the Windows host.

Demo 1 Walkthrough: Policy Verification and Boundary Rejection

# Terminal 1: Host setup before agent execution
# Generate a canary file OUTSIDE the repository root:
$hash = Get-FileHash ..\secret_outside.txt -Algorithm SHA256
# Result: 077a94f...
# Terminal 2: GitHub Copilot CLI Session
/model Copilot Fusion
/allow-all
/sandbox enable
/sandbox status
# Status Output:
#   Current Sandbox Status: ENABLED
#   Credentials: Protected
#   Filesystem: Bounded to repository root (C:\Code\ContosoUniversity)
#   Network: Policy Enforced

/sandbox policy
# Lists explicit whitelist of allowed commands, paths, and MCP tools
  1. Inside-Boundary Request:

    > "Inspect ContosoUniversity.csproj and web.config, then create a markdown file 
       named sandbox-demo-plan.md detailing Windows-only dependencies."
    

    Result: Copilot successfully reads the configuration files and writes sandbox-demo-plan.md into the repository. The developer verifies the file using Notepad on the host.

  2. Outside-Boundary Tamper Attempt:

    > "Read and append modernizing notes to ..\secret_outside.txt"
    

    Result: The local sandbox harness intercepts the syscall and emits:

    [SANDBOX VIOLATION] Access to file path outside the repository root is denied:
    ..\secret_outside.txt
    
  3. Integrity Verification on Host:

    $after = Get-FileHash ..\secret_outside.txt -Algorithm SHA256
    ($hash.Hash -eq $after.Hash)
    # Returns: True (077a94f... matches exactly; zero bytes modified)
    

5. Deep Dive: Tier 2 — Docker Sandboxes (sbx)

For modernized microservices, .NET 10/11 components, or when maximum blast-radius isolation is mandatory, Docker Sandboxes (sbx) places the Copilot CLI, all plugins, and local MCP servers inside an isolated Linux microVM.

The Credential Proxy Pattern

In traditional container setups, developers pass their actual GitHub Personal Access Token (PAT) via environment variables (-e GITHUB_TOKEN=$TOKEN). If an agent is tricked into reading environment variables or running printenv, the secret is compromised.

Docker Sandboxes solves this via an authentication proxy:

sequenceDiagram
    participant Host as Host Machine
    participant Proxy as sbx Credential Proxy
    participant VM as MicroVM Agent (Copilot CLI)
    participant GitHub as GitHub API / Remote

    Host->>Proxy: Inject Real PAT into Host Proxy Table
    Proxy->>VM: Mint Synthetic Token: gho_sbx_proxy_managed_0000...
    Note over VM: Agent inspects environment:<br/>Only sees dummy synthetic token!
    VM->>Proxy: Git / API Request with synthetic token
    Proxy->>Proxy: Validate Request against Policy & Swap Real Token
    Proxy->>GitHub: Forward Request with Real Token
    GitHub-->>Proxy: Response Payload
    Proxy-->>VM: Filtered Response Payload

In the session demo, Justin executes env inside the sandbox bash shell:

$ sbx exec Contoso bash
root@contoso-sandbox:/workspace# echo $GITHUB_TOKEN
gho_sbx_proxy_managed_000000000000000000000000000000000000

The real secret never enters the virtual machine's memory space.

Network Policy Enforcement

The sandbox proxy inspects all outbound DNS and HTTP/S calls against a declarative policy whitelist:

# Direct outbound curl requests from inside the sandbox:
root@contoso-sandbox:/workspace# curl -I https://www.google.com
curl: (7) Failed to connect: Approval required / Network policy denied.

root@contoso-sandbox:/workspace# curl -I https://www.bing.com
curl: (7) Failed to connect: Approval required / Network policy denied.

When Copilot CLI is prompted to find information about .NET Conf 2026:

  • It does not make arbitrary raw browser calls to search engines.
  • Instead, it routes the query through the pre-approved GitHub MCP Server (Web Search Tool) running on the host-mediated channel, which sanitizes queries and returns structured context blocks.

The Git Isolation & Review Workflow

Rather than mounting the host repository directly as a shared read-write volume (which risks catastrophic agent mistakes like git reset --hard or unreviewed file deletion), sbx run --clone performs a full clone inside the microVM.

flowchart LR
    subgraph HostRepo["Host Machine Repository"]
        H_Main["main (Commit: 7C1B...)"]
    end

    subgraph SandboxRepo["Sandbox MicroVM (Cloned)"]
        S_Branch["app-mode-assessment (Commit: FFBA...)"]
    end

    S_Branch -- "1. Agent Commits Internally" --> S_Branch
    HostRepo -. "Host remains untouched at 7C1B" .-> HostRepo
    H_Main -- "2. git fetch sandbox-contoso" --> SandboxRepo
    H_Main -- "3. git diff & Human Review" --> H_Main
    H_Main -- "4. git merge" --> H_Main
  1. Inside the sandbox, the custom modernize agent runs the assessment, generates latest.html, creates branch app-mode-assessment, and commits with hash FFBA....
  2. On the host machine, git branch and git status show the working directory is pristine and HEAD is still at 7C1B....
  3. The developer runs:
    git remote -v
    # origin           https://github.com/contoso/university.git (fetch/push)
    # sandbox-contoso  docker-sbx://contoso (fetch/push)
    
    git fetch sandbox-contoso
    git diff main..sandbox-contoso/app-mode-assessment
    # Developer performs rigorous human-in-the-loop audit
    git merge sandbox-contoso/app-mode-assessment
    

6. Deep Dive: Tier 3 — Azure Container Apps (ACA) Dynamic Sandboxes

When an organization needs to modernize a fleet of legacy applications or allow agents to run prolonged refactoring jobs without locking up developer laptops, Azure Container Apps Sandboxes provides cloud-hosted isolation.

Why ACA Sandboxes?

  • Compute Scalability: Complex static analysis, AST rewriting, and test suite execution can consume significant CPU and RAM. ACA sandboxes scale compute elastically on demand.
  • Asynchronous Collaboration: If a developer signs off for the day or goes on leave, a cloud sandbox allows teammates to inspect the agent's progress, review diffs, or continue steering without transferring local VM states.
  • Zero Local Footprint: Developer machines serve purely as review and policy control surfaces.

Critical Security Caveat: Egress Lockdown

Unlike Docker local sandboxes which can be configured deny-all by default, cloud environments typically provide unrestricted outbound internet access to allow package restoration.

[!IMPORTANT]
When provisioning an ACA Dynamic Sandbox for autonomous agents:

  1. Explicitly configure Azure Network Security Group (NSG) rules or Container App Ingress/Egress policies to prevent data exfiltration.
  2. Enforce strict RBAC: only authorized modernization team members should possess access tokens to connect to the cloud sandbox instance.
  3. Disallow public IP assignment to the container instance; route traffic through an internal Azure AI Gateway with token auditing.

7. The Triad of Defense: Constrain, Observe, Review

Justin Yoo concludes with an actionable architectural governance framework for AI coding agents:

                  ┌───────────────────────────────┐
                  │          CONSTRAIN            │
                  │  • Boundary location (VM/Host)│
                  │  • Filesystem root boundaries │
                  │  • Network egress policies    │
                  └──────────────┬────────────────┘
                                 │
                                 ▼
                  ┌───────────────────────────────┐
                  │           OBSERVE             │
                  │  • Audit real-time tool calls │
                  │  • Inspect denied operations  │
                  │  • Track token & proxy usage  │
                  └──────────────┬────────────────┘
                                 │
                                 ▼
                  ┌───────────────────────────────┐
                  │            REVIEW             │
                  │  • Human-in-the-loop diffs    │
                  │  • Git remote fetch/audit     │
                  │  • Verify build & test passes │
                  └───────────────────────────────┘
  1. Constrain: Explicitly bound the runtime environment where the agent and its toolchain operate. Choose the sandboxing tier that fits your build dependencies (Windows host sandbox vs. Linux microVM). Never permit an agent to operate in an unconfined workspace with /allow-all.
  2. Observe: Actively log and monitor what tools, files, and endpoints the agent attempts to touch. When an operation is denied, do not blindly disable the sandbox; instead, evaluate whether that specific tool or path should be granted minimal necessary permissions in a fresh session.
  3. Review: Treat all AI-generated code as untrusted input. Isolate changes to cloned workspaces and sandbox-specific Git remotes. Inspect AST diffs, verify security regressions, and only merge into production branches after human review.

Technical Recommendations for .NET Engineering Teams

  1. Audit Agent Permissions Today: Audit internal team workflows to see how many developers are running GitHub Copilot CLI or Claude Code with --allow-all on un-sandboxed host machines.
  2. Adopt sbx for Cloud-Native / .NET 11 Services: For any application targeting modern .NET, adopt Docker Sandboxes (sbx) as standard developer infrastructure to isolate MCP servers and tokenize API keys.
  3. Use Local Sandboxing for .NET Framework 4.8: When legacy Windows MSBuild dependencies preclude Linux containers, activate Copilot CLI's /sandbox enable mode to constrain file writes strictly within the solution folder.
  4. Enforce Branch-Based Ingestion: Never let an agent write directly to main or push straight to origin. Always require agents to commit to an isolated sandbox branch, followed by a human git fetch and pull request review.