Skip to main content

Security & Best Practices

🛡️ Security Overview

The Innovation City Digital License contract implements business-grade security with multiple layers of protection, role-based access control, and comprehensive audit trails. This document outlines security measures, access management, and best practices for secure deployment and operation.

🔐 Security Architecture

Multi-Layer Security Model

┌─────────────────────────────────────────────────────────────┐
│ SECURITY LAYERS │
├─────────────────────────────────────────────────────────────┤
│ Layer 1: Soulbound Enforcement (ERC-5192) │
│ Layer 2: Role-Based Access Control (RBAC) │
│ Layer 3: Upgradeable Security (UUPS) │
│ Layer 4: Emergency Controls (Pausable) │
│ Layer 5: Audit Trail (Events) │
└─────────────────────────────────────────────────────────────┘

1. Soulbound Security (ERC-5192)

Protection Mechanisms:

// Block all transfers after minting
function _update(address to, uint256 tokenId, address auth) internal override returns (address) {
if (_ownerOf(tokenId) != address(0)) {
if (to == address(0)) revert SoulboundBurn();
revert SoulboundTransfer();
}
return super._update(to, tokenId, auth);
}

// Block all approvals
function approve(address, uint256) public pure override {
revert SoulboundTransfer();
}

function setApprovalForAll(address, bool) public pure override {
revert SoulboundTransfer();
}

Security Benefits:

  • Transfer Prevention: Tokens cannot be moved once minted
  • Approval Blocking: No delegation of control possible
  • Burn Prevention: Tokens cannot be destroyed
  • Marketplace Protection: Prevents listing on NFT marketplaces

2. Role-Based Access Control (RBAC)

Role Hierarchy:

DEFAULT_ADMIN_ROLE (0x0000...0000)
├── MINTER_ROLE (0x9f2df0fed2c77648de5860a4cc508cd0818c85b8b8a1ab4ceeef8d981c8956a6)
├── PAUSER_ROLE (0x65d7a28e3265b37a6474929f336521b332c1681b933f6cb9f3376673440d862a)
└── UPGRADER_ROLE (0x189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e3)

Permission Matrix:

FunctionAdminMinterPauserUpgrader
safeMint()
setLicenseStatus()
pause() / unpause()
_authorizeUpgrade()
grantRole() / revokeRole()

3. Upgrade Security (UUPS)

Controlled Upgrades:

function _authorizeUpgrade(address newImplementation) internal override onlyRole(UPGRADER_ROLE) {}

Security Features:

  • Role-Protected: Only UPGRADER_ROLE can upgrade
  • Implementation Validation: New implementation must be valid
  • State Preservation: All data maintained during upgrades
  • Rollback Capability: Can revert to previous implementation

4. Emergency Controls

Pausable Functionality:

function pause() external onlyRole(PAUSER_ROLE) {
_pause();
}

function unpause() external onlyRole(PAUSER_ROLE) {
_unpause();
}

Emergency Scenarios:

  • Security Breach: Immediate system shutdown
  • Critical Bug: Prevent further damage
  • Regulatory Compliance: Emergency system halt
  • Maintenance: Planned system downtime

🔑 Access Management

Role Assignment Best Practices

1. Multi-Signature Wallets

// Assign roles to multi-sig wallets for enhanced security
contract.grantRole(MINTER_ROLE, multiSigWallet);
contract.grantRole(PAUSER_ROLE, emergencyMultiSig);
contract.grantRole(UPGRADER_ROLE, upgradeMultiSig);

Benefits:

  • Distributed Control: No single point of failure
  • Consensus Required: Multiple approvals needed
  • Audit Trail: All operations logged
  • Risk Mitigation: Reduces insider threat

2. Role Separation

// Separate roles for different functions
contract.grantRole(MINTER_ROLE, licenseIssuanceSystem);
contract.grantRole(PAUSER_ROLE, securityTeam);
contract.grantRole(UPGRADER_ROLE, developmentTeam);

Security Benefits:

  • Principle of Least Privilege: Minimal required permissions
  • Operational Separation: Different teams for different functions
  • Reduced Risk: Limited blast radius for compromised roles
  • Audit Clarity: Clear responsibility boundaries

Role Management Procedures

1. Initial Deployment

// Deploy with secure initial roles
function initialize(
address admin, // Multi-sig wallet
address pauser, // Security team
address minter, // License system
address upgrader // Development team
) public initializer {
// Role assignment with proper validation
}

2. Role Auditing

// Regular role audits
function auditRoles() external view returns (RoleAudit memory) {
return RoleAudit({
admin: getRoleMembers(DEFAULT_ADMIN_ROLE),
minter: getRoleMembers(MINTER_ROLE),
pauser: getRoleMembers(PAUSER_ROLE),
upgrader: getRoleMembers(UPGRADER_ROLE)
});
}

3. Role Revocation

// Emergency role revocation
function emergencyRevokeRole(bytes32 role, address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
_revokeRole(role, account);
emit RoleRevoked(role, account, msg.sender);
}

🚨 Security Best Practices

1. Deployment Security

Pre-Deployment Checklist

  • Code Audit: Professional security audit completed
  • Test Coverage: Comprehensive test suite with >90% coverage
  • Role Assignment: Secure initial role configuration
  • Multi-sig Setup: Critical roles assigned to multi-sig wallets

4. Monitoring and Alerting

Event Monitoring

// Comprehensive event logging
event SecurityEvent(
string eventType,
address indexed actor,
bytes32 indexed role,
uint256 timestamp,
string details
);

function logSecurityEvent(string memory eventType, string memory details) internal {
emit SecurityEvent(eventType, msg.sender, 0, block.timestamp, details);
}

Alert System

Implemented on the backend with Sentry:

  • Real-time Monitoring: Track all contract events and transactions
  • Error Tracking: Monitor failed operations and security events
  • Performance Monitoring: Track gas usage and transaction success rates
  • Alert Notifications: Automatic alerts for suspicious activity

📋 Security Checklist

Pre-Deployment

  • Code Audit: Professional security audit completed
  • Test Coverage: >90% test coverage achieved
  • Role Assignment: Secure role configuration
  • Multi-sig Setup: Critical roles assigned to multi-sig wallets

Post-Deployment

  • Monitoring Setup: Real-time monitoring implemented
  • Alert System: Security alerts configured

Ongoing Security

  • Contract Audit: Monthly security reviews
  • Quarterly Assessments: Quarterly security assessments

This security guide provides comprehensive protection for the Innovation City Digital License contract, ensuring business-grade security while maintaining operational efficiency and regulatory compliance.