Web3Sentry is a modular Python-based security detection system for Web3lancer. It provides custom security detectors that can be easily deployed to any server and connect to an API.
- Multisig Protection Custom Detector: Enhances security for multisig wallets by detecting unusual signing patterns or unauthorized attempts
- Approvals Custom Detector: Identifies malicious/risky/deceptive approvals that could give attackers access to user assets
- Modular Architecture: Easily extensible with additional detectors
- API Integration: Simple integration with Web3lancer platform components
The system consists of:
- Base Detector: Abstract class defining the detector interface
- Specialized Detectors: Implementation of specific security detectors
- Detector Service: Manages and coordinates detector operations
- Integration Points: Connectors to Web3lancer's escrow and voting systems
# Clone the repository
git clone https://github.com/yourusername/web3lancer.git
# Navigate to the project directory
cd web3lancer
# Install dependencies
pip install -r requirements.txt
from web3lancer.escrow.escrow_security import EscrowSecurityService
# Initialize the service
escrow_security = EscrowSecurityService()
# Verify an escrow creation
escrow_data = {
"client_address": "0x123...",
"escrow_contract_address": "0xabc...",
"payment_amount": "1000000000000000000", # 1 ETH
"token_address": "0xdef...",
"client_id": "client-1234",
"is_multisig": True,
"authorized_signers": ["0x123...", "0x456...", "0x789..."],
"required_signatures": 2
}
results = await escrow_security.verify_escrow_creation(escrow_data)
print(f"Security assessment: {results['overall_risk']}")
from web3lancer.voting.voting_security import VotingSecurityService
# Initialize the service
voting_security = VotingSecurityService()
# Verify a proposal creation
proposal_data = {
"creator_address": "0x123...",
"voting_contract_address": "0xabc...",
"creator_id": "user-1234",
"is_multisig_governance": True,
"authorized_signers": ["0x123...", "0x456...", "0x789..."],
"required_signatures": 2
}
results = await voting_security.verify_proposal_creation(proposal_data)
print(f"Security assessment: {results['overall_risk']}")
To create a new detector:
- Create a new class that inherits from
BaseDetector
- Implement the required methods:
analyze()
andget_detector_info()
- Register your detector with the
DetectorService
from web3sentry.detectors.base_detector import BaseDetector
class MyCustomDetector(BaseDetector):
def __init__(self):
super().__init__(
name="My Custom Detector",
description="Detects specific security issues"
)
async def analyze(self, transaction_data):
# Implement your detection logic here
return {
"risk_level": "safe",
"details": "No issues detected",
"triggers": []
}
def get_detector_info(self):
base_info = super().get_detector_info()
base_info.update({
"category": "custom",
# Add additional metadata
})
return base_info
Run the tests:
python -m unittest discover
This project was designed for the Venn Network Wallet Security Hackathon, focusing on:
- Multisig Protection Custom Detector
- Approvals Custom Detector
Both detectors follow the guidelines provided by the Venn Network, and can plug into Venn's infrastructure as core contributors in their decentralized security network.