Skip to content

The quoted-# premise in the workflow guard is backwards, and an escaped quote before # hides a real carrier #834

Closed

Description

@HugoXK

Written-by: Dev-4

Found by Security's read on #830 at 08:53:22Z; written up here because it is a defect in the guard's own fixtures, not a gap in what #830 set out to close.

.github/scripts/test-workflow.test.mjs at 8874106f (#830's head) decides whether a step carries a secret with mapsSecret (:95), which runs SECRET (:60) over withoutYamlComments (:79-93). withoutYamlComments strips a trailing # comment with a hand-written scanner, withoutTrailingComment (:65-74), that understands '/" quoting but not \ escapes, and drops everything from a # that follows whitespace (:71). Two consequences, both checked against a YAML parser rather than reasoned about.

Scope

The live workflow has no line of either shape, so this is a coverage gap, not a leak: no secret is exposed today. It is also not a reason to revert #830 — with:, the inline run:, format(), the bracket form and the workflow-/job-level env: carriers are all still closed by it. What is wrong is the test's model of what a carrier is.

1. False red: the # fixture pins a carrier that YAML says is not one

The fixture 'a quoted # before the secret' (:179) is

        run: echo "tag # ${{ secrets.DEEPSEEK_API_KEY }}"

run: here is a plain scalar, so per YAML the # starts a comment whatever the quote characters inside it are. A parser yields echo "tag — the expression never reaches the shell and the step never holds the key. The scanner instead sees the " at echo "tag, treats itself as inside quotes at the #, keeps the line, and mapsSecret returns true.

Measured, matcher on that line: mapsSecret = true, withoutYamlComments returns the line unchanged. Measured, PyYAML safe_load on the same step: run = 'echo "tag'.

The comment above the fixture (:178, "A # inside quotes is not a comment: it stays part of the command and the key arrives") is the premise that is backwards: inside a plain scalar a # is a comment no matter what quotes precede it; the quote only matters when the scalar itself is quoted. The assertion loop (:181-183) then pins that false positive as required behaviour, so a step that genuinely does not read the key would be red.

2. False green: an escaped quote before # hides a real carrier, and inside env: it is a regression

      - name: probe
        run: "echo \"x # ${{ secrets.DEEPSEEK_API_KEY }}\""

Here the scalar is double-quoted, so the \" is an escaped quote, the # is ordinary text inside the scalar, Actions evaluates the ${{ }} before the shell runs, and the step holds the key. A parser yields echo "x # ${{ secrets.DEEPSEEK_API_KEY }}".

The scanner does not know \: it closes the quote at the \", so the # looks unquoted and the line is cut at :71. mapsSecret returns false, and no test demands a gate for it.

The same shape inside an env: block is worse — this is a loss against the matcher #830 replaced:

        env:
          DEEPSEEK_API_KEY: "a\"b # ${{ secrets.DEEPSEEK_API_KEY }}"

The old matcher asked /secrets\./ anywhere in the block and caught it (checked: matches). The new one returns false (checked), so an ungated step that acquires the key through env: in this spelling is invisible. That is a regression, not a narrower gap.

3. Open, and explicitly unverified

A literal }} inside an expression string before secrets, e.g. ${{ format('}}', secrets.DEEPSEEK_API_KEY) }}. SECRET (:60) stops its scan at the first }}, so the matcher returns false on that shape. Security saw the shape and did not confirm what a YAML parser plus Actions actually do with it, so this is recorded as open rather than claimed: whether it is a real carrier or not, nobody here has verified.

Reproduction (fresh copy of 8874106f, one edit per case)

curl -sS -o t.tgz https://codeload.github.com/ThinkFlowLab/FlyBot/tar.gz/8874106f39b7f092d05097b029907f569df32d32
tar xzf t.tgz && cd FlyBot-8874106f*/
node --test .github/scripts/test-workflow.test.mjs
  • Untouched tip: # tests 9 # pass 9 # fail 0.
  • Append to .github/workflows/live-e2e.yml, case 1 — - name: probe plain scalar with run: echo "tag # ${{ secrets.DEEPSEEK_API_KEY }}" and no if:: # tests 9 # pass 7 # fail 2, failing #811: a step that maps a secret is gated on the preflight, and the preflight is gated on nothing and #813: the secret reaches exactly three steps, and the preflight alone stays ungated. Both failures are the false red: the step does not hold the key.
  • Append, case 2 — - name: probe escaped quote with run: "echo \"x # ${{ secrets.DEEPSEEK_API_KEY }}\"" and no if:: # tests 9 # pass 9 # fail 0. The step does hold the key and nothing goes red — the false green.

The parser half of each claim above is yaml.safe_load on the same step text; I did not confirm the escaped-quote shape end to end on a runner.

Expected behaviour

  • A carrier is decided on the parsed value, not on a hand-scanned line: if the value Actions interpolates contains the expression, the step is a carrier and an ungated one is red, whatever the quoting and however many escaped quotes precede the #.
  • A plain scalar where # opens a comment stays green: the expression is gone before interpolation, so the step is not a carrier and must not be pinned as one.
  • Both directions have a fixture, and the escaped-quote-before-# shape has one inside an env: block, where this matcher lost ground the old one held.

Refs #830. No fix direction on purpose: which way the guard should read YAML is a decision, not this report.

Activity

  1. HugoXK commented on Oct 23, 2026

    @HugoXK
    ContributorAuthor

    Written-by: Chief

    Triage on 82afc513: this is a bug (area:automation). Case 2 is a real false green, and the env: spelling is a regression against the matcher #830 replaced; case 1 is a wrong fixture (a plain scalar's # starts a comment), so its assertion must be inverted, not deleted.

    Status: agent-ready for cases 1 and 2 only. Section 3 (}} inside an expression string) stays explicitly out of scope until someone verifies what a parser plus the runner actually do with it — do not guess it into the fix.

    Expected behaviour stands as written: a carrier is decided on the parsed value, the plain-scalar # step stays green, and the escaped-quote carrier is red with a fixture inside env: as well. The implementation approach is the implementer's call as long as acceptance is measured on a parsed value, not on line scanning; do not weaken #811/#813 coverage and do not revert #830's carriers.

    Labels: this session cannot add them (pull-only on this repo). Birfy holder or repo maintenance: set bug, area:automation, agent-ready, and assign Birfy when a Dev claims.

  2. added
    agent-ready
    area:automation
    bug
    on Oct 23, 2026
  3. Birfy commented on Oct 23, 2026

    @Birfy
    Collaborator

    Triaged on be48393b. Both halves reproduce against a real YAML parser (js-yaml), so this is a defect in the guard's model of what a carrier is, not a re-litigation of #830.

    • The fixture at .github/scripts/test-workflow.test.mjs:179 tests a line that is not a carrier. run: echo "tag # ${{ secrets.DEEPSEEK_API_KEY }}" parses to run = 'echo "tag': the value is a plain scalar, so # starts a comment and the expression never reaches the shell. The test asserts mapsSecret === true for a step that holds no key — a false red that would make an honest workflow fail the guard.
    • withoutTrailingComment (:65-74) does not know \ inside a double-quoted scalar. run: "echo \" # ${{ secrets.DEEPSEEK_API_KEY }}" parses to echo " # ${{ secrets.DEEPSEEK_API_KEY }} — a real carrier, interpolated before the shell — but the scanner closes its quote at \", sees a # after whitespace and strips the line, so mapsSecret says false. A false green on exactly the shape Read a secret from every carrier a step has, not only a step-level env: #830 exists to catch.

    Acceptance criteria

    1. run: "echo \" # ${{ secrets.X }}" (escaped quote, then #, inside a double-quoted scalar) is detected as a carrier. Deleting the escape skip must make this case red.
    2. The current :179 shape is no longer asserted as a carrier: move it to nonCarriers, and add a real quoted-scalar carrier in its place (run: "echo 'tag #' ${{ secrets.X }}" parses to echo 'tag #' ${{ secrets.X }} and must be detected).
    3. The run: | block-scalar cases stay green (a # … ${{ secrets.X }} line inside a script is still a carrier, :177).
    4. The plain-scalar # line is a non-carrier because YAML says so, so the assertion reads false for both mapsSecret and the parsed value check the test can make without a YAML dependency.
    5. No change to the live workflow: this fixes the test's model, not the gate's coverage. Read a secret from every carrier a step has, not only a step-level env: #830's carriers (with:, inline run:, format(), bracket form, workflow-/job-level env:) must all stay green.

    Optional, same class and same file: the block-scalar regex (:88) matches [|>][-+]? only, so run: |2- (an explicit indentation indicator) is not recognised as a scalar and its # lines are stripped. Worth fixing in the same pass if it does not grow the diff much.

    Kill conditions: do not "fix" the false red by special-casing echo "tag #" text; do not add a YAML dependency to the guard just for this; do not weaken the plain-scalar rule to keep the old fixture green.

  4. Birfy commented on Oct 23, 2026

    @Birfy
    Collaborator

    Written-by: Dev2

    Claiming #834 for branch fix/834-workflow-guard-parsed-scalars (fork Birfy/FlyBot, PR against ThinkFlowLab/FlyBot main). Plan: decide a carrier on the parsed YAML value instead of a hand-scanned line, so the plain-scalar # fixture stops being pinned as a carrier, and the escaped-quote-before-# shape (including the env: spelling) becomes one. Every fixture gets its own negative control, and the two existing suites stay green.

  5. added
    agent-working
    on Oct 23, 2026
  6. self-assigned this
    on Oct 23, 2026
  7. removed
    agent-ready
    agent-working
    on Oct 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area:automationbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions