Harden git_gate.py shell rendering with shlex.quote and name validation #155

Closed
opened 2026-06-02 22:30:42 -04:00 by didericis-claude · 0 comments
Collaborator

Tracked from the medium-priority refactoring playbook in #154.

git_gate_render_entrypoint() passes GitEntry.Name and upstream_url into a POSIX shell script using single-quoted interpolation. GitEntry.Name is only validated for non-empty, so a name containing a single quote (e.g. o'reilly) will break the generated script and could allow injection into the entrypoint.

Work

  • Apply shlex.quote() to name and upstream_url before interpolation in git_gate_render_entrypoint() (and any other rendering functions that embed manifest-controlled values into shell).
  • Add a validation rule in GitEntry (or _from_object()) that rejects names containing characters unsafe for shell identifiers, or rely on shlex.quote() and document that names are quoted.
  • Add regression tests with pathological Name and Upstream values (single quotes, spaces, semicolons) to pin the fix.
Tracked from the medium-priority refactoring playbook in #154. `git_gate_render_entrypoint()` passes `GitEntry.Name` and `upstream_url` into a POSIX shell script using single-quoted interpolation. `GitEntry.Name` is only validated for non-empty, so a name containing a single quote (e.g. `o'reilly`) will break the generated script and could allow injection into the entrypoint. ## Work - Apply `shlex.quote()` to `name` and `upstream_url` before interpolation in `git_gate_render_entrypoint()` (and any other rendering functions that embed manifest-controlled values into shell). - Add a validation rule in `GitEntry` (or `_from_object()`) that rejects names containing characters unsafe for shell identifiers, or rely on `shlex.quote()` and document that names are quoted. - Add regression tests with pathological `Name` and `Upstream` values (single quotes, spaces, semicolons) to pin the fix.
didericis added the Kind/SecurityKind/Enhancement labels 2026-06-02 23:34:26 -04:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: didericis/bot-bottle#155