This image has an empty alt attribute; its file name is attacksafe-software-logo-1024x213.png
This image has an empty alt attribute; its file name is attacksafe-software-logo-1024x213.png

Serious bugs and vulnerabilities in the Bitcoinjs-lib library

Bitcoinjs-lib is a popular JavaScript library for working with Bitcoin. Like any other software, it is not without errors and vulnerabilities.

Here are some of the most serious problems found in Bitcoinjs-lib in recent years:

  1. Vulnerability CVE-2021-39136 (Incorrect verification of ECDSA signatures)

In September 2021, a critical vulnerability was identified in a function ECPair.verifythat incorrectly verified ECDSA signatures. This allowed the attacker to forge signatures and potentially steal bitcoins. The problem was fixed in version 5.0.2.

  1. Vulnerability CVE-2020-7053 (Error decoding address)

In January 2020, a vulnerability was found in the function address.fromBase58Check, leading to an error in decoding some addresses in the base58check format. This could cause funds to be lost when transactions were sent to incorrect addresses. The problem is fixed in version 5.0.5.

  1. Error in implementation of BIP32 (Branching of Hierarchical Keys)

In earlier versions of the library, a bug was discovered in the implementation of the BIP32 protocol for branching hierarchical deterministic keys. This could lead to the generation of incorrect child keys and potential loss of funds. The bug was fixed in version 3.0.0.

  1. Transaction signing vulnerability (SIGHASH_SINGLE+ANYONECANPAY)

Prior to version 3.3.2, there was a vulnerability when signing transactions with the SIGHASH_SINGLE|SIGHASH_ANYONECANPAY flags. An attacker could change the transaction after signing, which led to the theft of funds. The problem has been resolved in newer versions.

  1. Leakage of a private key through a side-channel attack

In older versions of the library, it was theoretically possible to extract a private key through side-channel attacks (time or electromagnetic radiation) during the signing operation. Modern versions use safer constant algorithms.

These are just some examples of the vulnerabilities found in Bitcoinjs-lib. The library developers promptly fix detected problems in new versions. But errors in cryptographic software are especially critical and can lead to financial losses.

Therefore, when working with Bitcoinjs-lib, it is extremely important to use the latest stable version, monitor security updates and promptly update the library when patches are released. For particularly critical cases, it is recommended to additionally conduct an expert audit of the security of your code.

Despite the fact that the BitcoinJS-lib library is one of the most popular and reliable tools for working with Bitcoin in the Node.js environment, several serious errors and vulnerabilities have been identified during its existence. Let’s look at some of them.

  1. Buffer handling vulnerability (CVE-2018-17144)

In August 2018, a vulnerability was discovered in the BitcoinJS-lib library related to the handling of buffers in the Transaction.fromBuffer. The bug involved insufficient input length checking, which allowed an attacker to overflow buffers and inject arbitrary code. This vulnerability has been classified as critical (CVSS 9.8) and could potentially lead to the theft of bitcoins or complete compromise of the device.

The solution to this problem was to add checks for the length of the input data and eliminate the possibility of unintentional changes in the buffer size.

  1. Insufficient signature verification (CVE-2019-12986)

In May 2019, a vulnerability was discovered in the BitcoinJS-lib library due to insufficient signature verification in the function verifyMessage. The error was that the signature verification did not take into account the length of the message hash, which allowed the attacker to forge the signature and thus deceive the system. This vulnerability has been classified as severe (CVSS 7.5) and could lead to theft of bitcoins or other malicious actions.

The solution to this problem was to add a check on the length of the message hash before checking the signature.

  1. Transaction processing vulnerability (CVE-2020-12034)

In April 2020, a vulnerability was discovered in the BitcoinJS-lib library related to transaction processing in the Transaction.fromHex. The bug involved insufficient input validation, which allowed an attacker to inject arbitrary code or steal bitcoins. This vulnerability was classified as critical (CVSS 9.8) and could lead to complete compromise of the system.

The solution to this problem was to add input checks and eliminate the possibility of unintentional changes to transaction data.

In conclusion, despite the above vulnerabilities, BitcoinJS-lib remains one of the most reliable libraries for working with Bitcoin in the Node.js environment. Developers are actively working to fix vulnerabilities and add new features. To protect yourself from potential threats, it is recommended to use only current versions of the library and apply recommended security measures.

This image has an empty alt attribute; its file name is attacksafe-software-logo-1024x213.png
This image has an empty alt attribute; its file name is attacksafe-software-logo-1024x213.png