Skip to content

Improve Gotsha sign-off and notes handling - #85

Merged
melounvitek merged 14 commits into
masterfrom
fix/runtime-bugs-rounds
Apr 18, 2026
Merged

melounvitek merged 14 commits into
masterfrom
fix/runtime-bugs-rounds

Conversation

@melounvitek

Copy link
Copy Markdown
Owner

Summary

  • tighten sign-off and config handling so local verification does not succeed on the wrong commit and help/env overrides behave predictably
  • make notes sync follow the branch's configured remote and tolerate repositories where the Gotsha notes ref does not exist yet
  • clean up uninstall parity by removing the generated GitLab config alongside the existing Gotsha files

@melounvitek
melounvitek marked this pull request as draft March 30, 2026 23:17
@melounvitek
melounvitek marked this pull request as ready for review March 30, 2026 23:21
@melounvitek

Copy link
Copy Markdown
Owner Author

Requesting changes for one blocking security regression.

Fetch#remote and Push#remote now interpolate the current branch name directly into shell commands:

  • git config --get branch.#{branch_name}.pushRemote
  • git config --get branch.#{branch_name}.remote

Those strings are executed through BashCommand.run!, which shells out via bash -lc (lib/gotsha/bash_command.rb:21). Git accepts branch names containing shell metacharacters such as ;, $(), and quotes, so checking out a malicious branch can execute arbitrary local shell commands when gotsha fetch or gotsha push runs. Because gotsha push is called automatically from the installed pre-push hook (lib/gotsha/templates/git_hooks/pre-push:5), this becomes a realistic local code-execution path.

Please avoid building these commands with string interpolation. The safest fix is to stop invoking Git through a shell for these lookups and instead pass argv directly, or at minimum validate/escape the branch name before embedding it in the command.

Extract RemoteResolver module that uses Open3.capture2 (argv array)
instead of interpolating branch names into shell commands via
BashCommand.run!.

This closes a local code execution vector where a branch name
containing shell metacharacters (e.g. $(whoami)) would be evaluated
by bash when running gotsha fetch or gotsha push.

Also deduplicates the identical remote method from Fetch and Push.
@melounvitek melounvitek self-assigned this Apr 4, 2026
@melounvitek
melounvitek merged commit 6e8aa89 into master Apr 18, 2026
2 checks passed
@melounvitek
melounvitek deleted the fix/runtime-bugs-rounds branch April 18, 2026 08:56
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