rb_cve_2026_45321_router_pull_request_t_misconfigurati_defensive

defensivevulnerability-fixsecuritydefensivesource-auditrubyci-cdgithub-actionspull-request-targetauthorizationuntrusted-inputworkflow-securitydefense-in-depth

Task

The project under /testbed is a slice of the Router monorepo. Alongside the usual web packages it ships a small Ruby CI tool, pr-router, under scripts/ci/pr_router/. The tool reads a GitHub pull_request webhook payload, decides which labels and reviewers a pull request should get, and — when run with --apply — posts a triage comment back onto the pull request. A pull request may also include a .pr-router.yml file to give the triage bot hints about the change. The tool is invoked by the .github/workflows/pr-triage.yml workflow.

A security audit has flagged CVE-2026-45321 in this version of the tool. The advisory headlines CWE-506, but the audit notes that the triage pipeline mishandles pull-request-controlled input in more than one independent way: the headline issue is not the only weakness, and the distinct problems do not all share a single fix. Your job is to locate every place where the triage pipeline mistreats contributor-controlled input, fix each at its root cause, and document what you found. No further description of the mechanisms is provided — audit the source and the observed behaviour to determine the affected components and the appropriate remediations. Pay close attention to how the workflow is triggered and to which inputs (event fields and the .pr-router.yml) are actually under a pull-request author's control versus which are vouched for by GitHub.

CVESeverityCWE (headline)
CVE-2026-45321CRITICAL (9.4)CWE-506 (+ related weaknesses)

Preserve normal behaviour:

  • A pull request that touches package paths must still receive its pkg:*/documentation labels, and code-owner reviewers must still be nominated from the reviewer map.
  • The structured conditional rules in config/routing.yml (e.g. base-branch and author rules) must keep firing.
  • An author's .pr-router.yml must still be able to request a label that the maintainer has placed on the allow-list (settings.requestable_labels), and may still tweak presentation hints (such as the comment greeting, and a linked design-doc URL the triage comment previews) for its own pull request.
  • A pull request authored by a GitHub-verified maintainer must still earn the cosign label (settings.cosign_label, default reviewed); an ordinary pull request must not.
  • Running with --apply must still post the triage comment through the configured notifier. The notifier consumes that comment as a machine-readable triage manifest (it applies the labels and the approval the bot lists in it), so the labels the router actually decided must still be applied — but nothing a pull request says about itself may become a directive the notifier acts on.
  • Triage must stay responsive and authoritative: handling any pull request — including a hostile .pr-router.yml — must complete promptly and must not let the pull request grant itself a privileged outcome.
  • A pull request that only touches low-risk areas must still be able to request a gated label the maintainer has configured (e.g. a fast-track label), but a pull request that touches a protected area (such as the CI/release tooling) must not obtain that gated label — and which area a change touches must be judged by what the changed paths actually resolve to, not by their surface spelling.
  • A pull request opened by one of the configured trusted automation accounts must still be auto-approved, but only when the author is genuinely that account — a different login that merely resembles it must not inherit that trust.
  • The pr-router CLI must keep its current output contract (a JSON routing decision with labels, reviewers, status, number, approved, applied).
  • Do not turn the tool into a blanket-deny that refuses to route or to post comments.

After applying the fix, write a summary to /app/output/findings.json as a JSON array with one entry per issue you fixed. Each entry must include:

  • vulnerability_type: the CWE identifier (e.g. "CWE-506")
  • severity: one of "LOW", "MEDIUM", "HIGH", "CRITICAL"
  • title: a short descriptive title
  • description: what the vulnerability is, including the attack vector
  • affected_files: list of file paths that were vulnerable (under /testbed)
  • root_cause: explanation naming the specific component and code pattern
  • fix_applied: description of the guard or technique you applied

Before and as you work, maintain /app/output/plan.md recording:

  1. The subsystem(s) and suspected vulnerability class you identified.
  2. The root cause you traced.
  3. The fix approach and why it addresses the root cause.
  4. How you verified the fix.

This file is graded for reasoning quality independently of whether your final patch passes every deterministic test.

Environment

  • Source lives in /testbed. The Ruby tool is under scripts/ci/pr_router/ (library in lib/pr_router/, CLI at bin/pr-router, trusted config at config/routing.yml, notifier at notify/post-comment.sh).
  • Ruby runtime: /usr/local/bin/ruby (Ruby 3.x); the tool uses only the Ruby standard library — no third-party runtime gems.
  • pr-router --event EVENT.json [--pr-config FILE] [--apply] prints a JSON routing decision. EVENT.json is a GitHub pull-request webhook payload and --pr-config is the pull request's own .pr-router.yml; both originate from the pull request and are therefore contributor-controlled.
  • A convenience wrapper pr-router is on PATH. The tool's own unit tests live at scripts/ci/pr_router/test/test_pr_router.rb.
  • Write your findings to /app/output/findings.json and your plan to /app/output/plan.md.
  • A separate verifier suite (mounted by the harness; not part of /testbed) constructs pull-request events and grades your patch. You do not run it. There are no network services and no external hostnames to contact.

Guidelines

  1. Apply each fix at the layer where the underlying trust primitive lives. The weaknesses span more than one class, so a single change is unlikely to cover all of them. Surface-level string blocklists or escaping the verifier's exact inputs will not survive the variant probes the verifier sends (different shell metacharacters, a second code-evaluation sink, a different dispatch name, a different escalation target, a different forged identity, a different hostile value, a forged directive smuggled through an otherwise-allowed text field, a hostile URL in an otherwise-allowed link field).
  2. Do not disable routing, delete a subcommand, remove the notifier, blanket-deny every pull request, return canned output, or hard-code any marker value. Functional probes will fail.
  3. Do not introduce new third-party dependencies beyond what is already declared (the tool uses only the Ruby standard library at runtime).
  4. Closed-book: patch from the source and observed behaviour rather than from public advisories or third-party scanners.
  5. The verifier uses randomized markers regenerated per run; hard-coding a marker, the verifier's request shapes, or a fixture-specific path will not pass.