GHSA-v666-6w97-pcwm: Ckb Miner Fails To Get Block Vulnerability
HIGHGHSA-v666-6w97-pcwm is a HIGH miner fails to get block vulnerability (CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition) affecting Ckb libraries in the crates.io ecosystem. The issue involves miner fails to get block template when a cell used as a cell dep has been destroyed.. Remediation is available by upgrading affected packages to version 0.40.0.
GHSA-v666-6w97-pcwm at a Glance
How to Fix GHSA-v666-6w97-pcwm
To remediate this vulnerability, upgrade all affected Ckb dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
Upgrade ckb to 0.40.0
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
inspect dependencies for ckb
How to Check if You Are Affected
To determine whether your application is affected by GHSA-v666-6w97-pcwm, inspect your project dependencies for Ckb:
inspect dependencies for ckb
Analyze the terminal output to locate any version of Ckb in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 0.40.0), your application is affected.
Note: Verify declared build manifests and deployed runtime container environments.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-367: Time-of-check Time-of-use (TOCTOU) Race Condition, where the product checks the state of a resource before using that resource, but the resource's state can change between the check and the use in a way that invalidates the results of the check. In Ckb, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
GHSA-v666-6w97-pcwm Affected Ckb Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
ckb
|
crates.io |
< 0.40.0
|
0.40.0
|
References
Frequently Asked Questions
What is GHSA-v666-6w97-pcwm?
Which Ckb versions are affected?
What version fixes GHSA-v666-6w97-pcwm?
Is ckb affected?
What CWE is associated with GHSA-v666-6w97-pcwm?
How can I check crates.io dependencies for GHSA-v666-6w97-pcwm?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-v666-6w97-pcwm",
"modified" : "2021-08-02T21:55:20Z",
"published" : "2021-08-25T21:01:21Z",
"aliases" : [ ],
"summary" : "Miner fails to get block template when a cell used as a cell dep has been destroyed.",
"details" : "### Impact\n\nThe RPC `get_block_template` fails when a cell has been used as a cell dep and an input in the different transactions.\n\nSay cell C is used as a dep group in the transaction A, and is destroyed in the transaction B.\n\nThe node adds transaction A first, then B into the transaction pool. They are both valid. But when generating the block template, if the fee rate of B is higher, it comes before A, which will invalidate A. Currently the RPC `get_block_template` will fail instead of dropping A.\n\n### Patch\n\nFirst, the `get_block_template` should not fail but dropping the conflict transactions.\n\nThen we can propose solution to this issue. Here is an example. When a transaction is added to the pool, the pool must consider it depending on all the transactions which dep cell (direct or indirect via dep group) has been destroyed in this transaction. Because future transactions using the destroyed cells as dep will be rejected, the spending transaction only need to wait for all the existing dep transactions on chain.\n\n### Workaround\n\n1. Submit transaction B when A is already on chain.\n2. Let B depend on A explicitly, there are several solutions:\n * a. Add any output cell on A as a dep cell or input in B.\n * b. Merge A and B. CKB allows using the same cell as both dep and input in the same transaction.\n3. Ensure the fee rate of B is less than A so A always has higher priority.\n",
"severity" : [ ],
"affected" : [ {
"package" : {
"ecosystem" : "crates.io",
"name" : "ckb"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "0.40.0"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/nervosnetwork/ckb/security/advisories/GHSA-v666-6w97-pcwm"
}, {
"type" : "WEB",
"url" : "https://rustsec.org/advisories/RUSTSEC-2021-0107.html"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-367" ],
"severity" : "HIGH",
"github_reviewed" : true,
"github_reviewed_at" : "2021-08-02T21:55:20Z",
"nvd_published_at" : null
}
}