Disclaimer: Content was not created with intention to plagiarize or to illegally distribute the paid course material. These are notes created with the purpose of self-study and revision. Blockchain-council.org maintain the rights to the contents of course found here: https://academy.blockchain-council.org/courses/take/certified-blockchain-security-professional-training
- 1. Blockchain Basics
- 2. Blockchain Concensus
- 3. Different Security Mechanism
- 4. Blockchain Risk Considerations
- Block chain architectural design
- 5. Two-Factor Authentication (2FA) with Blockchain
- 6. Blockchain Vulnerabilities and Attacks
- 7. Directed Acyclic Graphs (DAGs)
- Transaction record database that is distributed
- Decentralized (no one entity maintaining it)
- P2P (peer to peer) network
- New transactions are added into a 'ledger' but this ledger is tamper proof
- Permanently stores data in sequential link of cryptographic links (called blocks)
- Shared between all member nodes of network
- Verified and validated
- Added to the start of the chain
- Peers in a blockchain uses an agreed protocol.
- Integrity of data is ensured via Crptography hashes and digital signatures.
- Hashes changes when data is tampered with
- Original senders sign data using digital signatures
- Arranges data into groups or blocks that are linked or chained together.
- Timeline of data made automatically with accurate timestamp.
- When block is "filled" it is put into the block chain and merged into this timeline.
| basis of comparison | blockchain | cryptocurrency |
|---|---|---|
| Nature | Technology that records transaction | Tools used in virtual exchanges |
| Use | Record transactions | Make payments, investment etc |
| Value | No monetary value | Have monetary value |
| Mobility | Cannot be transferred | Can be transferred |
- A
blockis like a Ledger page or a record book.
- Permanently record data existing on the blockchain.
- Cannot be modified or deleted once it has been published.
- A
blockrecords any transaction which have not entered any previous blocks. - First block (aka Genesis
block), all confirmed and validated blocks derive from this first block. - Each
blockis created with an attachment of hash. - Each
blockhas a reference to the last block (creating a chain link) :exclamation: In theory it is possible to modify all blocks with powerful computer processers, but there is a way that overcomes this calledproof of work
- Any device connected to a network of blockchain is defined as a
node - Full nodes - Completely implement all blockchain rules. They form the core or network backbone.
- Lightweight nodes - Most nodes are lightweight nodes.
- Each
nodeor device are actually client and a server at the same time. - Computer systems are connected to each other over the internet to form a P2P (peer-to-peer) network.
- 10 mins to determine a
proof of work. - Then append a new block to the chain in the bitcoin blockchain architecture.
Minerscarry out this procedure, they are specialnodeswithin the bitcoin blockchain framework- As a reward for validating blocks, they get transaction fees from the block as a reward.
-
Digital Identity is used to verify users
- private key
- public key (visible to everyone)
-
Authorization (approved mutually) happens before transaction is appended to a block in the chain.
-
For public blockchain use - adding a transaction to the chain is made with the help of consensus
-
Majority of nodes/computers in the network must show consensus that transaction is legitimate
-
Rewards and incentives are given to people who posses the computers in the network to verify transactions -
proof of work
- Concensus are mechanisms are protocol make sure all nodes are synchronized with each other
- Some examples are:
- Proof-of-Work (PoW)
- Proof-of-Stake (PoS)
- Delegated Proof-of-Stake (DPoS)
- Proof-of-Importance (PoI)
- Simplified Byzantine Fault Tolerance (SBFT)
- Delegated Byzantine Fault Tolerance (DBFT)
- Practical Byzantine Fault Tolerance (PBFT)
- Proof-of-Elapsed Time (PoET)
❗ In theory, it is possible to hack this if the hacker can simultaneously control and edit 51% of the copies of blockchain so that their new copy becomes the majority copy and thefore the agreed upon chain
- Hash based data structure
- Each leaf node is hash of a data block
- Each non-leaf node is a hash of its offsptring
- Mining is the process of recoding the pending transaction by adding a new Block into the Blockchain through a mathematical puzzle
- Miners get rewarded by receiving new coins of that Blockchain
- Anyone can read/write without authorization and permission
- More complex rules and consensus algorithm
- Computationally expensive to mine and add a block
- Computational power is distributed globally
- examples: Bitcoin, Ethereum
- Only Authorized node can read/write
- One authorized node can be arbitrator for dispute
- Security is easier as network consists of trusted nodes
- Easy or computationally less expensive to add a Block
- examples: Hyperledger, R3 corda
- Modification to protocol such as when adding new features, fixing security issues
- Chain is split into 2 branches eg. cannot come to a consensus
- Two kinds of Forks: Hard Fork, Soft Fork.
- Permanent drift - when there is new and updated versions
- Happens when there is enough support from the mining community (90 to 95% support of miners)
- E.g. after an upgrade, the new consensus protocol must be used
- Soft fork - fork that occur when old network nodes do not follow a rule followed by newly upgraded nodes.
- New rules are followed by old rules will also be honored (backward compatibility)
| Hard forks | Soft forks | |
|---|---|---|
| Level | Work at Protocol level | Work at Network level |
| Power | N.A | Require 50% of hash power |
| Upgrade | All nodes and users must upgrade | Do not require all to upgrade |
| Split | Those fail to fork will be split from network | Will not cause a network split |
| DAO Attack | Can return funds without attacker's consent | Cannot retrieve funds from the attacker |
-
Provide continuous check on the integrity of both (1) New data blocks (2) Past ledger transactions
-
Rules defined for every blockchain application for generating new blocks: (1) Validate legitimacy of new blocks before adding to chain (2) Apply to all nodes (aka blockchain's network) (3) Processes for validating new blocks of data - written in computer code using algorithms
- Uses scheme of rewards to encourage users to participate in minding
- Simply "solve puzzles", gain rights and earn rewards for efforts such as fees
- Define privileges according to the actual known investment of users
Less complex or computer intensive consensus
- Proof-of-Authority (PoA), that verifies the identity of the node
- Simple delegation of authority to those trusted nodes to accept new blocks
- Allow authenticated nodes to publish new blocks at will or rotational basis.
❗ When users on the blockchain do not stick to accepted procedure on the network, the user loses credibility and user's reputation drops, probability of publishing a block also drops. In reality, all this is dynamic and block creation rates can be fast.
- When a block mathematical puzzle is 'solved' by miners, the transactions contained in that block are considered validated
- Miners receive some rewards when they solve the complex mathematical problem
- In short, the 'maths' problem is distributed to all Generals (Byzantine Generals Problem)
- Solution is integrated to the next PoW problem block.
- Block is created each time a General solves a PoW problem
- A General solves the problem of PoW - everyone elses would eventually solve theirs and know approximately how long it takes for Generals to solve the problem, and if they are still working on the same chain.
- Principle that no entity should obtain more than 50% of the total hashing or computing power
- If an attacker have e.g. 51% of the total hashing power the following can be exploited
Inject false transactions Exploit Blockchain network Eliminate all other users from network Perform double-spending Steal assets from other users
❗ GHash.io alone dominated 54% of the whole BTC network processing power for a day
Attacker use same coins to issue two or more transaction, spending More than they actually own. If transaction gets more approval, the less likely the transaction will be reversed in future
Miners raise their porportional mining share by selecting withholding mined blocks and then publishign them progressively. It is possible for an attacker with 33% mining power to use this method to earn 50% of the mining power.
:exclaimation: When all nodes in the blockchain are tightly synchronized, these attacks can be mitigated.
- Unlike Proof-of-Work, Proof-of-Stake chooses the creator of a new block in a deterministic way (depending on its wealth or stake)
- Like PoW, this consensus protocol also seek to address the problem of Byzantine Generals.
- Solutions had been deployed by a few PoS-based networks that avoid double spending attacks and other security vulnerabilities that could arise due to Byzantine failures.
❗ Ethereum 2.0 (Senerity) have a PoS algorithm named Casper which allow nodes to achieve consensus with a two-thirds majority before blocks can be formed.
- Principle that no entity should obtain more than 50 percent of digital asset
❗ PoS is said to be an safer option for the 51% vulnerability
Security features:
- Penalties for attackers: (1) validator will lose all confidence e.g. to be able to publish a new block (2) Depletion of cryptocurrency valuation - loss of attacker's net worth
- Barriers to 51 percent stake (1) buying 51 % stake in one go will have increased difficulty. (2) Coin demand drives up price, making it a very expensive choice.
Similar to PoW
Attacker use same coins to issue two or more transaction, spending More than they actually own. If transaction gets more approval, the less likely the transaction will be reversed in future
Selfish mining is not possible as there is no reward for miners unlike for PoW. Also, the new PoS Casper protocol impose penalties on malicious actors
- 3 Groups of people; (1) Consumers (2) Delegates - administer (3) Witness secure network
- Consumers vote for witnesses to secure their network
- More tokens one hold = Stronger vote strength e.g Rich are powerful
- If witness are bad, people in community can remove their votes (or fire them)
- Delegates are elected in a manner similar to witness. They administer the network. But can recommend change in size of block or rewards paid by a witness in exchange for validation of a block. Consumers vote whether to implement them.
- Strong protection against doublespending
- More democratic, easier to participate in vote (lesser stake held by user)
- More decentralization as more people can particpate (due to low entry threshold)
- Dont need high amounts of power to run network
- Seperates election of block producers from block production
- Provide basis for implementing governance models
- Delegators need to be well informed and appoint honest witnesses
- Restricted no of witness can lead to heavy centralization of network
- Vulnerable to weighted voting - smaller stake voters may not take part in voting with possiblity that their "vote wont matter"
- Offers high tolerance for performance and faults
- Nodes are authenticated and authroized to create new blocks
- Tolerance to compromised and malicious nodes
- High transactions rate
- Predictable block time
- Transfer cryptocurrency coins to an address where no one can retrieve
- This protocol is expected to fix issues surrounding energy consumption
- Coins in the address can be viewed by anyone one, but not accessible
- Used by online P2P marketplace OpenBazaar to enable members to execute Credibility Pledges. As they have invested resources on it, these pledges reflect a contribution to an identity on the web.
- Designed to improve Proof-of-work
- Alternative for permissioned networks
- Removes the need for mining-intensive process
- Joining the network and verification
- Elapsed time, randomized lottery selection process
- Major increase in the performance of proof-of-work protocol
- Function of finding an agreement or consensus on individual blocks based on Proof-of-work
- Certain nodes refuse to respond or send out malicious values to misguide the network
- BFT is a way to overcoming these challenges:
(1) Node has technological fault, stops running or responding (2) Random node failure. Node could fail to return response or respond to a misleading response intentially.
- Idea of finding consensus based on majority of truthful nodes
- Protect against Byzantine fault
- Optimizated for BFT
- Each 'General' manages an ongoing information status
- Consensus is made based on total number of decisions submitted by All the Generals
- Achieve agreement without Miner's assistance using Tangle.
- Tangle resolve massive micro-transactions in IoT networks.
- Scalable and TPS are high using Unique Data-Structure
- Output of transaction depends on ability to verify 2 prior transactions
- Digital signatures - electronic signed by the private key of holder, validated with the public key
- Encryption
- Authentication
- Non-repudiation
- Integrity
- Confidentiality
- Alternative technique to RSA
- Provides same security as RSA but it is less computer intensive as it uses smaller key sizes
- Commonly used such as used by bitcoin is SHA-256
- AES 128, 192, 256bits with 3 different key weights and each has block 128 bits
Different Key sizes have different 'rounds' of encryption mathematical operations
| key size | rounds |
|---|---|
| 128-bit keys | 10 rounds |
| 192-bit keys | 12 rounds |
| 256-bit keys | 14 rounds |
* the more secure the encryption (eg. bigger the key) the more time it takes to encrypt (the trade-off between security and performance)
- Block ciphers, each block is 128 bits long
- 128 bits of cipher text is producted each time 128 bits of plaintext go through the algorithm
- Not recommended to be used already as it will be deprecated by 2023 by NIST and disallowed from 2024 onwards.
- Considered not secured in modern cryptography
- Symmetric block cipher
- 8-byte fixed data block size and keys range from 32 to 448bits (4 to 56bytes)
- Considered safe and fast - if keys are large enough to survive a bruteforce attack (at least 16 bytes)
- Symmetric block cipher
- 128-bit block size and accepts a key of up to 256bits.
- Fast and flexible and suitable for network environments where keys are constantly modified
- Suitable environmemts where RAM and ROM are limited or not usable
- 2nd best after AES.
- Without revealing any additional details, one party (prover) may prove that a certain assertion is valid to the other party (verifier)
- Consensus & Network
Defective consensus mechanism impact wide spread - e.g. all organizations running on blockchain will be affected by major threats
- Cryptographic Key management
Key pairs not properly maintained
- Functional requirements
Require careful decisions to incorporate a blockchain
- Smart contracts
Programmatically executed Condition based and are executed automatically - error such as unintentionally executing
- Data management & privacy
Any transactions approved by the ledger is final Meaning, incorrect, incomplete or illegal transactions may not be revoked
- Centralized & Collusion
Although blockchain are formed by independent nodes Can potentially be owned by a single entity or organizational partnership - hence centralizing control
- Interoperability & Integration
Risks related to technical issues when blockchain are deployed to legacy IT networks Compatibility restrictions
- Scalabilty & Continuity
Coordination and interaction between nodes is important for achieving consensus (agreeing on something) Nodes are often isolated and situated in Internal infra (Not public facing and readily accessible) Above will result in loss of scalability or endanger continuity
- Third Party & Governance
Blockchain relys on network of individual and their participating organization's network. Risk may arise not from an individual's environment, but from its third party environments which is not within immediate control.
- Compliance
Goverment policy and regulation are still in implementing and experimenting state Lack of compliance to laws May put risks of organization in risk such as money laundering, funding terrorists
- Blockchain implementation can be complex
eg. to transfer data across the "hyper ledger fabric" protocol "Ethereum" protocol. They will require an integration layer to manage both systems.
- Lack of standardizations
Too much diversity of frameworks Investers have no effective protection against investments
- Poor valuation value
- Extreme wide swings in crypocurrency values
- May put danger on traders betting on projects
Blockchain is evolving into DLT (Distributed Ledger Technology). Hyper Ledger and IOTA make uses of this (and others) and they all pose the same risks:
- Under developed standards
No uniformity Lack standards for taking up this technology in a way every can follow Different versions for different organizations Hard to collaborate among organizations As such, Risk of security, privacy, interoperability
- Different consensus mechnisms
different consensus have its drawbacks
- Data privacy due to different regulations
Which privacy law should data adhere to? E.g. EUS privacy only shield transactions between EU and US
- Decrease attack surface - Such as by continous security vulnerability assessment, continously redefining risk assessment scope to be inclusive of all
- Total Visibility - Understanding current threats and have the latest intel of 0-days and exploitation. Being well informed sets the basis for what to defend against.
- Prevent risks that are known - Firewall, antivirus, endpoint protection to not defend against common and popular vulnerabilities
- Prevent risks that are uncertain - Red teaming, studying of intruder techniques, tactics and procedures to be better prepared to respond to such threats
Approach begins with the decision to decentralize authority or not.
- Cloud based - 2FA providers. Typically used extensively for e-commerce, online banking etc
- On-premise solution - Using internal VPN integrator who process certificates and shares a key between Internal 2FA providers and third parties. E.g 3rd party 2FA providers can produce OTP and exchange it via sms or mobile apps with employee
Ethereum allows applications (dApps) to be programmed with a smart contract. Having.
Some companies such as Bit ID have projects that allow users sign up to any service using their unique bitcoin wallet addresses and private keys. Such a platform could be adopted to serve as a 2FA protocol on top of the bitcoin blockchain.
- Clients-side vulnerabiltiies
- Consensus mechanism vulnerabilities
- Mining pool vulnerabilities
- Network vulnerabilities
- Smart contract vulnerabilities
- Digital signature vulnerabilities. Eg. ECC (elliptic curve cryptography) assymetric cryptography which is used by bitcoin. ECC does not have the randomness required which may compromise private key of user. To generate a digital signature, a random value must be used for the private key.
- Hash function function vulnerabilities - SHA256 is vulnerable to preimage and collision attacks
- Mining Malware - Launch malware on local device or computer to use victim's computer hardware resources to mine block (blockchain).
- Software's flaws - Coding related, runtime, concurrency hard fork flaws. E.g. in 2014 during software upgrade, Blockchain.info (hybrid wallet provider) made an error when users create a new key pair - the inputs were not appropriately random which allows an attacker to access public address to compromise the private keys of users.
- User's Address Vulnerabilities - identity fraud. Attacker use MITM attack to change the target bitcoin address during transactions
- 51% Attack - Gaining 51% control of total coins (or hashing power) in the network may allow an attacker to exploit this vulnerability to monitor the entire blockchain network. The attack could potentially inject, manipulate transactions or steal users assets.
- Alternative History Attack - Atttacker send to merchant transaction that pays. While also privately mining an alternate blockchain fork (double spending) transaction. If the attacker happen to find More blocks (while waiting) he releases the previous fork to regain his coins. Repeating this to try playing catchup wit the network.
- Finney attack - Doublespending attack that is like a race condition attack. E.g. Attacker transfers from A to B (both address he owns). He generates a block but dont broadcast it, but when he makes a payment to C with his address A. When the goods is transfered, he then broadcasts his block and the transaction takes precedence such as mention earlier A pays to B (own money to his pocket) but yet he receives the goods he didnt pay for (from C)
- Race Attack - Based on PoW. Attacker makes 2 competing transaction at the exact same time.
- Vector 76 attack - Attack idenitified by a user called Vector76 which is based on Double Spending attacks. One-confirmation attack, that makes a transaction with only 1 confirmation can still be reversed. In a successful attack, the attacker will 'sacrifice' one block by not broadcasting it, but instead relay it only to the attacked node. After that, the attacker initiates a transactions that makes a legal deposit into the target adn mines it to the stack.
- Block WithHolding Attack - Withhold block to decline the estimated revenue of pool. Aim of attack is to cause mining pool profitability to deline. This is typically possible via the pool administrator who cheats the entire pool.
- Bribery Attack - bribing miners using the following 3 types of bribing techniques: (1) out-of-band payment, owner of services is paid directly by attacker to mine the blocks of the attacker. (2) Attacker builds a pool in the negative-fee mining pool by awarding the higher return. (3) Attacker tries to bribe the blockchain itself using in-band payment by making a fork, involves free bribe money to any miner who endorses the fork of the attacker.
- Pool Hopping Attack - Based on appeal rate, attacker mines if the rate is high, otherwise, attacker leaves the pool. By gathering intel of the amount of submitted shares in the target, the attacker can maximize full profits and chose seperate pool to mine.
- Block Discarding Attack - Attacker must first possess sufficient number of network connection relative to the "honest" nodes. Idea is to improve network dominance by quickly publishes his own block in order to discard blocks of "honest" blocks.
- Selfish Mining Attack - Group of attacker conspires to build a mining pool against "honest" miners. Eg. miner withholds a "solution" for a block he mined and continue working on the next "problem" while his peers are still solving the previous block. If lucky, he can find 2 blocks in a row before anyone else does.
- Fork-After-Withholding Attack - (FAW) attack is a combination of Block WithHolding attack + Selfish mining attack.
- Partition Attack - Attacker isolates group of nodes from rest of the bitcoin blockchain network to break network into disjointed parts. Attacker spoof most of the isolated nodes to redirect the traffic to attacker controlled IP addresses. Attacker can drop packets etc.
- Delay Attack - Create delay in block publishing by modifying the content of individual messages (if lack of integrity and encryption checks)
- Distributed Denial of Service Attack (DDoS) - These attacks have caused companies such as BitQuick and CoinWallet to shutdown within few months of beginning operations. This is one of the most popular and inexpensive attacks.
- Sybil Attack - Attacker setup fake assistant nodes and aims to reveal part of the blockchain network. Goal of attack is that attacker can feed misleading data to victims. This could typically be eploited by attacker disabling the functionality of the concensus algorithm and trigger a possible double-spending attack.
- Transaction Malleability Attack - Modify TXID (transaction ID) without revoking the transaction. This is to trick victim into thinking that the transaction failed. eg. Attacker withdraws from an exchange, then with another TXID, republishes the same transaction (one of them appears on the network). But due to the delay, rather than the initial withdrawal, it is likely that the changed transaction will win. The currency exchange will not find the original transaction on the network, and assume that the exchange only depends on TXID. The attacker can continously make withdrawals.
Ethereum virtual machine (EVM) is a bytecode running virtual machine that product of compiling smart contracts source code. GAS is consumed for each process in the EVM and reflects the execution expense of the code.
| Vulnerability Name | Reason |
|---|---|
| Ether lost in transit | Anything sent to an address that is not associated with a user will be lost forever. There is no way to check if the address is orphan or not |
| Immutable bugs | Published smart contracts are immutable against any alteration |
| Stack size limit | Call stack limitation can be leveraged by attackers |
Solidity is ethereum's high level programming language. In smart contract source codes, there are 6 documented vulnerabilities that are already exploited:
| Vulnerability Name | Reason |
|---|---|
| Calls to unknown | Fallback function is invoked when calling a function that don't exist |
| Exception disorder | Anomaly in exceptions handling |
| Gasless send | Invoking the out-of-gas exception |
| Keeping secrets | Compromise a private field in the smart contract |
| Reentrancy | Reenter a non-recursive function before its termination. E.g. 2016 DAO attack |
| Type casts | No exception is thrown when caller made an error |
DAG protocol is an alternative to standard blockchain or known as distributed ledger technology.
- Scalable
- Lower user costs
- Suited for high volume transactions, the larger the number of transactions, the earlier they are validated by a DAG
- DAGs eliminates use of miners which means lower energy usage
- Decrease in transaction volume render DAGs vulnerable to attacks
- replication of data accross nodes is difficult (to solve)
- DAGs employ a 'co-ordinator' to avoid malicious attacks on attacks serving as a centralized, voluntary and temporary alternate consensus mechanism :question: Hmm wouldnt that not be de-centralized anymore???












