Skip to content

fix: escape command block payload to prevent prompt injection#84

Merged
frostming merged 1 commit intobubbuild:mainfrom
glasscatya:command-block-escape
Mar 5, 2026
Merged

fix: escape command block payload to prevent prompt injection#84
frostming merged 1 commit intobubbuild:mainfrom
glasscatya:command-block-escape

Conversation

@glasscatya
Copy link
Contributor

Problem Description

If command output contains </command> (or similar tag-like payload), it can break command-block boundaries and
create a prompt-injection risk in follow-up context.

Resolution

Added escaping for command-block payload and expanded unit test coverage.

  • Escaped command block content in CommandExecutionResult.block():
    • escape name and status as attributes
    • escape output as text content
  • Added tests for injection-like payload in command output:
    • assistant command follow-up path
    • user command error fallback path

Verification

  • ruff check
  • ruff format
  • mypy
  • pre-commit

@frostming frostming merged commit 5875771 into bubbuild:main Mar 5, 2026
5 checks passed
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.

2 participants