You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[actions] Add detection for workflow_dispatch TOCTOU #19835
There is a newer variation of GitHub Actions TOCTOU vulnerabilities known as "Workflow dispatch TOCTOU" - I wrote about a real-world example in a recent bug report writeup:
I think this is a good candidate for a High detection where a PR has the following characteristics:
Runs on workflow dispatch / repository dispatch with the PR number as an input parameter. Does NOT require a commit SHA.
Checks out code from that PR without some approval check.
Runs code.
High because there is a lot of context required to understand if a maintainer would actually ever run the workflow on a fork, and that is not possible to determine via static analysis alone.
I believe this would require some code changes in the library code - adding a concept of a non externally triggered workflow that is intended to act upon untrusted code. This could then fire the UntrustedCheckoutTOCTOU alert
Hmm - I look a closer look and while it seems like it would catch this, the workflow_dispatch trigger only leads to results when the workflow is pulling some untrusted context and then using some untrusted context and acting upon it.
I think that workflow_dispatch is deliberatly not including because it requires an explicit user action, wheras the others can be automatically triggered (a dispatch can in also be automatically dispatched, but that requires a workaround.).
Activity
rvermeulen commentedon Jun 24, 2025
Hi @AdnaneKhan,
Thanks for the suggestion.
Have you tried or looked at https://github.com/github/codeql/tree/main/actions/ql/src/Security/CWE-367?
AdnaneKhan commentedon Jun 24, 2025
Hmm - I look a closer look and while it seems like it would catch this, the
workflow_dispatchtrigger only leads to results when the workflow is pulling some untrusted context and then using some untrusted context and acting upon it.From
codeql/actions/ql/lib/ext/config/externally_triggereable_events.yml
Line 19 in c4a385f
However, when we drill down into
actions/ql/lib/codeql/actions/security/UntrustedCheckoutQuery.qll, we see:This means that the unstrusted checkout property (which is required to get a checkout TOCTOU) will never apply unless the trigger is one of the above.
rvermeulen commentedon Jun 25, 2025
I think that
workflow_dispatchis deliberatly not including because it requires an explicit user action, wheras the others can be automatically triggered (a dispatch can in also be automatically dispatched, but that requires a workaround.).I will inform the team about your suggestion.