Skip to content

fix(core,react): only send x-kyc-code to the configured API origin#179

Open
TaprootFreak wants to merge 1 commit into
developfrom
fix/kyc-code-same-origin-guard
Open

fix(core,react): only send x-kyc-code to the configured API origin#179
TaprootFreak wants to merge 1 commit into
developfrom
fix/kyc-code-same-origin-guard

Conversation

@TaprootFreak

Copy link
Copy Markdown
Contributor

Finding (Medium, branch-weiter Security-Review)

Die KYC-Setter (setContactData, setPersonalData, setNationalityData, … ~20 Stück) nehmen ihre Ziel-URL aus der vorherigen Step-Antwort der API und reichen sie direkt an den credentialed Request weiter, der den x-kyc-code-Header (KYC-Auth-Token) trägt:

  • core: KycApi.kycRequesthttp.requestAbsolute mit headers: { 'x-kyc-code': code }
  • react: useKyc's callfetch(config.url, …) mit x-kyc-code

Keine der beiden Stellen prüfte, dass die URL auf der API-Origin bleibt. Eine manipulierte / via MITM veränderte Step-URL könnte den KYC-Code an einen fremden Host exfiltrieren. Als Bibliothek multipliziert sich der Fehler über alle Konsumenten (Threat-Model: Fehlerquelle, die kein Konsument selbst absichern kann).

Fix

Neuer Helper Utils.isSameOrigin(url, baseUrl) (core; im react-Paket via Re-Export verfügbar). Beide Call-Sites guarden: Requests an etwas anderes als die konfigurierte API-Origin werden abgelehnt, bevor der Header gesetzt wird. Fail-closed bei nicht-parsebaren URLs.

Vergleich auf exakte Origin (Scheme + Host + Port) gegen http.getBaseUrl() (core) bzw. defaultUrl (react).

Tests

isSameOrigin-Spec (core): same-origin ✓, fremder Host / Subdomain-Trick / abweichendes Scheme/Port → abgewiesen, unparsebar → false. core 58/58 grün; core+react Build und Lint sauber.

Letzter offener Punkt aus dem Security-Backlog. Verbleibend nur noch der Account-Merge Token-Bindungs-Designentscheid (David).

The KYC setters take their target URL from a previous step response and
pass it straight to the credentialed request (x-kyc-code header) — in
core via KycApi.kycRequest, in react via useKyc's fetch. Neither checked
that the URL stays on the API origin, so a tampered/MITM step URL could
exfiltrate the KYC credential to a foreign host.

Add Utils.isSameOrigin and guard both call sites: requests to anything
but the configured API origin are refused before the header is attached.
Fails closed on unparsable URLs.
@TaprootFreak TaprootFreak marked this pull request as ready for review June 11, 2026 21:23
@TaprootFreak TaprootFreak requested a review from davidleomay June 11, 2026 21:23
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