Skip to content

fix(server): webhook retries and redirects, env booleans, log and trace privacy, CI pinning - #180

Merged
dillonstreator merged 6 commits into
mainfrom
fix/server-webhooks-logging-ci
Nov 28, 2026
Merged

dillonstreator merged 6 commits into
mainfrom
fix/server-webhooks-logging-ci

Conversation

@dillonstreator

Copy link
Copy Markdown
Member

What was wrong

  • Webhook retries never happened (CFYI-RES-002). The BullMQ worker wrapped a retrying fetch in a 3 s abort. The second attempt was always aborted, and the resulting error was treated as non-retryable, so the job completed without retrying. Read, burn and failure alerts were lost whenever the receiver was down for more than about 3 s, and WEBHOOK_MAX_ATTEMPTS/WEBHOOK_BACKOFF_* had no effect.
  • Webhook redirects and DNS changes skipped the SSRF check (CFYI-SEC-002). The private-address check ran only when the secret was created, and fetch followed redirects, so a webhook host could send the server's POST on to an internal address.
  • OTEL_ENABLED=false turned tracing on (CFYI-CFG-001). z.coerce.boolean() reads every non-empty string as true. The same applied to WEBHOOK_REMOVE_ON_COMPLETE, WEBHOOK_REMOVE_ON_FAIL and WEBHOOK_REQUIRE_HTTPS.
  • Traces recorded the verification hash (CFYI-SEC-003). HTTP server spans stored url.query=h=…, and h together with the id is enough to fetch (and burn) a secret.
  • Request logs linked sender and reader IPs to vault ids (CFYI-PRIV-001). Each request log had the client address and /vault/<id>, which the privacy page says the service can't know.
  • A full Redis took the whole API down (CFYI-RES-001, low-risk part). The rate limiter shares Redis with the vault and rethrew store errors, so at maxmemory every request returned 500.
  • 5xx responses echoed internal errors (CFYI-SEC-004), such as Redis OOM text or key-configuration messages.
  • Release actions were pinned to mutable tags (CFYI-SC-001) in the workflow that holds NPM_TOKEN and GHCR write access.

What changed

  • Webhooks: the worker makes one attempt per job run. It throws HTTPError or TimeoutError so isRetryableFetchError lets BullMQ's attempts and backoff apply. The nested retry client is gone from index.ts; the HTTP sender was effectively single-attempt already and stays that way. Both senders use redirect: 'manual', which treats a 3xx as a failed, non-retryable delivery. Both also re-run assertWebhookUrlAllowed (with WEBHOOK_REQUIRE_HTTPS) before each delivery and drop the job if it fails.
  • Config: a new envBoolean helper (zod stringbool, with empty meaning unset) is used for all four boolean env vars. Unrecognised values now fail at startup.
  • Telemetry: redactedQueryParamsServer: ['h'] for the HTTP instrumentation. The API is unchanged.
  • Logging: the request serializer logs the route pattern (/vault/:vaultId) with no client address or port.
  • App: rate limiting uses skipOnError: true, and 5xx responses send a generic msg. The README covers sizing and alerting on REDIS_MAXMEMORY.
  • CI: release.yml actions are pinned to full commit SHAs, with version comments.
  • Two server patch changesets.

How it was tested

  • pnpm build, pnpm typecheck, pnpm lint (0 errors; the existing core warning), pnpm format:check: pass.
  • Tests: server 39 pass (12 new), run against a temporary Redis container. core 65, cli 15, extension 14, desktop 58, theme 12, web 6: pass.
  • New tests, each confirmed to fail against main's code:
    • webhook.test.ts: real BullMQ. A 503 is retried, a timeout is retried, the URL is re-checked before delivery, and a 307 to a second local server is not followed.
    • telemetry.test.ts: a real NodeSDK with an in-memory exporter; the span has no h value.
    • logging.test.ts: no vault id, hash or IP in the serialized request.
    • config.test.ts: envBoolean.
    • app.test.ts: a failing rate-limit store still lets a create succeed, and a 500 does not leak its message.
  • pnpm test:e2e not run.

For the reviewer

  • The rate limiter now fails open when its store errors. That is the trade-off for not taking down reads. If you'd rather fail closed, or move the limiter to its own Redis or DB, that's a one-line change.
  • At-delivery validation narrows the DNS-rebinding gap but doesn't close it: fetch does its own lookup. Fully closing it needs an undici dispatcher with a checking connect.lookup. A DNS failure at delivery now drops the job instead of retrying.
  • OTel spans still carry url.path with the vault id and the client address, so operators who enable tracing hold that linkage. The privacy copy doesn't state a log retention period; that's yours to decide.
  • After rebasing with fix: honour CLI --password and stop trusting client-supplied X-Forwarded-For #178, the request logs have no IP at all, so TRUST_PROXY doesn't affect them.

Left out

  • Per-IP create quotas, a separate rate-limit Redis, and a lower TTL for large payloads (RES-001 remainder): these need a design decision.
  • Trusted npm publishing instead of NPM_TOKEN, and job-level permissions: these need registry-side setup. Pinning ci.yml/desktop.yml was skipped because neither holds publish credentials.
  • SEC-006 (failed-IP webhook before the hash check): it changes what the event means.
  • SEC-005 (Dockerfile USER node, pnpm deploy), SC-002 (Dependabot, image pinning): these are policy choices for you to make.

z.coerce.boolean() turned every non-empty string into true, so
OTEL_ENABLED=false enabled tracing and WEBHOOK_REMOVE_ON_FAIL=false was
ignored.
The BullMQ worker wrapped a retrying fetch in a 3 second abort and then
treated the resulting error as non-retryable, so failed deliveries were
dropped. Make one attempt per job run and throw retryable errors so the
queue's attempts and backoff apply. Deliveries also no longer follow
redirects, and the URL is checked against private addresses again
before each delivery.
Request logs paired the client address with the concrete /vault/<id>
path, linking who created a secret to who read it. Log the route pattern
and drop the address and port.
The rate limiter shares Redis with the vault, so a Redis at maxmemory
made every request fail. Skip rate limiting when its store errors, keep
internal error messages out of 5xx responses, and document sizing and
monitoring REDIS_MAXMEMORY.
@dillonstreator
dillonstreator merged commit 869aab4 into main Nov 28, 2026
11 checks passed
@dillonstreator
dillonstreator deleted the fix/server-webhooks-logging-ci branch November 28, 2026 19:20
@github-actions github-actions Bot mentioned this pull request Nov 28, 2026
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.

1 participant