fix: prevent .env secret leakage into containers#419
Closed
roeeho-tr wants to merge 1 commit intoqwibitai:mainfrom
Closed
fix: prevent .env secret leakage into containers#419roeeho-tr wants to merge 1 commit intoqwibitai:mainfrom
roeeho-tr wants to merge 1 commit intoqwibitai:mainfrom
Conversation
…ing in db Mask the .env file inside the main group container by mounting /dev/null over it. Despite secrets being delivered via stdin and sanitized from env vars, the project-root bind mount exposed .env to the agent — allowing a simple `cat /workspace/project/.env` to read API keys. Also wrap JSON.parse(container_config) in db.ts with try/catch to prevent a persistent crash loop if the SQLite database contains corrupt JSON. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This was referenced Feb 23, 2026
This was referenced Mar 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
.envfile inside the main group container by mounting/dev/nullover/workspace/project/.env. Despite secrets being delivered via stdin and sanitized from environment variables by the Bash hook, the project-root bind mount exposed the.envfile directly — allowing the agent to read API keys with a simplecat /workspace/project/.env.JSON.parse(container_config)indb.tswith try/catch to prevent a persistent crash loop if the SQLite database contains corrupt JSON. Without this, a single corrupted row causesgetAllRegisteredGroups()/getRegisteredGroup()to throw on every startup attempt with no recovery path.Details
Secret leakage via mounted
.env(HIGH severity)The existing secret protection architecture is thorough:
container.stdin.write)inputafter delivery (delete input.secrets)createSanitizeBashHook)However,
buildVolumeMounts()bind-mounts the entire project root read-only at/workspace/project, which includes.env. Since the agent runs withpermissionMode: 'bypassPermissions', it can read the file directly, completely bypassing all three protections above.Fix: Mount
/dev/nullover/workspace/project/.envinside the container. Docker's mount overlay behavior ensures the more specific file mount takes precedence, replacing.envwith empty content.Unguarded
JSON.parsecrash loop (MEDIUM severity)getAllRegisteredGroups()andgetRegisteredGroup()indb.tscallJSON.parse(row.container_config)without error handling. If the SQLite DB is corrupted (power failure, disk error), a single bad row causes an unhandled exception duringloadState()at startup — creating a persistent crash loop.Fix: Wrap in try/catch, log a warning, and skip/return undefined for corrupt rows.
Test plan
.envcontents (cat /workspace/project/.envshould return empty)container_configrow in SQLitenpx tsc --noEmit— passes cleanly🤖 Generated with Claude Code