This week, I focused on simulating a Sybil attack on the network to verify the effectiveness of the rated list. The objective is to demonstrate how fake identities (Sybil nodes) can exploit the system by manipulating peer relationships and the scoring process.
## Sybil attack launch
1. Inserting Sybil Nodes:
First, I created Sybil nodes and add them to the RatedListData.
2. Manipulating Peer Relationships:
Sybil nodes are injected into the parent-child relationships of legitimate nodes.
3. Artificially Increasing Scores:
The Sybil nodes will repeatedly contact and reply to each other, inflating their descendant_score.
Here's the code that simulates these steps:
### Step 1:
param rated_list_data: The rated list data structure.
param num_sybil_nodes: Number of Sybil nodes to create.
param target_node_id: The legitimate node to which the Sybil nodes will be attached.
```
def add_sybil_nodes(rated_list_data: RatedListData, num_sybil_nodes: int, target_node_id: NodeId):
for i in range(num_sybil_nodes):
sybil_node_id = NodeId(b"sybil" + bytes([i])) # Create a unique ID for each Sybil node
sybil_node_record = create_empty_node_record(sybil_node_id)
# Link the Sybil node to the target legitimate node
sybil_node_record.parents.append(target_node_id)
rated_list_data.nodes[target_node_id].children.append(sybil_node_id)
# Add the Sybil node to the network
rated_list_data.nodes[sybil_node_id] = sybil_node_record
```
### Step 2:
:param rated_list_data: The rated list data structure.
:param sybil_node_ids: List of Sybil node IDs to attach.
:param target_node_id: The legitimate node being targeted.
```
def establish_sybil_peer_connections(rated_list_data: RatedListData, sybil_node_ids: List[NodeId], target_node_id: NodeId):
# Establishes parent-child relationships between Sybil nodes and the target legitimate node.
for sybil_node_id in sybil_node_ids:
rated_list_data.nodes[sybil_node_id].parents.append(target_node_id)
rated_list_data.nodes[target_node_id].children.append(sybil_node_id)
# Optionally, Sybil nodes could interact with each other to create more complex peer relationships
for other_sybil_id in sybil_node_ids:
if other_sybil_id != sybil_node_id:
rated_list_data.nodes[sybil_node_id].children.append(other_sybil_id)
rated_list_data.nodes[other_sybil_id].parents.append(sybil_node_id)
```
### Step 3:
```
def sybil_contact_interaction(rated_list_data: RatedListData, block_root: Root, sybil_node_ids: List[NodeId], sample_id: SampleId):
for sybil_node_id in sybil_node_ids:
# Sybil nodes 'contact' each other
for other_sybil_id in sybil_node_ids:
if other_sybil_id != sybil_node_id:
on_request_score_update(rated_list_data, block_root, sybil_node_id, sample_id)
on_response_score_update(rated_list_data, block_root, other_sybil_id, sample_id)
def sybil_increase_scores(rated_list_data: RatedListData, block_root: Root, sybil_node_ids: List[NodeId], sample_id: SampleId):
for sybil_node_id in sybil_node_ids:
# Sybil nodes 'contact' each other
sybil_contact_interaction(rated_list_data, block_root, sybil_node_ids, sample_id)
```
## Summary of the attack
1. Sybil Nodes Creation:
We first create several Sybil nodes and add them to the rated list system by calling add_sybil_nodes. These nodes are attached to a legitimate node (legitimate_node_id), making them look like regular participants in the network.
2. Score Inflation:
The function sybil_increase_scores simulates the Sybil nodes contacting and replying to each other, which inflates their scores in the system. The more interactions they have, the higher their scores become, making them appear more important than legitimate nodes.
3. Artificial Score Calculation:
After inflating the scores, the system will compute and print out the scores of the Sybil nodes using the compute_node_score function.
## To do list:
- Comparison of the Sybil attack with rated list and without rated list to show the effectiveness.
- Providing the theortical analysis for the security definition and quantification analysis.