From 5203cb53ba650f8faae2b7226dbbfb7e2996e8e5 Mon Sep 17 00:00:00 2001 From: Brad Lhotsky Date: Fri, 24 Apr 2026 10:04:00 -0400 Subject: [PATCH] Address Potential Container Escape via git (#42) This patch prevents claude from manipulating `.git/hooks` or `.git/config` which could result in unintended code execution outside the devcontainer. As an example, ask claude to create a git hook to print "Hello World" on commit or push. Outside of the devcontainer, the git status is clean, but running `git commit` or `git push` will result in printing "Hellow World". Credit for this disovery to @tillberg. --- devcontainer.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devcontainer.json b/devcontainer.json index b10a841..d6b513a 100644 --- a/devcontainer.json +++ b/devcontainer.json @@ -46,7 +46,9 @@ "source=devc-${localWorkspaceFolderBasename}-config-${devcontainerId},target=/home/vscode/.claude,type=volume", "source=devc-${localWorkspaceFolderBasename}-gh-${devcontainerId},target=/home/vscode/.config/gh,type=volume", "source=${localEnv:HOME}/.gitconfig,target=/home/vscode/.gitconfig,type=bind,readonly", - "source=${localWorkspaceFolder}/.devcontainer,target=/workspace/.devcontainer,type=bind,readonly" + "source=${localWorkspaceFolder}/.devcontainer,target=/workspace/.devcontainer,type=bind,readonly", + "source=${localWorkspaceFolder}/.git/config,target=/workspace/.git/config,type=bind,readonly", + "source=${localWorkspaceFolder}/.git/hooks,target=/workspace/.git/hooks,type=bind,readonly" ], "containerEnv": { "NODE_OPTIONS": "--max-old-space-size=4096",