Skip to content

Fix BigInteger.modInverse DoS in shipped bundles#653

Open
Kr0emer wants to merge 1 commit into
kjur:masterfrom
Kr0emer:fix/modinverse-dos
Open

Fix BigInteger.modInverse DoS in shipped bundles#653
Kr0emer wants to merge 1 commit into
kjur:masterfrom
Kr0emer:fix/modinverse-dos

Conversation

@Kr0emer
Copy link
Copy Markdown
Contributor

@Kr0emer Kr0emer commented Mar 18, 2026

Summary

Fix a denial-of-service issue in the shipped jsrsasign bundles where BigInteger.modInverse(0, odd_modulus) could enter an infinite loop.

What changed

  • Synced bundled bnModInverse implementations with the normalized safe logic already present in source
  • Updated the generated browser and npm bundles affected by the source/bundle desync
  • Added a regression test covering modInverse(0, 9) through the npm entrypoint

Validation

  • Reproduced the hang locally against npm/lib/jsrsasign.js with a timeout-based PoC before the fix
  • Verified the fixed bundle now returns 0 instead of hanging
  • Added and executed a regression test locally with a lightweight harness

@kjur
Copy link
Copy Markdown
Owner

kjur commented Apr 17, 2026

Hi @Kr0emer , could you conclude ext/jsbn2.js with your fix? Thank you as always.

@Kr0emer Kr0emer force-pushed the fix/modinverse-dos branch from cb3593d to cb7f09f Compare April 18, 2026 02:08
@Kr0emer
Copy link
Copy Markdown
Contributor Author

Kr0emer commented Apr 18, 2026

Hi @Kr0emer , could you conclude ext/jsbn2.js with your fix? Thank you as always.
Sorry for the late response—I’ve been quite busy lately and missed your email. I’ve now pushed the requested changes. Thank you for your patience.

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