The vulnerability stems from the use of Buffer.isBuffer for type checking within the tiny-secp256k1 library. In environments where Node.js's native Buffer object is not available and is instead polyfilled by the buffer npm package (common in browser bundlers like Webpack or in React Native), the Buffer.isBuffer check can be easily bypassed. An attacker can create a simple JSON object like {"type": "Buffer", "data": [...]} which, when parsed, can fool the Buffer.isBuffer check into returning true.
The core issue lies in the helper functions isScalar, isPoint, and isSignature, which all used this weak validation method. These functions are used by the main verify function to validate its inputs: the message hash, the public key, and the signature, respectively.
By crafting a malicious message that is a JSON-stringifyable object, an attacker can bypass the type check in isScalar. This leads the verify function to process a manipulated object instead of a byte buffer, ultimately causing it to incorrectly return true for a message and signature pair that should be invalid. This effectively allows a bypass of the cryptographic signature verification.
The patch addresses the root cause by replacing all instances of Buffer.isBuffer(x) with the more robust x instanceof Uint8Array. This ensures that the functions only accept true byte arrays, regardless of the environment, thus preventing the type confusion attack.