Skip to content

Commit eeda9c0

Browse files
committed
Prevent workflow command injection via commit history log
When the action logs commit history to the runner output, any GitHub Actions workflow commands (e.g. ::set-output::, ::error::, ::warning::) present in commit messages are interpreted by the runner. This can cause unexpected side effects or CI failures. Wrap the history output in a ::stop-commands:: / ::<endtoken>:: pair so that workflow commands in commit messages are printed literally instead of being executed.
1 parent 4ed4496 commit eeda9c0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

entrypoint.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ declare -A history_type=(
166166
["compare"]="$(git log "${tag_commit}".."${commit}" --format=%B)" \
167167
)
168168
log=${history_type[${branch_history}]}
169+
stop_commands_token=$(cat /proc/sys/kernel/random/uuid)
170+
echo "::stop-commands::${stop_commands_token}"
169171
printf "History:\n---\n%s\n---\n" "$log"
172+
echo "::${stop_commands_token}::"
170173

171174
if [ -z "$tagPrefix" ]
172175
then

0 commit comments

Comments
 (0)