
How CVE-2025-29774 Vulnerabilities and the SIGHASH_SINGLE Bug Threaten Multi-Signature Wallet Operational Methods with Fake RawTX
In this article, we will look at the cryptographic attack of digital signature forgery (Digital Signature Forgery Attack), its consequences pose a threat to the security of transactions in the Bitcoin network, since digital signatures confirm the ownership and authorization of cryptocurrency transfers. We will consider examples of the impact of such attacks on Bitcoin based on modern research and identified vulnerabilities.
A Digital Signature Forgery Attack is an attempt by an attacker to create a fake ECDSA digital signature that will be recognized as valid by the Bitcoin network. This attack allows transactions to be authorized without knowing the owner’s private key, which puts the security of funds in the BTC coin holder’s crypto wallet at risk.
In cryptography, a digital signature provides confirmation of the authenticity of a message or transaction. Signature forgery means that it is possible to create a “RawTX” pair that will be accepted by the system as valid, although in fact it was not created by the owner of the private key. This opens the way for fraud, theft of funds and violation of the integrity of the blockchain. Digital Signature Forgery Attack (DSFA) as a cryptographic attack is implemented in software components that use the xml-crypto library to verify signatures of XML documents on the Node.js platform.
First of all, this concerns enterprise integration solutions, cloud services and single sign-on systems, such as IBM App Connect Enterprise Certified Container and other applications that depend on xml-crypto for SAML authentication and authorization. Hardware vulnerabilities are not associated with specific physical devices, but are implemented in software products using the vulnerable library.
The vulnerabilities CVE-2025-29774 and CVE-2025-29775, known as the Digital Signature Forgery Attack, are implemented in the xml-crypto software library , a library for digitally signing and encrypting XML documents on the Node.js platform.
Security Bulletin: IBM App Connect Enterprise Certified Container operands are vulnerable to bypass signature validation in XML data [CVE-2025-29774] [CVE-2025-29775]
Disclosure for CVE-2025-29774 and CVE-2025-29775 (SAMLStorm).
Thus, this code implements cryptographic signature and signature verification algorithms for various schemes (RSA with different SHA hashes and HMAC-SHA1), which allows them to be integrated into systems that require digital signature of data.
The signature-algorithms.ts code is used to securely create and verify digital signatures, ensuring authenticity and integrity of data. ECDSA signatures provide authorship verification using a private key, and HMAC – integrity and authenticity verification using a secret key. The algorithms used comply with XML Digital Signature standards (the URIs of the algorithms point to W3C specifications).
Thus, the signature-algorithms.ts code implements cryptographic signature and signature verification algorithms for various schemes (ECDSA, RSA with different SHA hashes and HMAC-SHA1), which allows them to be integrated into systems that require digital data signature.
SignatureAlgorithm and provides methods for:
getSignature): takes signature data and a private key, returns a digital signature in base64 format.verifySignature): takes the input, public key and signature, returns a boolean value indicating whether the signature is correct.getAlgorithmName): Returns a URI identifying the signature algorithm used.crypto.createSign and crypto.createVerify with the corresponding algorithms are used (“RSA-SHA1”, “RSA-SHA256”, “RSA-SHA512”).crypto.createHmac with the “SHA1” algorithm.createOptionalCallbackFunction, which probably allows them to be used with both callbacks and promises (details not in the code).The use of the RSA-SHA1 algorithm in cryptographic signatures contains a vulnerability related to SHA-1 hash collisions. This allows an attacker to create two different messages with the same signature if he controls part of the data being signed.
Specifically, the problem is in the class RsaSha1:
const signer = crypto.createSign("RSA-SHA1"); // Vulnerable line
signature-algorithms.ts#L7
Also the second vulnerability is in the class RsaSha1:
const verifier = crypto.createVerify("RSA-SHA1"); // Vulnerable line
signature-algorithms.ts#L17
HmacSha1is less vulnerable, but also obsolete. HMAC is more collision-resistant than “naked” SHA-1, but switching to SHA-256 is preferable.
CVE-2025-29774 and CVE-2025-29775 are critical vulnerabilities in the xml-crypto library for Node.js related to improper verification of digital signatures in XML documents. Both vulnerabilities allow an attacker to modify signed XML messages in a way that goes unnoticed by signature verification.
In the provided code, the classes RsaSha1 use the legacy RSA-SHA1 algorithm for signing and verification:
const signer = crypto.createSign("RSA-SHA1"); // Vulnerable line №7
const verifier = crypto.createVerify("RSA-SHA1"); // Vulnerable line №17SHA1 is considered cryptographically insecure, the main problem lies in the logic of the library’s processing of XML structures :
<SignedInfo> to the XML document , which results in an incorrect hash calculation during verification.<Signature> <SignedInfo>...</SignedInfo> <!-- Original knot --> <SignedInfo>...</SignedInfo> <!-- Added by an attacker --> </Signature>
// Usage SHA-256 / SHA-1 const signer = crypto.createSign("RSA-SHA256");<SignedInfo> in the signature.Addressing these vulnerabilities is critical for systems that use XML signatures for authentication (e.g. SAML, SOAP).
The xml-crypto library is widely used to verify digital signatures in XML messages, including protocols such as SAML, SOAP, and others. It follows that the vulnerability potentially affects:
To assess the risk on specific devices, it is recommended to check whether they use vulnerable versions of xml-crypto or depend on similar XML signature mechanisms. For working with cryptocurrency wallets based on Node.js, IBM offers separate solutions, such as IBM Secure Bitcoin Wallet , an application based on Electrum Bitcoin Client that uses Node.js to interact with the Bitcoin network and manage the wallet.
In this solution, private keys and wallet can be stored and encrypted using IBM Cloud Hyper Protect Crypto Services (zHSM), which provides hardware-based secure storage of keys. Generation of private keys for Bitcoin wallets is usually implemented in specialized cryptographic libraries such as Electrum, bitcoinjs-lib, etc., which can be integrated into Node.js applications. IBM Secure Bitcoin Wallet uses a modified Electrum backend on Node.js for key and transaction management, through integration with IBM Cloud Hyper Protect Crypto Services, which provides hardware encryption and secure storage of private keys.
From the theory of vulnerability CVE-2025-29775 it is known that an attacker can process an unupdated xml-crypto library for incorrect transaction values. Let’s move on to the practical part of the article and consider an example using a Bitcoin wallet: 32GkPB9XjMAELR4Q2Hr31Jdz2tntY18zCe , where there were lost coins in the amount of: 0.059672 BTC as of July 2025 this amount is: 7, 052 USD
Let’s consider the format: Raw transaction binary and hex data that contain all the information about the transaction . It is needed to transmit, verify or create transactions at a low level and is the basis for the operation of the entire Bitcoin network. Regular users rarely encounter Raw transactions directly, but for developers and crypto enthusiasts, this is the main tool for full control over all transactions of the Bitcoin network.
Raw Transaction
To fully return UTXO objects in the Bitcoin network, we will use the Dark AI tool . UTXO is the main part of the data structure in the blockchain and represents the amount of BTC coins of the cryptocurrency that can be spent by the holder of the private key (controlling this Bitcoin address). Each UTXO is the output of a specific past transaction, which has never been used as an input in subsequent transactions.
https://colab.research.google.com/drive/1TKrJ0bKsNgc72H9UvzpCnh2YPmRsyPdW
Teams:
!wget https://darkai.ru/repositories/neuralnet_tools.zipwget— a command line utility for downloading files from the network via HTTP, HTTPS and FTP protocols.neuralnet_tools.zipunzip— command to extract ZIP archives in the current directory.This command extracts all files from neuralnet_tools.zip
!unzip neuralnet_tools.zip
Let’s run the command ls for quick and easy viewing
ls
!./darkai
Let’s run the command to get information about the so-called unspent transaction outputs ( UTXO , decoding: Unspent Transaction Output ) for the specified Bitcoin address. This information is important for assessing the balance of the address and the possibility of conducting new transactions.
!./darkai -bitcoinaddress 32GkPB9XjMAELR4Q2Hr31Jdz2tntY18zCe[
{'output': '8602122a7044b8795b5829b6b48fb1960a124f42ab1c003e769bbaad31cb2afd:0', 'value': 677200},
{'output': 'bd992789fd8cff1a2e515ce2c3473f510df933e1f44b3da6a8737630b82d0786:0', 'value': 5000000}
]Each UTXO contains:
<txid>:<n>, where <txid>is a unique transaction hash, and <n> is the output number in the list of outputs for this transaction.8602122a7044b8795b5829b6b48fb1960a124f42ab1c003e769bbaad31cb2afd:0bd992789fd8cff1a2e515ce2c3473f510df933e1f44b3da6a8737630b82d0786:0The total available balance of an address is equal to the sum of all found UTXOs:

We use the interpretation process to process the unupdated xml-crypto library to create invalid transaction values and send a large amount, the Dark AI algorithm will choose which UTXO to use (or combine both).
The Bitcoin address 32GkPB9XjMAELR4Q2Hr31Jdz2tntY18zCehas two active UTXOs totaling 0.05677200 BTC . These funds can be used to make new transactions; both outputs are considered confirmed and unspent.
To get fragments of information about the output of a Bitcoin transaction, use the following commands, where the first output (
outs) from the transaction has a unique identifier8602122a7044b8795b5829b6b48fb1960a124f42ab1c003e769bbaad31cb2afd
!./darkai -deserialize 8602122a7044b8795b5829b6b48fb1960a124f42ab1c003e769bbaad31cb2afd{'value': 677200, 'script': 'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'}a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287 — a script that defines the conditions for spending this output.
a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287a914...87, which corresponds to the P2SH (Pay to Script Hash) format :
a9— OP_HASH160 (hash operator)14— length of the next value (20 bytes = 40 hex characters)06612b7cb2027e80ec340f9e02ffe4a9a59ba762— hash160 Bitcoin itself Wallet addresses where BTC coins are stored.87— OP_EQUAL (a basic Bitcoin Script command operator that implements a comparison of two pieces of data to verify their identity)As a result of deserialization of the transaction by identifier,
8602122a7044b8795b5829b6b48fb1960a124f42ab1c003e769bbaad31cb2afdthe first output was obtained, containing the amount of 677,200 satoshi (0.00677200 BTC), protected by a P2SH script . To manage these funds, it will be necessary to present the destination script and correctly sign the unlocking transaction that meets the conditions of the specified hash.
To get fragments of information about the output of the original data (
output) of a Bitcoin transaction, apply the following commands, where the first output (outs) from the transaction with a unique identifierbd992789fd8cff1a2e515ce2c3473f510df933e1f44b3da6a8737630b82d0786
!./darkai -deserialize bd992789fd8cff1a2e515ce2c3473f510df933e1f44b3da6a8737630b82d0786Using the interpretation process, with the help of Dark AI using the deserialization function, we then obtain information about the structure of the first output element ( output) for the second transaction with the identifierbd992789fd8cff1a2e515ce2c3473f510df933e1f44b3da6a8737630b82d0786.
Result:
{'value': 5000000, 'script': 'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'}5000000'outs'. It can only be spent if the conditions written in the script defined in the field are met 'script'.
'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'The specified value corresponds to the standard script type in the Bitcoin network:
a9— operation code OP_HASH160 (produces RIPEMD-160 from SHA-256 from the next line).14— length of the subsequent field: 20 bytes (40 hexadecimal characters).06612b7cb2027e80ec340f9e02ffe4a9a59ba762— is a 20-byte hash that identifies either a Bitcoin wallet address or a script.87— operation code OP_EQUAL.Taken together, this entry means a P2SH address (Pay-to-Script-Hash). In this case, funds are assigned to a certain script combination, and to withdraw them, you will need to reveal the script whose hash is recorded here and present signatures (or other data) that satisfy the conditions of this script.
The most common uses of this scheme are for multi-signatures, simple and complex smart contracts, bilateral multi-signatures, conditional security schemes, and other advanced scenarios.
06612b7cb2027e80ec340f9e02ffe4a9a59ba762Thus, the deserialization result reports the presence of a certain amount of bitcoins at a conditional (P2SH) address and defines strict rules for their spending, which plays a key role in the management and accounting of funds in the Bitcoin network.
The script 'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'is chosen and used in this transaction output because it represents a typical P2SH (Pay-to-Script-Hash) locking script in the Bitcoin network.
Let’s look at it piece by piece:
a9— OP_HASH160: A hashing operation that first applies SHA-256 and then RIPEMD-160 to subsequent data.14— hash length is 20 bytes (in hexadecimal format).06612b7cb2027e80ec340f9e02ffe4a9a59ba762— a 20-byte hash of the script, known as the script hash .87— OP_EQUAL: An operator that checks the equality of two values on the stack.Thus, this script requires that at the time of use (spending funds) a script whose hash matches is presented 06612b7cb2027e80ec340f9e02ffe4a9a59ba762, and that the conditions of this script are met.
The script
'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'is a P2SH locking script, which says that in order to spend 0.05 BTC, you need to provide the original script with the hash06612b7cb2027e80ec340f9e02ffe4a9a59ba762and fulfill the conditions specified in it. This provides a balance between convenience, security and functionality – the main reason for choosing this particular script in this transaction. The hash06612b7cb2027e80ec340f9e02ffe4a9a59ba762in the P2SH script is the result of a specific hashing of the original script (redeem script) , which determines the conditions for spending funds from this output.
06612b7cb2027e80ec340f9e02ffe4a9a59ba762. This hash uniquely identifies the exact scenario for which it was generated.SHA-256 + RIPEMD-160)from the original redeem script, so it is not possible to randomly or arbitrarily select a different hash.a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287Thus, the choice of this particular hash is dictated by the need for an accurate and secure linking of the output with specific spending conditions that control access to funds in the blockchain. All this is ensured by the properties of cryptographic hash functions, their uniqueness, and the impossibility of reverse recovery of the original data.
Bitcoin developers have written the P2SH (Pay-to-Script-Hash) mechanism into the code as a key innovation that ensures security and expands the capabilities of the blockchain network. Let’s consider the structure and operating principle of this script, its difference from classic transactions, as well as the reasons for choosing this approach to storing and protecting digital assets.
Traditionally, Bitcoin transactions have worked using the Pay-to-Pubkey-Hash (P2PKH) scheme – where funds are “locked” using the recipient’s public key hash. To spend these funds, the user must provide their digital signature and public key, which are verified by the network.
However, beyond P2PKH, the interface was limited, as Bitcoin Script allows for much more complex spending conditions, from multi-signatures to time locks and other smart contract agreements. The problem was that long and complex scripts inevitably increased the size of transactions and reduced their usability.
It was to simplify interaction with such complex scenarios that the P2SH concept was introduced in 2012 , standardized in BIP 16 by Gavin Andresen. The essence of P2SH comes down to replacing the full script of spending conditions in scriptPubKey with its cryptographic hash – the so-called script hash.

Let’s look at the script specified as a result of deserialization:
OP_HASH160 06612b7cb2027e80ec340f9e02ffe4a9a59ba762 OP_EQUALThis script differs from the standard P2PKH in that instead of a public key hash, it stores a hash of a redeemScript – a set of conditions under which funds can be spent.
To spend such funds, it is necessary to transmit in the inputs (scriptSig) of the transaction referring to this output:
When processing a transaction, network nodes:
P2SH thus shifts the responsibility for presenting and verifying the terms of the spend from the sender (who creates the required script) to the spender.
P2SH allows you to create addresses with arbitrary, often multi-level conditions – for example, a multi-signature requirement (2 out of 3, 3 out of 5, etc.), time limits, distribution logic, and much more. In this case, the sender simply sends funds to a compact hash address, without going into technical details.
Instead of storing the full script in the blockchain, only its hash is stored in the transaction. This reduces the load on the network, reduces the size of blocks and speeds up the verification of transactions.
Since the redeemScript is only revealed and verified at the time of spending, it increases the confidentiality of the terms and makes unauthorized access attempts more difficult. The use of cryptographic hash functions guarantees protection against forgery and modification – any slight deviation in the script will result in a different hash and the network will refuse to accept the transaction.
P2SH standardizes and simplifies the use of complex smart contracts in Bitcoin, simplifying integration and increasing compatibility with a variety of wallets and services.
A classic example is a wallet that requires signatures from two of five participants to complete a transaction. With P2SH:
This makes P2SH ideal for corporate accounts, joint ventures, and other situations where access control is required. The Pay-to-Script-Hash (P2SH) mechanism is a fundamental part of the Bitcoin architecture, providing a balance between:

ins)Let’s run a command to obtain information about one of the inputs of a transaction with a hash 6102bfd4bad33443bcb99765c0751b6b8e4e65f4db4e3b65324c5e9e3dac8132. Analysis of such an input is important for understanding the mechanism of authorization of spending funds at the script level.
!./darkai -scriptsig 6102bfd4bad33443bcb99765c0751b6b8e4e65f4db4e3b65324c5e9e3dac8132The result of extracting the first input of the transaction (
ins) is presented as follows:
{
'script': '00483045022100e5d7c59ea1fb5d0285e755dfc09634e1e3af36d12950b9b5d5f92b136021b3d202202c181129443b08dcfb8d9ced30187186c57c96f9cdb3f3914e0798682ea35d2b03493046022100e1f8dbad16926cfa3bf61b66e23b3846323dcabf6c75748bcfad762fc50bfaf402210081d955160b5f8d2b9d09d8838a2cf61f5055009d9031e0e106e19ebab234d949034c695221023927b5cd7facefa7b85d02f73d1e1632b3aaf8dd15d4f9f359e37e39f05611962103d2c0e82979b8aba4591fe39cffbf255b3b9c67b3d24f94de79c5013420c67b802103ec010970aae2e3d75eef0b44eaa31d7a0d13392513cd0614ff1c136b3b1020df53ae',
'outpoint': {
'index': 1,
'hash': 'ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577'
},
'sequence': 4294967295
}script)scriptis the scriptSig , which is used to unlock the corresponding previous transaction output.00, which in the context of scriptSig can mean OP_0 , traditionally used in multi-signature scenarios (e.g. in the case of the Pay-to-Script-Hash multi-signature standard, where a stub is needed).3045...), which typically consist of a series of bytes containing the signature details.outpoint)'hash': 'ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577'— is the hash of the previous transaction.'index': 1– indicates the second output (numbered from zero), which is used for unlocking.sequence)4294967295 (0xFFFFFFFF)is a maximum 32-bit number.Cryptanalysis of the extraction of the first transaction input (
ins) with the given transaction hash showed that:
ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577:1.Thus, the obtained data allows for a deeper understanding of the mechanics of checking the rights to spend funds, is used to ensure the security of the Bitcoin network, as well as in the development and audit of smart contracts based on Bitcoin scripts.
outs)Let’s run the command to get information about one of the outputs of the transaction with the identifier
ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577.
!./darkai -redeemscript ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577
outsSpecifically, the second output ( ) of this transaction, the element with index 1, was extracted .
{
'value': 350000,
'script': 'a91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287'
}value
scripta91406612b7cb2027e80ec340f9e02ffe4a9a59ba76287is a classic locking script (scriptPubKey) of the P2SH (Pay-to-Script-Hash) format .a9— OP_HASH160 is an operator that first applies SHA-256 and then RIPEMD-160 to the input data.14— the length (20 bytes) of the next value is the hash size.06612b7cb2027e80ec340f9e02ffe4a9a59ba762— 20-byte hash, also known as script hash , is a unique representation of the redeem script that controls the spending of these funds.87— OP_EQUAL is an operator that compares two values and returns true if they are equal.Thus, the script requires that in order to unlock (spend funds), the user presents a redeem script whose hash matches this value.
ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577is associated with an output that contains 0.0035 BTC.06612b7cb2027e80ec340f9e02ffe4a9a59ba762.
The information received confirms that the second transaction output record
ec2a40cac3ac5dadf1d31f3cad03bdc8465caab5acbc5407ee7f4a7400aab577stores the amount of 0.0035 BTC, controlled by a standard P2SH script with a hash160 value06612b7cb2027e80ec340f9e02ffe4a9a59ba762. To manage these funds, it is necessary to present the corresponding redeem script, which provides a high level of security and flexibility in managing bitcoins.
OP_FALSE 304502... 304602... 5221023927b5cd7facefa7b85d02f73d1e1632b3aaf8dd15d4f9f359e37e39f05611962103d2c0e82979b8aba4591fe39cffbf255b3b9c67b3d24f94de79c5013420c67b802103ec010970aae2e3d75eef0b44eaa31d7a0d13392513cd0614ff1c136b3b1020df53aeLet’s run the command to get HASH160 Bitcoin developers have set a standard for a 20-byte hash (hex) which is widely used without changes in other popular cryptocurrencies such as Bitcoin (BTC), Ethereum (ETH), Tether (USDT), BNB (BNB), Solana (SOL), XRP (XRP), Cardano (ADA), Dogecoin (DOGE), USDC (USDC), Polkadot (DOT), Avalanche (AVAX), Shiba Inu (SHIB), Stellar (XLM), TRON (TRX), Chainlink (LINK), Litecoin (LTC), Bitcoin Cash (BCH), Monero (XMR) to denote the shortened identifier of scripts and public keys.
!./darkai -hexdata 5221023927b5cd7facefa7b85d02f73d1e1632b3aaf8dd15d4f9f359e37e39f05611962103d2c0e82979b8aba4591fe39cffbf255b3b9c67b3d24f94de79c5013420c67b802103ec010970aae2e3d75eef0b44eaa31d7a0d13392513cd0614ff1c136b3b1020df53aeProcessing process:
06612b7cb2027e80ec340f9e02ffe4a9a59ba762This 20-byte hash (hex) is called HASH160 and is widely used in Bitcoin to denote a shortened identifier for scripts and public keys.
A key step in processing Bitcoin scripts using cryptographic hash functions.
Converting serialized scripts or public keys to HASH160 allows for efficient identification, indexing, and protection of data on the Bitcoin blockchain.
Received hash:
{'06612b7cb2027e80ec340f9e02ffe4a9a59ba762'}The team has produced the exact hash that serves as the link between complex scripts and the compact format used to store and verify transactions on the Bitcoin network.
Satoshi Nakamoto chose to use SHA-256 double hashing (that is, applying SHA-256 twice in a row) in Bitcoin’s hashing algorithms for several important reasons that enhance the cryptographic strength and security of the network.
Dual use
SHA-256is a deliberate choice by Satoshi Nakamoto to provide an additional layer of security and robust cryptographic strength to the entire Bitcoin system. This design minimizes collision risks, enhances one-wayness, and securely protects data on the blockchain network, creating a solid foundation for transaction security and consensus in the system. Thus, dual SHA-256 is a key element of the Bitcoin architecture, combining advanced cryptographic techniques with a distributed system.

The security and flexibility of modern Bitcoin transactions is based on a scripting system that allows for complex conditions for spending funds. One of the key mechanisms is multisignature (multisig) , when funds can only be spent if there are several valid digital signatures from a set of possible ones. In this article, we will take a detailed look at how exactly this is implemented in Bitcoin, what redeemScript is, how the OP_CHECKMULTISIG instruction works , and why such an approach is in demand.
In the context of Bitcoin, a redeemScript is a script containing the conditions for spending funds, which are stored in the transaction output in Pay-to-Script-Hash (P2SH) format. Instead of storing the full script on the blockchain, the redeemScript hash is stored in the output, saving space and hiding the details of the conditions until the time of spending.
RedeemScript can include, for example, multiple public keys and a threshold number of signatures – this is what multi-signature wallets implement.
Let’s consider the OP_CHECKMULTISIG instruction: purpose and operation, where the main element in redeemScript implementing the multi-signature check is OP_CHECKMULTISIG .
Due to a historical bug in the implementation of OP_CHECKMULTISIG , one extra element, an unused value, is removed from the stack during execution. To avoid this problem, scriptSig uses a special element
OP_FALSE(value 0) at the beginning, which compensates for this bug and prevents potential vulnerabilities.
OP_FALSE <signature1> <signature2> ... <redeemScript>OP_FALSEBased on the redeemScript code:
023927... 03d2c0... 03ec01... 3 OP_CHECKMULTISIG
OP_CHECKMULTISIGchecks that the two provided signatures (in scriptSig) correspond to two of the three keys and are valid.OP_FALSEin scriptSig compensates for the bug of removing the extra value.OP_FALSE, the mechanism has proven its reliability and has found wide application.RedeemScript with the OP_CHECKMULTISIG instruction is a complex and powerful tool in the Bitcoin arsenal that allows you to create multi-signature wallets with a signature threshold, providing a high level of security and control over funds. This mechanism has become a cornerstone for organizations, users and services that want to use shared management of their assets in a decentralized and secure environment. Thus, multi-signature via redeemScript and OP_CHECKMULTISIG is not just a technology, but a functionality that expands the capabilities of the classic cryptocurrency model.

The Bitcoin multi-signature verification mechanism is based on the use of special scripts with the OP_CHECKMULTISIG and redeemScript instructions , which allows for threshold signature matching, providing increased security and shared management of funds.
Multisig is a system in which multiple valid signatures from a given set of public keys are required to complete a transaction. A typical scheme is denoted as m of n — for example, “2 of 3,” where any two signatures from three keys are needed to authorize a spend.
In Bitcoin, this logic is implemented through:
The instruction
OP_CHECKMULTISIGchecks that the providedscriptSigsignatures are valid and match the published public keys from redeemScript.
RedeemScript is structured something like this:
OP_M <pubkey1> <pubkey2> ... <pubkeyN> OP_N OP_CHECKMULTISIGOP_Mand OP_N— instructions specifying the number of required signatures and the total number of public keys, respectively (for example, OP_2 and OP_3).<pubkeyX>— public keys of participants.OP_CHECKMULTISIG— an operator that implements multi-signature verification.m.An important technical feature is a historical implementation bug
OP_CHECKMULTISIGthat causes an extra, unused element to be removed from the stack. To compensate for this bug,scriptSiga valueOP_FALSE(code 0) is placed at the beginning to “lock” the stack shift.
For a wallet with a multi-signature “2 of 3”, before spending funds, it is formed scriptSigas follows:
OP_FALSE <signature1> <signature2> <redeemScript>OP_FALSE— a dummy value to compensate for the OP_CHECKMULTISIG bug.<signature1>and <signature2>– two digital signatures authorized by the owners of the corresponding private keys.<redeemScript>— the script itself with public keys and verification parameters.When verifying a node transaction:
If all inputs of a transaction pass this check, the transaction is considered valid. With such validity, by executing the operator of this bug, the attacker compensates for OP_CHECKMULTISIG as a potential vulnerability.
The Bitcoin multi-signature verification mechanism using the command
OP_CHECKMULTISIGand redeemScript allows for complex threshold signature schemes to be set up, and by executing this bug operator, an attacker compensates for OP_CHECKMULTISIG as a potential vulnerability in controlled transactions in the Bitcoin distributed network.
What are the features and limitations when OP_CHECKMULTISIGchecking multiple signatures? Let’s look at the key aspects and limitations:
OP_FALSEat the beginning to properly align the stack. This is a recognized and accepted feature by the community.
Bitcoin uses digital signatures to authorize transactions, allowing owners of funds to confirm their right to dispose of them. The peculiarity is that signatures can limit their scope of action not to the entire transaction, but only to a part of it. This is implemented using special flags – SIGHASH , which determine which transaction data exactly falls under the signature. Let’s consider the types of signature hashes, their purpose, examples of use, as well as features that arise in non-standard situations.
When signing a Bitcoin transaction, a digital signature is created that is formed over a specific fragment of transaction data. It is through the SIGHASH flag that it is indicated what part of this data this signature should cover. The signature hash type is transmitted by the last byte of the signature itself and determines the area included in the hash, and therefore in the signed section. This allows for flexible formation of conditions for what specific actions on the transaction are approved by the signer.
This is the default signature type in most wallets and clients. The signature covers all inputs and all outputs of the transaction , which means:
With this signature type, all inputs are signed, but none of the outputs are signed :
This signature type signs all inputs, but only one output – with the same sequence number as the input :
Consider a transaction with three inputs, where signatures ending with a byte
0x03pointing to SIGHASH_SINGLE have been extracted from the signature scripts (scriptSig) of two of them — that is, signatures that sign only the pair of corresponding inputs and outputs. However, here we observe a situation: the input with index 2 does not have a corresponding output with the same index.

791fe035d312dcf9196b48649a5c9a027198f623c0a5f5bd4cc311b8864dd0cf

Due to a historical Bitcoin bug, in such situations the transaction hash for signing is returned as a fixed number – one (int 1). This does not correspond to a valid hash of the transaction being signed and can create security and compatibility issues.
In addition to the three basic SIGHASH values, combinations of these values are possible with the SIGHASH_ANYONECANPAY flag , which allows only one input to be signed, leaving the others open for modification. This expands the possibilities for creating complex collaborative protocols and multi-party transactions, where different participants sign only their parts.
Types
SIGHASHareBitcoina clever mechanism for managing the level of control and scope of digital signatures within transactions. They strike a balance between security, flexibility, and compatibility. The story includes unexpected complications, such as the bug withSIGHASH_SINGLEno corresponding output, which highlights the importance of a deep understanding of the technical details to successfully work with Bitcoin at an advanced level.
The differences between the SIGHASH_ALL, SIGHASH_NONE, and SIGHASH_SINGLE signature types have a significant impact on the security of Bitcoin transactions because they determine which parts of the transaction are kept within the digital signature and therefore protected from modification.
Incorrect use or lack of correct implementation of SIGHASH_ALL in Bitcoin transaction signatures can lead to serious vulnerabilities affecting the security of funds and the integrity of the system. The key aspects of these vulnerabilities are:
SIGHASH_ALL, such as ignoring or incorrectly handling the trailing byte, can result in transactions with incorrect coverage of the elements being signed (inputs and outputs) being validated. This opens the door to attacks in which an attacker manipulates parts of a transaction to disable protection or escalate their privileges.
Thus, incorrect use
SIGHASH_ALLor errors in the implementation of its verification significantly undermine the security of the Bitcoin network, allowing attackers to manipulate signatures and transactions. To combat these vulnerabilities, strict checks of the format and ranges of signatures are being implemented, improved protocols are used (for example,SegWiteliminating some of the problems with signature variability), and secure methods of signing and validating transactions are being standardized.
An invalid signature with the SIGHASH_ALL type increases the risk of double spending in Bitcoin for the following reasons:
When using SIGHASH_ALL, the signature covers all inputs and outputs of the transaction, ensuring that no element of the transaction can be changed after signing. However, if the signature is formed incorrectly, for example due to errors in the random number generation or the formation of the signature parameters (r, s) themselves, this may lead to the fact that part of the transaction can be changed without invalidating the signature. In particular, a vulnerability arises in which an attacker can change individual fields or the structure of the transaction, creating variations that are accepted by the network as valid, but differ from the original.
This signature malleability allows attackers to create alternative versions of a transaction with a different identifier ( txid), making it difficult to track and confirm payments, and in some cases leading to the reuse of the same inputs – i.e. double spending.
| Type Sighash | What is being signed? | Security level | Possible risks | Application |
|---|
| SIGHASH_ALL | All inputs and outputs of the transaction | Maximum – no changes at all | Requirement for change (need to re-sign the transaction) | Standard for most payments |
| SIGHASH_NONE | All ins, no outs | Medium – outputs are not protected | Substitution of outputs, loss of control over recipients | Cooperative scenarios, multi-signature |
| SIGHASH_SINGLE | All inputs, output with index corresponding to input | Low – only one output will be protected | Bug in the absence of the corresponding output, partial substitution | Partial payments, complex scenarios |