Skip to content

fix(github): keep the metrics permissions out of the runner Job token - #5064

Merged
dan-petty merged 2 commits into
mainfrom
fix/5058-keep-the-hooks-permission-out-of
Nov 12, 2026
Merged

dan-petty merged 2 commits into
mainfrom
fix/5058-keep-the-hooks-permission-out-of

Conversation

@dan-petty

@dan-petty dan-petty commented Nov 12, 2026 •

Copy link
Copy Markdown
Owner

Only the metrics row of the Service reads the hooks and the traffic, but each installation token asked for repository_hooks: read and administration: read, the token of a runner Job included. So a prompt injection in a step could read the hook URLs, the deliveries and the settings of the repository.

  • CONST_GITHUB_APP_METRICS_TOKEN_PERMISSIONS holds both, out of CONST_GITHUB_APP_TOKEN_PERMISSIONS.
  • A token that names no repository, as the Service mints, asks for both sets. A runner Job token names one repository and asks for the roadmap jobs' set only.
  • The HTTP 422 error names the permissions that the process asked for.
  • ADR 0015 gets an amendment line and states the two sets, and k8s/README.md follows.

Closes #5058

Change: openspec/changes/archive/2026-11-12-5058-keep-the-hooks-permission-out-of/

@dan-petty dan-petty added type/bug Type bug: the code does not do what it must scope/github GitHub Projects v2, Views, Milestones, Labels, and PR automation labels Nov 12, 2026
@dan-petty

Copy link
Copy Markdown
Owner Author

Evidence

This change fixes a major finding of the review of #5017. That pull request merged before the fix, so this is a new item.

Fail-to-pass (uv run devops ci fail-to-pass --base origin/main, base 2e6f407): 2 tests fail on base and pass on head.

  • tests/github/test_github_app_identity.py::test_a_runner_job_asks_for_a_token_that_names_one_repository_and_no_hooks: on base the body holds repository_hooks.
  • tests/github/test_github_app_identity.py::test_a_runner_job_whose_repository_the_installation_lacks_fails_naming_the_repository: on base the 422 error names repository_hooks.

Local checks

  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-tree: pass.
  • uv run mypy src/devops_cli/github/app_installation.py src/devops_cli/config/constants.py: no issues.
  • uv run devops ci test tests/github/test_github_app_identity.py tests/github/test_hook_deliveries.py tests/roadmap/test_roadmap_run_metrics.py tests/k8s/test_k8s_configmap.py tests/commands/k8s/test_k8s_run_job.py: 88 passed.

Why the token repository selects the set: src/devops_cli/k8s/configmap.py renders service.github_app with no token_repository, so the Service never names one repository. implement_submit.py and cluster_jobs.py set DEVOPS_CLI_SERVICE_GITHUB_APP_TOKEN_REPOSITORY on each runner Job. Only roadmap/run.py (the metrics row) calls hook_deliveries.

Owner step: this is Service code. It waits for the owner's "safe and vetted" call before the merge.

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 13:33
@dan-petty

Copy link
Copy Markdown
Owner Author

This PR now conflicts with main. PR #4932 (#4757) merged at 13:23Z. It adds administration: read to CONST_GITHUB_APP_TOKEN_PERMISSIONS and rewrites the ADR 0015 consequence paragraph. The rule "A later feature that needs more permissions asks for a token with its own set" is gone. The new text is "Each token asks for one shared set, because a process keeps one token for each gh and git child and each REST request".

Decision for the rebase (least privilege, and it narrows no Service token):

  1. Rebase onto origin/main and keep the merged fix(telemetry): read repository traffic as the GitHub App #4932 text.
  2. Keep both metrics-only permissions out of the runner Job token: repository_hooks: read (fix(service): find why webhook deliveries get HTTP 403 #5017) and administration: read (fix(telemetry): emit traffic per repository on a schedule #4757). Only the Service metrics row reads hooks and traffic. A runner Job step runs model-written shell commands with the token in each git and gh child. Administration read adds branch protection, rulesets, the Actions policy, runners and deploy keys to what such a step can read.
  3. Write the ADR 0015 rule so that it matches the reason that fix(telemetry): read repository traffic as the GitHub App #4932 gives: each process keeps one token, so each process role asks for one set. The Service asks for the shared set. A runner Job asks for that set without the permissions that only the Service metrics row uses. A feature that needs one more permission adds it to the set of the role that uses it, with an amendment line.
  4. Update the spec scenarios and the tests for both permissions. Put the issue scope change in a comment on fix(github): keep the hooks permission out of the runner Job token #5058.

@dan-petty
dan-petty enabled auto-merge (squash) November 12, 2026 13:36
Only the metrics row of the Service reads the hooks and the traffic. A
token that names no repository, as the Service mints, asks for
repository_hooks: read and administration: read from the new
CONST_GITHUB_APP_METRICS_TOKEN_PERMISSIONS. A runner Job token names one
repository and asks for the roadmap jobs' permissions only, so a step
cannot read a hook URL, a delivery or the settings of the repository.
The HTTP 422 error names the permissions that the process asked for.
ADR 0015 and k8s/README.md state the two sets.
@dan-petty
dan-petty force-pushed the fix/5058-keep-the-hooks-permission-out-of branch from e90354d to 045df60 Compare November 12, 2026 13:41
@dan-petty dan-petty changed the title fix(github): keep the hooks permission out of the runner Job token fix(github): keep the metrics permissions out of the runner Job token Nov 12, 2026
@dan-petty
dan-petty marked this pull request as draft November 12, 2026 13:42
auto-merge was automatically disabled November 12, 2026 13:42

Pull request was converted to draft

@dan-petty

Copy link
Copy Markdown
Owner Author

Rebase on #4932: the change now covers administration: read too

#4932 merged after this pull request opened. It added administration: read to the one shared set, for the traffic of the metrics row (#4757), and it changed ADR 0015 to "Each token asks for one shared set". The traffic read has the same scope as the hook read: only roadmap/run.py (the metrics row of the Service) and devops gh metrics on a workstation call collect_project_metrics_report. No runner Job reads the traffic. Administration read lets a token read rulesets, deploy keys, self-hosted runners and pending invitations, so a step of a runner Job does not get it either.

What changed in this pull request:

  • CONST_GITHUB_APP_METRICS_TOKEN_PERMISSIONS holds repository_hooks: read and administration: read.
  • ADR 0015: a new amendment line (fix(github): keep the hooks permission out of the runner Job token #5058). The shared-set paragraph now says that each process asks for one set: a runner Job the set of the roadmap jobs, the Service also the set of its metrics row. A process still keeps one token for each child and each REST request, which was the reason for the shared set.
  • k8s/README.md setup step 1 and the docstring of get_repository_traffic_metrics follow.

Owner decision: this changes the shared-set rule that #4932 wrote into ADR 0015. If the owner wants one shared set, close this pull request and #5058 as not planned.

Checks after the rebase (base 2bd87bc):

  • uv run devops ci fail-to-pass --base origin/main: 2 tests fail on base and pass on head (test_a_runner_job_asks_for_a_token_that_names_one_repository_and_no_metrics_permission, test_a_runner_job_whose_repository_the_installation_lacks_fails_naming_the_repository).
  • uv run devops ci --check --only lint,format,docs,constructs,openspec,test-tree: pass.
  • mypy on app_installation.py, constants.py and metrics.py: no issues.
  • 190 covering tests pass: test_github_app_identity, test_hook_deliveries, test_github_metrics, test_roadmap_run_metrics, test_k8s_configmap, test_k8s_run_job, test_docs.

The pull request is a draft again until the checks of the new head pass. It is Service code, so it waits for the owner's "safe and vetted" call.

@dan-petty
dan-petty marked this pull request as ready for review November 12, 2026 13:50
@dan-petty
dan-petty merged commit fb549ff into main Nov 12, 2026
27 of 28 checks passed
@dan-petty
dan-petty deleted the fix/5058-keep-the-hooks-permission-out-of branch November 12, 2026 13:53
dan-petty pushed a commit that referenced this pull request Nov 12, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.119.0](v0.118.0...v0.119.0)
(2026-11-12)


### Features

* **repos:** the claim sets In Progress
([#5111](#5111))
([06ef1c6](06ef1c6))
* **roadmap:** a fix-plan step repairs a plan PR with open findings
([#5104](#5104))
([ca5b16d](ca5b16d))
* **roadmap:** extend stage review rounds while open findings drop
([#5090](#5090))
([bacf713](bacf713))
* **roadmap:** re-anchor a stale citation that matches one line
([#5040](#5040))
([16356d8](16356d8))


### Bug Fixes

* **ci:** keep failed test IDs in the service image shard summary
([#5106](#5106))
([88589ef](88589ef))
* **github:** count each page of a paginated GitHub read
([#5070](#5070))
([908e24a](908e24a))
* **github:** keep the metrics permissions out of the runner Job token
([#5064](#5064))
([fb549ff](fb549ff))
* **github:** pace mutations through the clock seam
([#5063](#5063))
([2bd87bc](2bd87bc))
* **k8s:** delete the CoreDNS files that k3s never applies
([#5055](#5055))
([463f601](463f601))
* **monitoring:** tidy LLM stack windows, units and lines
([#5052](#5052))
([375d724](375d724))
* **roadmap:** a refused kept plan uses no stage gate return
([#4983](#4983))
([b8adbca](b8adbca))
* **roadmap:** count a command as removed only when MUST NOT governs it
([#4985](#4985))
([2e6f407](2e6f407))
* **roadmap:** cut prose after a cited stage command
([#4982](#4982))
([a172563](a172563))
* **roadmap:** name every module of a group with no named test
([#5089](#5089))
([27a0e79](27a0e79))
* **roadmap:** stage returns every open review finding to the planner
([#5067](#5067))
([21b116e](21b116e))
* **roadmap:** the alternatives check reads the tools in use
([#5062](#5062))
([8903233](8903233))
* **roadmap:** the constants gate reads 6_500 and no new value
([#5080](#5080))
([8a7b113](8a7b113))
* **roadmap:** the constants gate reads only a stated value
([#5042](#5042))
([cf4733e](cf4733e))
* **telemetry:** read repository traffic as the GitHub App
([#4932](#4932))
([7c42823](7c42823))
* **tests:** close the UDP, DNS and git gaps of the network floor
([#5101](#5101))
([047ee48](047ee48))
* **tests:** repair the bwrap contract suite and gate it
([#5110](#5110))
([9a0659d](9a0659d)),
closes [#4715](#4715)


### Performance Improvements

* **ci:** build the Service image once for its test shards
([#5079](#5079))
([dcf5bd5](dcf5bd5))
* **ci:** run only the required checks on the release PR
([#5057](#5057))
([8174071](8174071))
* **ci:** stop the cache export of pull request image builds
([#5113](#5113))
([ba30820](ba30820))
* **roadmap:** consolidate keeps its vectors in the shared tiers
([#5099](#5099))
([2a8bf1a](2a8bf1a))


### Code Refactoring

* **roadmap:** one Status writer for every job
([#5109](#5109))
([24cfedc](24cfedc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope/github GitHub Projects v2, Views, Milestones, Labels, and PR automation type/bug Type bug: the code does not do what it must

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(github): keep the hooks permission out of the runner Job token

1 participant