← Back to Pull requests

Security review fixes: hostile-input hardening, the runner's API host, bounded requests #17

Closed
unknown closed this pull request without merging on Nov 06, 2026 03:25 UTC
View on GitHub
unknown unknown commented on Nov 06, 2026 03:14 UTC
Author

What and why

These are the fixes from an independent security review. The threat model is a hostile audited repository. Anyone who can open a pull request controls run, job and step names. Whoever can push to the default branch, or owns a repository you audit, controls the workflow YAML. Each finding below was reproduced before it was fixed, and each has a regression test in test/security.test.mjs.

1. Slow matching.

  • isOn and cacheInputOn matched /^\$\{\{\s(.?)\s\}\}$/ against workflow values. A long unterminated ${{ made it backtrack in cubic time (2,000 spaces took 3 s; 20 KB, about an hour). In the action, that holds the runner until its 6-hour limit.

  • wholeExpression() now uses a prefix and suffix test instead.

  • jobNamePattern joined literals with [\s\S] (polynomial on a long, non-matching job name). It now finds the literals in order with indexOf, giving the same matches in linear time.
  • 2. Report text stays text (src/report.mjs, src/compare.mjs, src/cli.mjs). Every string from the repository is rendered through md():

  • newlines become spaces, so text can't start a heading or block;

  • outside code spans, < and > become entities and [, ], \ are escaped, so no HTML, hidden comment, link or tracking image;

  • runs of backticks are cut to one and an unpaired backtick is escaped, so no code span is left open;

  • control characters are stripped, so no terminal escapes.
  • Examples are fenced with more backticks than they contain, cell() builds on md(), and the CLI progress line drops control characters. The HTML report was already escaped correctly.

    3. The runner's API host. The action and the CLI send the token to GITHUB_API_URL (apiBase(), https only, no credentials or query), and createClient refuses a non-https base. On GitHub Enterprise Server or GHE.com, the token used to go to api.github.com, and the audit read a github.com repository of the same name.

    4–5. Bounded requests.

  • Contents paths are percent-encoded per segment, so a file name with ? or # can't change which file or ref is read.

  • REPO_RE rejects . and .. as an owner or repository name.

  • Each attempt has a 30 s deadline (AbortSignal.timeout) that covers the body too.

  • An answer over 20 MB is an error, checked from content-length and while streaming.
  • 6. A wider injection scan.

  • New untrusted fields: a workflow_run's display_title and its pull requests' head refs, committer name and email, head repository description.

  • Untrusted text is followed through env: at workflow, job and step level, including chains, into a later ${{ env.NAME }}. A variable read as "$VAR" is the fix, not a finding. A nearer scope that sets the variable again from trusted text clears it.

  • The report says what the scans don't check: pull_request_target and workflow_run jobs that run a fork's code or artifacts, composite actions, and reusable workflows in other repositories.
  • 7. Smaller items.

  • The HTML report uses system fonts and loads nothing.

  • The README says that the GitHub CLI's token usually has write scope, and that a fine-grained read-only token is enough.

  • SECURITY.md and docs/rules.md state the new guarantees.
  • Not in this PR:

  • Splitting publish.yml so build and test run without publish rights. It changes the release workflow, so it gets its own PR.

  • The README's SHA-pinned install and security-model section, which are part of the README rewrite.
  • I re-checked against the real API: an audit of askalf/ci through a proxy runs to completion, and its report includes the coverage note.

    Checks

  • npm test passes (203; 13 new in test/security.test.mjs)

  • npm run build run and dist/ committed

  • A new or changed rule has a fixture it must catch, a near miss it must leave alone, and an entry in docs/rules.md. The new injection fields and env flow each have positive cases and near misses (workflow_run.id, committer.date, "$VAR", a nearer trusted reassignment), and docs/rules.md lists them.

  • Fixtures are synthetic (no other project's run data)
  • Diff: 514 lines (+385 / -129) across 6 files Reviewer: askalf Review duration: 10m
    All Vouch review confidence checks passed
    Residual risk 0.34 = Change Risk (0.71) × (1 − Review Confidence (0.53)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.71 · 514 lines diff across 6 files
    0.71
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 83% · Reviewer familiarity: 35%
    52%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.374
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.071
    Real PR Conversation Timeline
    1 comments
    "Review active on #17"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 52.6% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 70.9% (HIGH) · Higher = larger blast radius
    70.9%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 52.6% · Lower = rushed or shallow review
    52.6%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 33.6% · Safe to merge
    33.6%