security: gate command DSL health checks on isEmbedded#106
Open
garagon wants to merge 1 commit intogarrytan:masterfrom
Open
security: gate command DSL health checks on isEmbedded#106garagon wants to merge 1 commit intogarrytan:masterfrom
garagon wants to merge 1 commit intogarrytan:masterfrom
Conversation
The typed DSL 'command' case in executeHealthCheck runs spawnSync without checking isEmbedded. A CWD recipe can execute arbitrary binaries. Block command checks for non-embedded recipes.
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
gbrain integrations doctorruns health checks from recipe YAML files. In v0.9.3,a typed DSL was added with 4 check types:
http,env_exists,command, andany_of.The
commandtype runs a binary viaspawnSync.The problem: recipes can be loaded from
recipes/in the current working directory.The old string-based health checks had an
isUnsafeHealthCheck()guard for non-embeddedrecipes, but the new
commandDSL type skips that check entirely. A malicious recipein CWD with a
commandhealth check executes arbitrary binaries ongbrain integrations doctor.What the fix does
Before calling
spawnSync, the handler checksisEmbedded. If the recipe is NOTfirst-party (loaded from CWD), the command check returns
status: 'blocked'withoutexecuting anything. First-party recipes continue to work as before.
Changes
src/commands/integrations.tsisEmbeddedgate at the top of thecommandcase, beforespawnSynctest/integrations.test.tsisEmbedded=falsereturns blockedisEmbedded=trueValidation
bun test test/integrations.test.ts— 38 pass, 0 fail