singpass / myinfo-connector-v4-nodejs

4 stars 3 forks source link

`generateJwkThumbprint` triggering a ERR_BUFFER_OUT_OF_BOUNDS error #5

Open benjamin-richardson-circular opened 2 months ago

benjamin-richardson-circular commented 2 months ago

While running the MyInfo Connector v4 in production, I have seen this error pop up a couple of times, and it looks like it is generated in the generateJwkThumbprint helper function that uses node-jose.

Has anyone else encountered this? Any ideas on what I could do to avoid this issue?

RangeError [ERR_BUFFER_OUT_OF_BOUNDS]: Attempt to access memory outside buffer bounds
    at new NodeError (node:internal/errors:405:5)
    at boundsError (node:internal/buffer:86:11)
    at Buffer.readUInt16BE (node:internal/buffer:334:5)
    at Object.import (/usr/app/build/index.js:992:157921)
    at /usr/app/build/index.js:992:143199
    at Array.forEach (<anonymous>)
    at importFrom (/usr/app/build/index.js:992:143132)
    at Object.value (/usr/app/build/index.js:992:143869)
    at Yx.asKey (/usr/app/build/index.js:992:146624)
    at z7.exports.generateJwkThumbprint (/usr/app/build/index.js:999:21997)
image
benjamin-richardson-circular commented 2 months ago

I suggest updating node-jose to the latest version (v2.2.0) might help here. There are many package updates and bug fixes since v2.0.0 spanning many years.