fix(webhooks): fail-closed Yapeal key check + drop Alchemy cache log line#3873
Draft
TaprootFreak wants to merge 1 commit into
Draft
fix(webhooks): fail-closed Yapeal key check + drop Alchemy cache log line#3873TaprootFreak wants to merge 1 commit into
TaprootFreak wants to merge 1 commit into
Conversation
…line
Two anonymous webhook endpoints, hardened:
- Yapeal (bank/yapeal/webhook): validateApiKey returned early when no
expected key was configured, accepting every unauthenticated request
on an endpoint that marks bank payments as received. Fail closed: a
missing expected key now rejects every request. Both DEV and PRD have
the key set, so no environment is affected by the stricter check.
- Alchemy (isValidWebhookSignature): dropped the
'Webhook cache: ${JSON.stringify(this.webhookCache)}' line. It is
anonymously triggerable log noise (always prints {} since a Map does
not JSON-serialize its entries) and a latent secret leak if the cache
type ever changes to a plain object. The webhookId warn stays.
Added a YapealWebhookController spec covering match / wrong-key /
fail-closed-when-unconfigured.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hintergrund
Zwei Medium-Findings aus dem branch-weiten Security-Review, beide an anonym erreichbaren Webhook-Endpoints.
1. Yapeal-Webhook fail-open → fail-closed
bank/yapeal/webhook(yapeal-webhook.controller.ts) prüft einenx-api-key-Header.validateApiKeykehrte bei fehlendem erwarteten Key vorzeitig zurück (if (!expectedKey) return;) und akzeptierte damit jeden unauthentifizierten Request — auf einem Endpoint, der Bank-Zahlungseingänge als erhalten markiert (processWebhook). Verstösst gegen die No-Fallbacks-Regel.Fix: Fail-closed — ein fehlender erwarteter Key lehnt jetzt jeden Request ab. Verifiziert:
YAPEAL_WEBHOOK_API_KEYist auf DEV und PRD gesetzt, die strengere Prüfung trifft also keine Umgebung.2. Alchemy-Webhook: Cache-Log-Zeile entfernt
alchemy-webhook.service.tsisValidWebhookSignatureloggte bei unbekannterwebhookIdWebhook cache: ${JSON.stringify(this.webhookCache)}.Klarstellung zum Review: Die Zeile leakt die Signing-Keys aktuell nicht —
JSON.stringifyeinesMapergibt{}, die Map-Einträge werden nicht serialisiert (per node verifiziert). Sie ist aber (a) anonym auslösbares, nutzloses Log-Rauschen und (b) ein latenter Secret-Leak, falls der Cache-Typ je auf ein Plain-Object umgestellt wird. Daher entfernt; diewebhookId has no signing key-Warnung (kein Secret) bleibt.Tests
Neuer
YapealWebhookController-Spec: korrekter Key → verarbeitet, falscher Key →ForbiddenException, kein Key konfiguriert → lehnt jeden Request ab (fail-closed).format:check,type-check,lintsauber; Yapeal-Spec 3/3 grün.Teil des Security-Backlogs; verbleibend: Lightning-Sign-in-Bypass bei leerer Signatur, SDK
x-kyc-codeohne Origin-Check.