[CRIT-2] No identity authorization: any authenticated client can impersonate or revoke any IC holder (identity + SANs taken from CSR) #2

Closed
opened 2026-11-14 18:28:38 +01:00 by amiryahaya · 0 comments
Owner

Finding

The JWT carries only iss/aud/sub(client) — no scopes, no subject binding. jwt_claims is assigned by RequireJwt but no controller reads it. Subject identity (CN, serialNumber/IC, O, OU, email) is copied verbatim from the attacker-controlled CSR, and enrollment/renewal also copy CSR dNSName SANs. MyKad validation was removed in d69c944. Standalone renewal revokes the victim's valid remote cert and re-issues to the attacker's key; revocation has no ownership check at all.

Evidence

  • lib/mdid_ws_web/plugs/require_jwt.ex:32 — jwt_claims assigned, never consumed
  • lib/mdid_ws/cert_management/enrollment.ex:31-38, 178-189 — CSR DN copied into subject
  • lib/mdid_ws/cert_management/renewal.ex:185-209 — dNSName SANs / O / OU / email copied; renewal.ex:369-381 — revokes victim's remote cert, adopts CSR commonName

Impact

Complete identity impersonation of any national-ID holder (12-digit MyKad space is enumerable): issue certs asserting arbitrary names/orgs/DNS names, and hostile revocation (= identity DoS) of any citizen's certificate.

Fix

  • Introduce an identity-proofing/attestation step before issuance (out-of-band MyKad verification or Trustgate-side attestation)
  • Add scopes/roles on OAuth clients & tokens; enforce per-route/per-subject checks
  • Fix subject to a defined template (CN, serialNumber, C); strip extensionRequest SANs and O/OU/email from CSRs

Line numbers refer to the initial import commit 282cb11. Source: comprehensive audit, 2026-11-12 (first review of this codebase).

## Finding The JWT carries only iss/aud/sub(client) — no scopes, no subject binding. `jwt_claims` is assigned by RequireJwt but no controller reads it. Subject identity (CN, serialNumber/IC, O, OU, email) is copied verbatim from the attacker-controlled CSR, and enrollment/renewal also copy CSR dNSName SANs. MyKad validation was removed in d69c944. Standalone renewal revokes the victim's valid remote cert and re-issues to the attacker's key; revocation has no ownership check at all. ## Evidence - `lib/mdid_ws_web/plugs/require_jwt.ex:32` — `jwt_claims` assigned, never consumed - `lib/mdid_ws/cert_management/enrollment.ex:31-38, 178-189` — CSR DN copied into subject - `lib/mdid_ws/cert_management/renewal.ex:185-209` — dNSName SANs / O / OU / email copied; `renewal.ex:369-381` — revokes victim's remote cert, adopts CSR commonName ## Impact Complete identity impersonation of any national-ID holder (12-digit MyKad space is enumerable): issue certs asserting arbitrary names/orgs/DNS names, and hostile revocation (= identity DoS) of any citizen's certificate. ## Fix - [ ] Introduce an identity-proofing/attestation step before issuance (out-of-band MyKad verification or Trustgate-side attestation) - [ ] Add scopes/roles on OAuth clients & tokens; enforce per-route/per-subject checks - [ ] Fix subject to a defined template (CN, serialNumber, C); strip extensionRequest SANs and O/OU/email from CSRs _Line numbers refer to the initial import commit `282cb11`. Source: comprehensive audit, 2026-11-12 (first review of this codebase)._
Sign in to join this conversation.
No description provided.