Bitcoin Forum
May 10, 2024, 04:36:36 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Pasting untrusted blocks/ and chainstate/ to new pruned node safe?  (Read 1093 times)
watashi-kokoto (OP)
Sr. Member
****
Offline Offline

Activity: 682
Merit: 269



View Profile
February 14, 2016, 05:42:14 PM
Merited by ABCbits (1)
 #1

I ask if it's safe to download untrusted blocks and chainstate from the internet and paste it to a pruning Bitcoin Core as a quick-start method?

Does Core validate the UTXO?

Edit: Is the chain cross platform?
Make sure you back up your wallet regularly! Unlike a bank account, nobody can help you if you lose access to your BTC.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715315796
Hero Member
*
Offline Offline

Posts: 1715315796

View Profile Personal Message (Offline)

Ignore
1715315796
Reply with quote  #2

1715315796
Report to moderator
TierNolan
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
February 14, 2016, 06:28:19 PM
 #2

Using a bootstrap file with the blockchain is safe.  Pruning nodes process the entire blockchain and verify everything.  Once they have processed a block, they don't have to keep the block data.  In practice, they keep the most recent blocks (and always at least 2 days).

You can't use any chainstate data from the internet (UTXO and wallet data).  Pruning nodes assume that the chainstate they have is correct, since they generated it while processing the block data.

[Edit]
The bootstrap file is generally a single file for bootstrapping from the internet.  It isn't the directory.  If the directory comes from a pruning node, then it won't have the entire blockchain anyway.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 14, 2016, 06:36:18 PM
 #3

The "checkpoints" don't come into this at all?

(I haven't checked the source code myself but have heard conflicting things about the validation of "old blocks")

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
TierNolan
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
February 14, 2016, 08:25:09 PM
 #4

The "checkpoints" don't come into this at all?

The original question was just copying the /block and /chainstate directories.  That is not safe, since there is no checking.

If you use the bootstrap method, then the node reads the blockchain from the bootstrap file as if it was downloaded from the internet.  All blocks are checked as normal.

You can also use the -loadblock command.

bitcoind -loadblock=blk00001.dat -loadblock=blk00002.dat ....

I think you have to give them in order.

If you add a block called bootstrap.dat into the data directory, then it is automatically used for bootstrapping.

Quote
(I haven't checked the source code myself but have heard conflicting things about the validation of "old blocks")

The checkpoints have 2 effects.  If a block at any of the checkpointed heights has the wrong hash, then it is rejected.  This means that once a block is checkpointed, core will not accept any chain that doesn't include that block.

The second effect is with signature validation.  Core doesn't check signatures until it hits the final checkpoint.

In 0.12, the last checkpointed block is at height 295000.  This means that core doesn't check signatures until it hits block 295001.  From them on, it checks signatures.  The code is here.

You cannot keep checkpoints and still do the signature checks. 

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
CIYAM
Legendary
*
Offline Offline

Activity: 1890
Merit: 1078


Ian Knowles - CIYAM Lead Developer


View Profile WWW
February 15, 2016, 03:04:37 AM
 #5

The "checkpoints" don't come into this at all?
You cannot keep checkpoints and still do the signature checks. 

Presumably for those blocks prior to the last checkpoint it is verifying that the block hash matches the actual content though - correct?

(skipping the signature verification being an optimisation permitted by using checkpoints)

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
-ck
Legendary
*
Offline Offline

Activity: 4102
Merit: 1632


Ruu \o/


View Profile WWW
February 15, 2016, 03:21:58 AM
 #6

If you have pruned a copy of the blockchain and then shut down your bitcoind, you can safely copy the pruned contents of the .bitcoin directory across and use the pruned directory as is. I have done so many times over without problem.

Developer/maintainer for cgminer, ckpool/ckproxy, and the -ck kernel
2% Fee Solo mining at solo.ckpool.org
-ck
theymos
Administrator
Legendary
*
Offline Offline

Activity: 5194
Merit: 12982


View Profile
February 15, 2016, 03:53:43 AM
Last edit: February 15, 2016, 04:14:01 AM by theymos
Merited by ABCbits (1)
 #7

It is never safe to use untrusted copies of those directories. When someone gives you an already-made block database, it's possible for them to manipulate it so that they can fork you off of the real chain at any time or do various other nasty things. By default Bitcoin Core does no checking of info in the database except for some basic checks of the last few blocks. Checkpoints are not rechecked. And even Bitcoin Core's checkblocks feature won't find all possible traps.

The database files are cross-platform, but you should copy them only if you trust the source absolutely. Also, the files are all intimately related and different per node, so it won't work to copy just some files -- it needs to be an all-or-nothing copy.

P.S. watashi-kokotoのアブターはとてもかわいい。

1NXYoJ5xU91Jp83XfVMHwwTUyZFK64BoAD
-ck
Legendary
*
Offline Offline

Activity: 4102
Merit: 1632


Ruu \o/


View Profile WWW
February 15, 2016, 05:18:34 AM
 #8

It is never safe to use untrusted copies of those directories. When someone gives you an already-made block database, it's possible for them to manipulate it so that they can fork you off of the real chain at any time or do various other nasty things. By default Bitcoin Core does no checking of info in the database except for some basic checks of the last few blocks. Checkpoints are not rechecked. And even Bitcoin Core's checkblocks feature won't find all possible traps.

The database files are cross-platform, but you should copy them only if you trust the source absolutely. Also, the files are all intimately related and different per node, so it won't work to copy just some files -- it needs to be an all-or-nothing copy.

P.S. watashi-kokotoのアブターはとてもかわいい。
I wasn't advocating using someone else's copy...

僕のは可愛くないの

Developer/maintainer for cgminer, ckpool/ckproxy, and the -ck kernel
2% Fee Solo mining at solo.ckpool.org
-ck
TierNolan
Legendary
*
Offline Offline

Activity: 1232
Merit: 1083


View Profile
February 15, 2016, 12:20:15 PM
 #9

Presumably for those blocks prior to the last checkpoint it is verifying that the block hash matches the actual content though - correct?

Exactly, if you trust the checkpoint, then you can trust the blocks.  Having said that, it does still check everything else.  It makes sure every transaction is spending money that actually exists etc.

1LxbG5cKXzTwZg9mjL3gaRE835uNQEteWF
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4172
Merit: 8419



View Profile WWW
February 15, 2016, 11:59:31 PM
Merited by ABCbits (2)
 #10

Beyond the issue of potential problems in the data itself-- there has been no auditing or effort to make sure these raw database files are safe for malicious input. (In the case of the bdb wallet files, I'm reasonably confident that they are not safe.)

Running a database (chainstate, txindex, blockindex) or wallet from an untrusted third party might result in giving them arbitrary code execution on your system.

The loadblock raw blockfile imports, otoh, are handled the same way as data from the network and are designed to handle untrusted input.
srinikethan
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
February 20, 2016, 04:59:51 PM
 #11

Actual result:
Core trusts index and chainstate blindly

Expected results:
Core loads the pruned index and chainstate
Core catches up
Core compares the utxo - hash with other network nodes
If some other node has different database hash the node will fail to start
EDIT: or ban the liar node

Alternative expected result:
Core loads the pruned index and chainstate
Core catches up
User is notified to add configuration option that the user is aware the chain might be untrusted
The value of the option could be dependent on some kind of hash derived from latest block or machine specific random uuid
This will prevent user to download the configuration file from untrusted source because attacker cannot predict this value
gmaxwell
Moderator
Legendary
*
expert
Offline Offline

Activity: 4172
Merit: 8419



View Profile WWW
February 21, 2016, 10:16:56 PM
 #12

srinikethan, I think your expectations are unrealistic.

It takes a long time-- tens of seconds to hash the UTXO set on a fast host. No random peers are just going to do this for you today. (Incrementally updating a tree structured hash could be done, but only with a considerable on disk and in memory overhead.)3

Even if they do, anyone can spin up as many nodes as they want, simply asking other nodes and then refusing to run if they disagree is just a DOS vector.

If, instead, you ban ones that disagree with you this just guarantees you'll only be connected to the party that gave you the bad data.

So what has this accomplished?

This also has ignored my point that format of these databases is likely not secure against malicious input, and might well result in remote code execution for the party that gave them to you.


As far as machine specific random values go-- yes that could probably be done, though then your node would stop working when you upgraded hardware/software and it would get in the way of copying state between systems which you control where there is no trust issue.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!