Skip to content

tighten security by enabling HMAC on WebSub - #168

Closed
naftis wants to merge 2 commits into
developfrom
ocrvs-12842
Closed

naftis wants to merge 2 commits into
developfrom
ocrvs-12842

Conversation

@naftis

@naftis naftis commented Aug 5, 2026

Copy link
Copy Markdown
Member

Why not enable proof verification with the VCs?

  • The vectors it would protect for largerly overlap HMAC, given that hub and issuer are both MOSIP infrastructure. It's a bit more involved because RsaSignature2018 MOSIP uses signs the URDNA2015 RDF canonicalization of the credential. The canonicalization depends on the JSON-LD context of the credential and can vary between environments.

We are now secured for:

  1. Message intended for OpenCRVS - RSA-OAEP that was enabled earlier as well
  2. Man-in-the-middle
  • Any altered byte invalidates the HMAC
  • Replay is not prevented cryptographically, but the getTransactionAndDiscard does remove the record from the database
  1. Message source is MOSIP - hub.secret is shared between MOSIP's hub and mosip-api

@naftis

naftis commented Aug 6, 2026

Copy link
Copy Markdown
Member Author

I tested this on integration environment and the records seem to come through fine. I'm happy to merge this for 2.1 but only after Tahmid's fixes for 2.0.1.

@naftis

naftis commented Aug 25, 2026

Copy link
Copy Markdown
Member Author

Continuing the PR here opencrvs/opencrvs-core#13561

@naftis naftis closed this Aug 25, 2026
naftis added a commit to opencrvs/opencrvs-core that referenced this pull request Aug 25, 2026
* tighten security by enabling HMAC on WebSub

Ports opencrvs/mosip#168 into core, now that packages/mosip-api lives here.

WebSub callbacks are authenticated with the hub's X-Hub-Signature HMAC and
rejected with a 401 if it is missing or does not match. Previously nothing
established that a callback came from MOSIP: the route is exempt from JWT
auth, and decrypting the credential only proves the sender had OpenCRVS's
public certificate, which is not a secret.

This replaces the credential's RsaSignature2018 proof as the source check,
so the proof verification and the canonicalize dependency are removed along
with MOSIP_VERIFIABLE_CREDENTIAL_ALLOWLIST.

* remove redundant comment

* make onAssign run promises in parallel to save time

* rename BODY to rawBody

* add Promise.all to api.ts wherever applicable
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.

2 participants