Repository navigation
Conversation
A ${{ }} expression that is a comparison, a ! negation, a contains() /
startsWith() / endsWith() call, or an && / || combination of only those
expands to true or false, so a free-text field inside it never reaches
the script. lib.expression reduces such parts away before the injection
patterns run; && and || still expand to an operand, so a field that is
itself an operand keeps firing.
Checked on GitHub in getplumber-examples/github-actions-miscellaneous-knowledge,
branch test/2026-11-20-boolean-expressions.
Closes #624
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exypte
requested review from
Totara-thib,
coconux3 and
thomasboni
as code owners
November 20, 2026 10:49
…ean expressions Review of #630 found boolean expressions the reduction still flagged: contains() around another call, such as contains(fromJSON('["/a","/b"]'), github.event.comment.body); a group on one side of a comparison, such as (body || 'a') == 'b'; and a comparison holding an index, such as body == github.event.commits[0].message. A bare group no longer takes the parentheses of a call whose inner call was just reduced, a group next to a comparison operator counts as boolean, and an index reads as a property. That last change also makes github.event['head_commit'].message match the injection patterns, which missed it before. ISSUE-209 now calls lib.expression.untrusted instead of its own copy, and the docs example for boolean expressions moves after the fix example. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
expression.reduced turned every index into .__i__, so github.event.comment['body'] and github['head_ref'] lost their field name and no injection pattern matched them. An index holding one name now reads as that property before literals are blanked. Any other index still becomes .__i__. New fixtures cover what the PR review asked about: a parenthesized field, an expression nested past the three passes, a named index in ISSUE-207 and ISSUE-209, and an env-bound || operand written to $GITHUB_ENV with a redirect and through a heredoc. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What type of PR is this?
fix
What this PR does / why we need it:
ISSUE-207 (template injection) and ISSUE-209 ($GITHUB_ENV / $GITHUB_PATH injection) fired on any
${{ }}that mentions a free-text field, even when the expression can only expand totrueorfalse:A comparison (
==,!=,<,>,<=,>=), a!negation, acontains()/startsWith()/endsWith()call, or an&&/||combination of only those carries no payload.&&and||expand to one of their operands, so${{ cond || github.event.comment.body }}must still fire, and does.policies/lib/expression.rego(lib.expression.reduced) removes the boolean-valued parts of an expression: string literals, boolean calls, negated groups, comparisons, and groups made only of those. The existing injection patterns then run on what's left, so a free-text field that survives can reach the script.fromJSON(F)still fires.template_injection.regouses it in_expression_controlled, so the finding, its line and its subject stay consistent.github_env_injection.regochecks every untrusted value throughlib.expression.untrusted: direct writes,env:values, lines and subjects. Theunsafe_patternslists are unchanged, so the test that keeps them in sync still holds.docs/GITHUB_ISSUES.mddocuments the exclusion under ISSUE-207 and points to it from ISSUE-209.Which issue(s) this PR is related to:
Closes #624
Special notes for your reviewer:
test/2026-11-20-boolean-expressions, run 44718136654.$(touch /tmp/injected), and only ever renderedtrueorfalse.&&/||operand cases rendered the field and ran the payload.${{ format('{0}', github.event.issue.title) }}doesn't fire onmaineither, because the extraction pattern\$\{\{[^}]*stops at the}inside'{0}'. Tracked in ISSUE-207/209: a}inside a string literal cuts the expression short #631./code-reviewpass found three boolean forms that still fired:contains()around another call, a group on one side of a comparison, and a comparison with an index. The second commit fixes them, with fixtures. The third, after the claude-review findings, reads an index holding a name as that property (github.event.comment['body']isgithub.event.comment.body). Bracket references like that now match the injection patterns, which missed them before.Does this PR introduce a user-facing change?
How was this tested?
TestIssue206_TemplateInjectionandTestIssue209_GitHubEnvInjection:clean_boolean_expression.yml(the issue's workflow),clean_boolean_forms.yml(21 safe forms, a ternary, a literal containing&&,(and==, nested calls, compared groups, an index),violation_boolean_operand.yml(11 jobs, all must fire, including a parenthesized field, nesting past the three passes and a named index) andviolation_index_field.yml(github['head_ref']).clean_boolean_to_env.yml(a direct write, plus anenv:value written to$GITHUB_ENVand$GITHUB_PATH),violation_boolean_operand_to_env.yml,violation_boolean_operand_env_bound.yml(redirect and heredoc) andviolation_index_to_env.yml.make buildandmake testpass.make lintreports 7govetfindings aboutreflect.Ptrinconfiguration/schema.go,configuration/schema_test.goandcontrol/catalog.go. This PR doesn't touch those files.plumber analyzeon a clone of getplumber-examples/cli-working-lab with the issue's workflow plus an||-leak job: only the leak job (comment/leak) got ISSUE-207, and the issue's job (comment/check) got nothing.AI usage disclosure:
YES. Claude Code (Claude Opus 5.5) reproduced the bug, wrote the Rego helper, the fixtures and the docs, and ran the tests and the CLI check. The approach and the GitHub experiment it relies on were reviewed by the author, who is responsible for the change (CONTRIBUTING.md, AI_POLICY.md).
🤖 Generated with Claude Code