Skip to content

security: gate command DSL health checks on isEmbedded#106

Open
garagon wants to merge 1 commit intogarrytan:masterfrom
garagon:security/r5-f002-command-dsl-embedded-gate
Open

security: gate command DSL health checks on isEmbedded#106
garagon wants to merge 1 commit intogarrytan:masterfrom
garagon:security/r5-f002-command-dsl-embedded-gate

Conversation

@garagon
Copy link
Copy Markdown
Contributor

@garagon garagon commented Apr 13, 2026

Summary

gbrain integrations doctor runs health checks from recipe YAML files. In v0.9.3,
a typed DSL was added with 4 check types: http, env_exists, command, and any_of.
The command type runs a binary via spawnSync.

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-embedded
recipes, but the new command DSL type skips that check entirely. A malicious recipe
in CWD with a command health check executes arbitrary binaries on gbrain integrations doctor.

What the fix does

Before calling spawnSync, the handler checks isEmbedded. If the recipe is NOT
first-party (loaded from CWD), the command check returns status: 'blocked' without
executing anything. First-party recipes continue to work as before.

Changes

src/commands/integrations.ts

  • isEmbedded gate at the top of the command case, before spawnSync

test/integrations.test.ts

  • New test: command check with isEmbedded=false returns blocked
  • Existing command tests (exit 0 ok, exit 1 fail) still pass with isEmbedded=true

Validation

  • bun test test/integrations.test.ts — 38 pass, 0 fail

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant