Skip to content

fix(python): prevent heredoc delimiter injection in write()#449

Merged
chaliy merged 1 commit intomainfrom
claude/fix-412-Y2nIj
Mar 1, 2026
Merged

fix(python): prevent heredoc delimiter injection in write()#449
chaliy merged 1 commit intomainfrom
claude/fix-412-Y2nIj

Conversation

@chaliy
Copy link
Contributor

@chaliy chaliy commented Mar 1, 2026

Summary

  • Generate random heredoc delimiter suffix using secrets.token_hex(8) to prevent content injection
  • Quote file path with shlex.quote() for path injection prevention
  • Extract _build_write_cmd() helper for testability

Closes #412

Test plan

  • Test verifies content with BASHKIT_EOF is written literally
  • Test verifies file paths with spaces are properly quoted
  • Test verifies each call generates unique delimiters
  • ruff check and ruff format pass

@chaliy chaliy force-pushed the claude/fix-412-Y2nIj branch from b56cb3d to 9ff5ec9 Compare March 1, 2026 08:50
@chaliy chaliy merged commit 90bbd7a into main Mar 1, 2026
17 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.

[H-6] Heredoc content injection in BashkitBackend.write()

2 participants