Simplify/ibantools

Infinite loop caused in mod9710 by some invalid IBANs

dantman opened this issue · 1 comments

Describe the bug
Trying to validate some invalid IBAN strings will trigger an infinite loop/DOS instead of returning an error.

To Reproduce

const { validateIBAN } = require('ibantools');
validateIBAN('SI94BARC102');

Expected behavior
Presumably this should return some sort of error instead of mod9710 looping infinitely.

Additional context
The infinite loop happens in mod9710.

  • Given the invalid IBAN SI94BARC102 mod9710 gets the input BARC102
  • It takes BARC10 out as the first part
  • validationString becomes NaN2
  • On next iteration validationString becomes "NaN"
  • And it continues iterating infinitely with validationString as "NaN" which never has a length less than 2.

@dantman thanks a for bug report, again :)
Issue is solved. I'll be releasing new version in a few minutes.