How your data is safe in Hyperledger Fabric when one can make changes to couchdb data directly
Asked Answered
D

8

8

I am wondering that how your data is safe when an admin can change the latest state in Couchdb using Fauxton or cURL provided by Couchdb directly.

According to my understanding Hyperledger Fabric provides immutable data feature and is best for fraud prevention(Blockchain feature).

The issue is :- I can easily change the data in couchdb and when I query from my chaincode it shows the changed data. But when I query ledger by using GetHistoryForKey() it does not shows that change I made to couchdb. Is there any way I can prevent such fraud? Because user will see the latest state always i.e data from couchdb not from ledger

Any answer would be appreciated.

Thanks

Duty answered 20/4, 2018 at 5:1 Comment(2)
seems like its a limitation in Hyperledger-FabricDuty
how about not exposing the CouchDB service to the ports?Jeth
M
9

You should not expose the CouchDB port beyond the peer's network to avoid the data getting tampered. Only the peer's administrator should be able to access CouchDB, and the administrator has no incentive to tamper their own data. Let me explain further...

The Hyperledger Fabric state database is similar to the bitcoin unspent transaction database, in that if a peer administrator tampers with their own peer’s database, the peer will not be able to convince other peers that transactions coming from it are valid. In both cases, the database can be viewed as a cache of current blockchain state. And in both cases, if the database becomes corrupt or tampered, it can be rebuilt on the peer from the blockchain. In the case of bitcoin, this is done with the -reindex flag. In the case of Fabric, this is done by dropping the state database and restarting the peer.

In Fabric, peers from different orgs as specified in the endorsement policy must return the same chaincode execution results for transactions to be validated. If ledger state data had been altered or corrupted (in CouchDB or LevelDB file system) on a peer, then the chaincode execution results would be inconsistent across endorsing peers, the 'bad’ peer/org will be found out, and the application client should throw out the results from the bad peer/org before submitting the transaction for ordering/commit. If a client application tries to submit a transaction with inconsistent endorsement results regardless, this will be detected on all the peers at validation time and the transaction will be invalidated.

Masha answered 11/2, 2019 at 1:22 Comment(1)
Why can't we use ledger data directly by parsing the block in chaincode instead instead of verifying from the state database?Ilium
C
7

You must secure your couchdb from modification by processes other than the peer, just as you must generally protect your filesystem or memory.

If you make your filesystem world writable, other users could overwrite ledger contents. Similarly, if you do not put access control on couchdb writes, then you lose the immutability properties.

Civvies answered 23/4, 2018 at 18:4 Comment(0)
H
6

In Hyperledger Fabric v1.2, each peer has its own CouchDB. So even if you change the data directly from CouchDB of one peer. The endorsement would fail. If the endorsement fails, your data will not be written neither in world state nor in the current state.

Hurleigh answered 3/8, 2018 at 17:12 Comment(2)
What do you mean when you say endorsement fails? As far as I know only transactions are endorsed. Changing couchdb data directly from fauxton or curl does not generate any new transactions.Lyda
This reply is simply untrue, try it.Wallachia
T
5

That's the beauty of a decentralized distributed system. Even if you or someone else changes the state of your database/ledger it will not match with the state of others in the network, neither will it match the transaction block hash rendering any transactions invalid by the endorsers unless you can restore the actual agreed upon state of the ledger from the network participants or the orderer. To take advantage of the immutability of ledger you must query the ledger. Querying the database does not utilize the power of blockchain and hence must be protected in fashion similar to how access to any other database is protected.

Torse answered 23/4, 2018 at 19:9 Comment(0)
B
2

You need to understand 2 things here

  1. Although the data of a couchdb of a peer maybe tampered, you should setup your endorsement policy in such a way that it must be endorsed by all the peers.

  2. You cannot expose your couchdb to be altered, I recommend to see Cilium

Brillatsavarin answered 19/2, 2019 at 13:42 Comment(0)
C
1

As explained by others - endorsements/consensus is the key. Despite the fact that ledger state of an endorsing peer can be modified externally - in that event all transactions endorsed by that peer would get discarded, because other endorsing peers would be sending correct transactions (assuming other's world state was also not tampered with) and consensus would play the key role here to help select the correct transaction.

Worst case scenario all transactions would fail.

Hyperledger fabric's world state (Ledger state) can be regenerated from the blockchain (Transactions Log) anytime. And, in the event of peer failure this regeneration happens automatically. With some careful configuration, one can build a self-healing network where a peer at fault would automatically rise from ashes (pun intended).

The key point to consider here is the Gossip Data dissemination protocol which can be considered as the mystical healer. All peers within the network continuously connect, and exchange data with other peers within the network.

To quote the documentation -

Peers affected by delays, network partitions, or other causes resulting in missed blocks will eventually be synced up to the current ledger state by contacting peers in possession of these missing blocks.

and ...

Any peer with data that is out of sync with the rest of the channel identifies the missing blocks and syncs itself by copying the correct data.

That's why it is always recommended to have more and more of endorsing peers within the network and organizations. The bigger the network - harder it would be beat with malicious intent.

I hope, I could be of some help. Ref Link: https://hyperledger-fabric.readthedocs.io/en/release-1.4/gossip.html

Conduction answered 14/3, 2019 at 11:19 Comment(0)
P
1

"a state reconciliation process synchronizes world state across peers on each channel. Each peer continually pulls blocks from other peers on the channel, in order to repair its own state if discrepancies are identified."

Photochronograph answered 9/9, 2019 at 5:12 Comment(0)
N
0

Even though this is plausible, the endorsement policy is the general means by which you protect yourself (the system) from the effects of such an act.

Novice answered 23/4, 2018 at 18:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.