Files
PaperClipAI/server
Zurva Aziz 96eb00e98f fix(routines): prefer X-Hub-Signature-256 on app_webhook triggers (#18581)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - Routines can start from public webhook triggers
> - The `app_webhook` signing mode reads a signature from
`X-Hub-Signature` or `X-Hub-Signature-256`
> - Some senders, such as GitHub, can send both headers on one delivery
> - The code reads `X-Hub-Signature` first, and `verifyAppWebhook`
accepts only `sha256=` values
> - So a SHA-1 value in `X-Hub-Signature` causes a 401, even when the
SHA-256 signature is valid
> - This pull request reads `X-Hub-Signature-256` first
> - The benefit is that senders that send both headers can use
`app_webhook` triggers

## Linked Issues or Issue Description

Fixes #18565

Related, not duplicates: #16781, #1892.

## What Changed

- `firePublicTrigger` now prefers `X-Hub-Signature-256` over
`X-Hub-Signature` in `app_webhook` mode.
- Added tests for both headers, each header alone, an invalid SHA-256
header, and a SHA-1 header alone.

## Verification

- Codex ran these checks in its cloud sandbox.
- Run from `server/`: `../node_modules/.bin/vitest run
src/__tests__/routines-service.test.ts`
- Result: 85 tests passed, 0 failed, 0 skipped. Embedded Postgres ran.
- With the fix reversed, 2 of the 5 new tests failed. With the fix
restored, all 5 passed.
- The server TypeScript check passed.
- The full workspace typecheck did not finish because `cargo` was not
installed in the test environment.
- The full build and the repository-wide tests were not run. CI must
confirm them.

## Risks

- Low risk. The change affects only `app_webhook` mode.
- Behavior change: a delivery with a valid `sha256=` value in
`X-Hub-Signature` and an invalid `X-Hub-Signature-256` value was
accepted before. It now gets a 401.
- SHA-1 signatures stay rejected. This is an interoperability fix, not a
security fix.

## Model Used

- Implementation and tests: OpenAI Codex (cloud). The session did not
show the exact model ID, context window, or reasoning mode.
- Review and pull request text: Anthropic Claude Opus 5.5
(`claude-opus-5-5`), with tool use.

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [ ] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass (targeted suite only, in
the Codex sandbox, see Verification)
- [x] I have added or updated tests where applicable
- [ ] I have updated relevant documentation to reflect my changes (not
needed, the existing docs stay correct)
- [x] I have considered and documented any risks above
- [x] All Paperclip CI gates are green
- [x] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [ ] I will address all Greptile and reviewer comments before
requesting merge
2026-11-24 15:44:57 -06:00
..