Skip to content

fix(service): the webhook route refuses an unsigned or oversized delivery before it reads the body, and a rate limit guards it - #2553

Merged
dan-petty merged 7 commits into
mainfrom
fix/2476-webhook-route-guards
Oct 28, 2026
Merged

dan-petty merged 7 commits into
mainfrom
fix/2476-webhook-route-guards

Conversation

@dan-petty

@dan-petty dan-petty commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

The webhook route of the roadmap Service read the body of a delivery before it checked that the delivery had a signature header. Nothing limited the requests to the route, and no alert showed a burst of refused deliveries.

  • The route refuses a delivery with no X-Hub-Signature-256 header, or an empty one, with 401 missing signature before it reads the body. The check of a declared Content-Length above 25 MiB (413) moves to the same function, _refuse_before_reading. That check already ran before the read, so its behavior does not change. Each refusal counts under the outcome rejected.
  • The Traefik Middleware devops/roadmap-service-rate-limit (k8s/devops/roadmap-service/middleware.yaml) lets 60 requests a minute through, with a burst of 60, in one bucket for the host. Both copies of the Ingress devops/roadmap-service name it, and the native devops stack applies it before the Ingress.
  • The rule group roadmap-service-webhooks, separate from roadmap-service, holds the warning alert RoadmapServiceWebhooksRejected: more than 20 rejected deliveries in 15 minutes. A label set that starts in the window counts from zero (fix(monitoring): the roadmap Service alerts count the first value of a new series and see a lane of a new pod #2505).
  • k8s/README.md, Roadmap service: step 8 says how to check the hooks (uv run devops gh api repos/<owner>/<name>/hooks) and that each hook sends the Issues event only. The new subsection Webhook route gives the rate limit, the refusals, and a query of traefik_router_requests_total that counts each answer of the route, the 429 of the rate limit included. Traefik counts traefik_service_requests_total only for the requests that get to the Service, so that series does not show a 429 of the rate limit. The folder tree lists middleware.yaml. devops gets no command that changes a hook.

Closes #2476

…very before it reads the body

The route checked the X-Hub-Signature-256 header only after it read the body. The check of the signature header, and the check of a declared length above the size cap, now run in _refuse_before_reading with the other checks of the headers. Each refusal counts under the outcome rejected.

Refs #2476
The Middleware devops/roadmap-service-rate-limit lets 60 requests a minute through, with a burst of 60, in one bucket for the host. Both copies of the Ingress devops/roadmap-service name it, and the native devops stack applies it before the Ingress.

Refs #2476
The rule group roadmap-service-webhooks, apart from roadmap-service, holds RoadmapServiceWebhooksRejected: more than 20 deliveries rejected in 15 minutes, with a label set that starts in the window counted from zero. k8s/README.md says how to check the hooks and that each hook sends the Issues event only.

Refs #2476
@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass: uv run devops ci fail-to-pass --base origin/main replays the changed tests on the base tree (4f7390a). 10 fail there, and all pass on this branch:

  • test_the_route_reads_the_body_only_of_a_signed_delivery_within_the_cap[unsigned] and [empty-signature]: on the base tree, the route reads the body of an unsigned delivery.
  • test_each_webhook_ingress_names_the_rate_limit_that_the_devops_stack_renders, test_kustomizations_list_manifests_and_directory, test_devops_stack_manifests_integrity: no Middleware.
  • test_the_webhook_rule_warns_on_more_than_20_rejected_deliveries_in_15_minutes, test_the_baseline_rule_set, and the [roadmap-service-webhooks] cases of the selector, README and promtool tests: no rule group.

The pinned promtool 3.15.0 ran the unit tests of both groups locally.

One part of the premise did not hold: the route already refused a Content-Length above the cap before it read the body (_read_capped_body on origin/main, pinned by test_a_content_length_over_the_cap_gets_413_whatever_its_number_of_digits). The change adds no second check. It moves that check into _refuse_before_reading, beside the new check of the signature header. The declared-above-the-cap case of the new test passes on the base tree for that reason.

Evidence for the limit (2026-10-28): in 2 days the Service counted at most 36 issues deliveries in one minute, and at most 85 deliveries with no subscriber. In 7 days Traefik sent at most 133 requests to the Service in one minute, with no 4xx or 5xx. The hook of dan-petty/devops-cli sends issues, milestone, pull_request and release. A person sets each hook to the Issues event only (step 8).

@dan-petty

Copy link
Copy Markdown
Owner Author

Fail-to-pass check run of CI: https://github.com/dan-petty/devops-cli/actions/runs/40776584565/job/123127352384 (success). All checks pass on 49c0ef6. The three code-scanning checks waited because GitHub did not process the first SARIF upload, so the Static Analysis job ran again, and its new upload completed them.

…ixes

The review of #2553 found two defects in k8s/README.md. The change
folder goes back to openspec/changes/ so that its tasks, design and
spec record the fixes, and the last commit archives it again.

Refs #2476
…rate limit

The subsection Webhook route of k8s/README.md counted the answers of the
route with traefik_service_requests_total. Traefik counts that series
only around its proxy to the pods, after the middlewares of the router,
so a request that the rate limit refuses with 429 did not count there.
The query now reads traefik_router_requests_total, which Traefik counts
before the middlewares of the router (Traefik v3.7.13,
pkg/server/router/router.go and pkg/server/service/service.go).

The folder tree of k8s/README.md now lists middleware.yaml of
k8s/devops/roadmap-service/. Two tests in
tests/test_k8s_roadmap_service.py pin the tree and the query.

The comment of the rule group roadmap-service-webhooks now says that
the scrape reads the deliveries counter each minute, so the 15-minute
window reads only a new label set as new. A promtool case pins that a
label set that is quiet for 40 minutes and then rejects one delivery
does not fire the alert.

Refs #2476
@dan-petty

Copy link
Copy Markdown
Owner Author

Review fixes on 6efa4eb. All checks pass. Fail-to-pass check run: https://github.com/dan-petty/devops-cli/actions/runs/40782083997/job/123146067808 (success). An earlier run on the same commit was cancelled when the body edit started this run.

  1. Fixed: the Traefik query did not show a 429 of the rate limit. In Traefik v3.7.13 (chart 41.6.0), buildHTTPHandler in pkg/server/router/router.go adds the router metrics before the router middlewares. getLoadBalancerServiceHandler in pkg/server/service/service.go adds the service metrics only around the proxy to each server. The subsection Webhook route now uses sum by (code) (increase(traefik_router_requests_total{service="devops-roadmap-service-8000@kubernetes"}[15m])). test_the_webhook_route_section_counts_the_429_answers_of_the_rate_limit failed before the fix.
  2. Fixed: the folder tree of k8s/README.md did not list middleware.yaml. test_the_folder_tree_of_the_readme_lists_each_file_of_the_roadmap_service failed before the fix.
  3. Not reproduced: RoadmapServiceWebhooksRejected fires on 1 rejection after a quiet time. The reproduction models devops_cli_service_webhook_deliveries_total as an OTLP delta series that gets a sample only when a delivery is rejected. The Service does not send this counter through OTLP. _Delivery.conclude adds to it through GLOBAL_METRICS, a prometheus_client registry that only /metrics serves (src/devops_cli/telemetry/metrics.py, src/devops_cli/server/service.py). k8s-monitoring scrapes /metrics each 60 s (global.scrapeInterval). So a label set has a sample in each minute while its pod runs. The same scenario with one sample each minute (1+1x24 25x39 26x15) stays quiet at 65m and 79m in promtool. The rule does not change. The comment of the group now says that the scrape reads the counter each minute, and a promtool case pins the scenario.

The change folder was opened again for these fixes and archived again in the last commit. The push was a fast-forward, so the branch history holds the old archive commit and its revert.

@dan-petty
dan-petty marked this pull request as ready for review October 28, 2026 23:04
@dan-petty
dan-petty merged commit 40efcd4 into main Oct 28, 2026
19 of 20 checks passed
@dan-petty
dan-petty deleted the fix/2476-webhook-route-guards branch October 28, 2026 23:17
dan-petty pushed a commit that referenced this pull request Oct 29, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.12.0](v0.11.3...v0.12.0)
(2026-10-29)


### Features

* **ai:** constrain structured replies on the openai and claude
providers ([#2550](#2550))
([4f7390a](4f7390a))
* **argo:** retire the Helm release records of the charts that Argo CD
renders ([#2568](#2568))
([cabfcd4](cabfcd4))
* **k8s:** devops k8s tunnel keeps the cloudflared forward to
k8s.&lt;domain&gt; running
([#2567](#2567))
([f9493fa](f9493fa)),
closes [#1641](#1641)
* **monitoring:** alert when the otel collector fails to export spans,
metric points or log records
([#2565](#2565))
([4fc8ff7](4fc8ff7))
* **telemetry:** the roadmap Service counts its GitHub writes, budget
holds, Firecrawl searches and own deliveries, and caps refine's comments
on one item
([#2556](#2556))
([9819877](9819877)),
closes [#2475](#2475)


### Bug Fixes

* **git:** report a worktree that a run in parallel removed as removed,
not a failed reclaim
([#2557](#2557))
([a556984](a556984)),
closes [#2408](#2408)
* **k8s:** the devops perimeter opens only the collector's OTLP/HTTP
port, 4318
([#2549](#2549))
([d156ce7](d156ce7))
* **sandbox:** devops sandbox logs reads each line with its stream from
a real engine
([#2546](#2546))
([e7216d5](e7216d5)),
closes [#2520](#2520)
* **service:** the webhook route refuses an unsigned or oversized
delivery before it reads the body, and a rate limit guards it
([#2553](#2553))
([40efcd4](40efcd4)),
closes [#2476](#2476)


### Performance Improvements

* **ai:** price a request with one load of the settings
([#2555](#2555))
([5d86538](5d86538)),
closes [#1420](#1420)


### Code Refactoring

* **config:** a default that backs a settings field is read only through
the settings
([#2561](#2561))
([0702d13](0702d13))
* **exceptions:** each exception class declares its error_code and
exit_code ([#2558](#2558))
([410dece](410dece))
* **review:** render the review report from one input, outside the
orchestrator
([#2563](#2563))
([9e73e6d](9e73e6d)),
closes [#1008](#1008)
* **security:** src has no unreviewed Bandit findings, and the gate
scans src at low severity
([#2560](#2560))
([45261dd](45261dd)),
closes [#1538](#1538)
* **security:** the scanners stop looking for mocks, and their tests run
on the scanner fake
([#2551](#2551))
([2b7f37a](2b7f37a))

---
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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(service): the webhook route refuses an unsigned or oversized delivery before it reads the body, and a rate limit guards it

1 participant