Repository navigation
Description
Problem Description
Since #5017 (PR #5045, v0.118.0), each installation token of the GitHub App asks for repository_hooks: read. The runner Job tokens get it too. Only the metrics row of the Service reads hooks (src/devops_cli/github/hook_deliveries.py, called from src/devops_cli/roadmap/run.py). No step of a runner Job reads a hook.
A step of a runner Job runs model-written shell commands, and the token is in the environment of each git or gh child (k8s/README.md, Guarantees). So a prompt injection in a runner Job can now read the configuration of each hook (its URL hooks.<domain>) and the deliveries of each hook, with their payloads and response headers. ADR 0015 says: "A later feature that needs more permissions asks for a token with its own set."
Reproduction Steps
src/devops_cli/config/constants.py:CONST_GITHUB_APP_TOKEN_PERMISSIONSholds"repository_hooks": "read".src/devops_cli/github/app_installation.py,_exchange: each token asks for that one set. A runner Job (service.github_app.token_repositoryset) only addsrepositories.tests/github/test_github_app_identity.py,test_a_job_token_names_only_its_repository: the runner Job token asks forrepository_hooks: read.
Expected vs Actual Behavior
Expected: a token with service.github_app.token_repository set (a runner Job) asks for the permissions of the roadmap jobs only. The token of a process with no token repository (the Service) also asks for repository_hooks: read, for the metrics row.
Actual: each token asks for repository_hooks: read.
Environment Diagnostics
devops-cli v0.118.0, the roadmap Service and the runner Jobs in the cluster.
Logs, Traces, or Terminal Output
Found in the review of PR #5045.
Source: #5045
Proposed design
Problem statement
Since v0.118.0, each GitHub App installation token asks for repository_hooks: read. Runner Job tokens get that permission too. A runner Job runs model-written shell commands, so a prompt injection can read hook URLs and deliveries. Only the Service metrics row reads hooks. The runner Job token must ask only for the roadmap job permissions.
Acceptance criteria
Requirement: Runner Job token omits hooks permission
A token minted for a process with service.github_app.token_repository set SHALL ask for CONST_GITHUB_APP_TOKEN_PERMISSIONS and SHALL NOT ask for repository_hooks.
Scenario: Runner Job token body
- WHEN The fake GitHub App receives an exchange from a process whose
service.github_app.token_repositoryisexample-org/app. - THEN The request body's
permissionsequalsCONST_GITHUB_APP_TOKEN_PERMISSIONS, has norepository_hookskey, and the body holdsrepositories: ["app"].
Requirement: Service token keeps hooks read
A token minted for a process with no service.github_app.token_repository SHALL ask for CONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONS, which includes repository_hooks: read.
Scenario: Service token body
- WHEN The fake GitHub App receives an exchange from a process with no token repository.
- THEN The request body's
permissionsequalsCONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONSand holdsrepository_hooks: read.
Requirement: Permission maps are separate
CONST_GITHUB_APP_TOKEN_PERMISSIONS SHALL hold only the roadmap job permissions, and CONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONS SHALL extend it with repository_hooks: read.
Scenario: Permission maps
- WHEN A test imports both constants from
devops_cli.config.constants. - THEN The base map has no
repository_hookskey and the service map equals the base map plusrepository_hooks: read.
Requirement: Runner Job error names its permissions
The HTTP 422 error of a runner Job SHALL name the permissions of CONST_GITHUB_APP_TOKEN_PERMISSIONS and SHALL NOT name repository_hooks.
Scenario: Runner Job 422 error
- WHEN The fake GitHub App returns HTTP 422 for a process whose
service.github_app.token_repositoryis set. - THEN The raised
GitHubUnauthenticatedErrormessage lists the base permissions and does not containrepository_hooks.
Requirement: ADR records the split
ADR 0015 SHALL name the base permission map for roadmap jobs and the service permission map for the Service, with repository_hooks: read only in the service map.
Scenario: ADR text
- WHEN A test reads
docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md. - THEN The text names
CONST_GITHUB_APP_TOKEN_PERMISSIONSandCONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONSand states thatrepository_hooks: readis in the service map.
Existing Tool Considered
No alternatives check has run. No open, maintained tool or library covers this need: the change is to devops-cli's own GitHub App token request. Building cost is about 6,000 tokens to build, 2,000 tokens to keep, 1,000 tokens to fix, and 1 to 2 hours elapsed.
Key questions
- Which permissions does a runner Job installation token ask for?: It asks for
CONST_GITHUB_APP_TOKEN_PERMISSIONSonly: issues, pull_requests, contents and workflows write, and checks, actions and metadata read. It asks for norepository_hookspermission. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md:21, src/devops_cli/config/constants.py:1488, src/devops_cli/github/app_installation.py:187]- Rejected: One shared permission map with a conditional removal. The removal branch hides the security boundary and lets a later edit put hooks back into the runner token.
- Chosen: Two permission maps selected by
token_repository. ADR 0015 says a feature that needs more permissions asks with its own set, and each map stays auditable. - Rejected: A new setting for token permissions. It adds configuration for a fixed boundary and lets a deployment weaken the runner token.
- How does the Service token keep
repository_hooks: readfor the metrics row?:CONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONSextends the base map withrepository_hooks: read._exchangeselects it whenservice.github_app.token_repositoryis unset. (best practice) [sources: src/devops_cli/github/hook_deliveries.py, src/devops_cli/roadmap/run.py, src/devops_cli/config/constants.py:1488, src/devops_cli/github/app_installation.py:187]- Rejected: Add hooks to the base map and remove it for runner Jobs. The runner request would still carry the permission in code and a later edit can restore the leak.
- Chosen: Add a service-only map that extends the base map. The Service keeps the read and the runner Job never asks for it.
- Rejected: Use a second GitHub App for the metrics row. It adds a second identity and secret for one read, beyond this fix.
- What should a 422 error name when the token's permission set is not granted?: It names the permissions of the set that the token asked for: the base set for a runner Job and the service set for the Service. A runner Job error must not name
repository_hooks. (best practice) [sources: src/devops_cli/github/app_installation.py, tests/github/test_github_app_identity.py]- Rejected: Always name the service set. It tells a runner Job to ask for a permission that the Job must not carry.
- Chosen: Name the selected set. The error tells the operator what to grant for that token only.
- Should ADR 0015 record the two permission sets?: Yes. Amend ADR 0015 to name
CONST_GITHUB_APP_TOKEN_PERMISSIONSfor roadmap jobs andCONST_GITHUB_APP_SERVICE_TOKEN_PERMISSIONSfor the Service, withrepository_hooks: readonly in the service set. (best practice) [sources: docs/adr/0015-roadmap-jobs-act-as-a-github-app-on-the-personal-account.md:21]- Rejected: Leave ADR 0015 unchanged. The ADR still implies one set covers every process and hides why the Service asks for hooks.
- Chosen: Amend ADR 0015. The ADR is the recorded decision that the issue cites, and it should state the split.
- Which code reads webhook hooks?: Only the metrics row of the Service reads hooks.
read_delivery_failuresinhook_deliveries.pycalls the hooks and deliveries endpoints, and_run_metrics_adapterinroadmap/run.pycalls it. No runner Job step reads a hook. [sources: src/devops_cli/github/hook_deliveries.py, src/devops_cli/roadmap/run.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 12, 2026
A prompt injection in a runner Job can read hook URLs and payloads through the token, which is a security risk.Both scope GitHub App token permissions to what each process needs, but #2473 set the general principle while the candidate removes one permission added later to runner Job tokens.devops-cli-service commentedon Nov 12, 2026
Status set to Ready at acb4e19 (see proposed design in issue body).
dan-petty commentedon Nov 12, 2026
Scope note: #4932 merged after this issue was filed and added
administration: readto the same shared set, for the traffic read of themetricsrow (#4757). No runner Job reads the traffic either, so PR #5064 keeps bothrepository_hooks: readandadministration: readout of the runner Job token. The Service token keeps both.devops-cli-service commentedon Nov 12, 2026
Released in v0.119.0: https://github.com/dan-petty/devops-cli/releases/tag/v0.119.0
devops-cli-service commentedon Nov 12, 2026
Live since 2026-11-12 15:46 UTC