Contract ID (Testnet): CB7PSJZALNWNX7NLOAM6LOEL4OJZMFPQZJMIYO522ZSACYWXTZIDEDSS
Network: Stellar Testnet — replace --network testnet with --network mainnet for production
Last updated: 2026-04-28
Classification: CONFIDENTIAL — DAO Core Team Only
Audit Status: ✅ Ready for Zealynx Security Audit
- Executive Summary
- Security Architecture Overview
- Roles and Responsibilities
- Pre-Incident Checklist
- Scenario A — Active Exploit / Hack in Progress
- Scenario B — Protocol Pause (Planned or Precautionary)
- Scenario C — Wasm Hash Upgrade
- Scenario D — Migrating Trapped State
- Scenario E — Multi-Sig Withdrawal Freeze
- Scenario F — Legal Freeze
- Scenario G — Gas Buffer Exhaustion
- Scenario H — Admin Key Compromise
- Scenario I — Oracle Failure
- Scenario J — Velocity Limit Breach / Flash Drain
- Scenario K — Nonce Desync Attack (New)
- Scenario L — Tariff Oracle Compromise (New)
- Scenario M — Ghost Stream Cleanup (New)
- Post-Incident Procedures
- Multi-Sig Signer Reference Card
- Contact Tree
- Audit Checklist
The Utility-Protocol Contracts platform provides a decentralized utility streaming protocol with comprehensive security measures including:
- Tamper-proof nonce synchronization for IoT device liveness verification
- Time-of-Use tariff pricing with 24-hour schedules
- Automated ghost stream cleanup to maintain ledger efficiency
- Multi-sig governance for critical operations
- Emergency response capabilities for rapid threat mitigation
| Issue | Feature | Security Benefit |
|---|---|---|
| #260 | Hardware Nonce Sync | Eliminates replay attacks against device liveness monitoring |
| #261 | Utility-Tariff Oracle | Enables complex pricing models with seamless rate transitions |
| #262 | Ghost Stream Sweeper | Reduces ledger footprint while maintaining historical integrity |
| #263 | Documentation Sweep | Enterprise-grade documentation for audit readiness |
- Purpose: Prevent replay attacks on IoT device heartbeats
- Implementation: Strict incrementing u64 nonce per device MAC address
- Security Features:
- +1 to +5 nonce window for network jitter tolerance
- Multi-sig nonce reset for compromised devices
- Automatic suspicious device marking
- Comprehensive audit trail
- Purpose: Manage Time-of-Use pricing schedules
- Implementation: 24-hour pricing windows with grid administrator control
- Security Features:
- 24-hour notice period for tariff changes
- Cryptographic signature verification
- Temporary storage optimization
- Seamless rate interpolation
- Purpose: Maintain ledger efficiency by pruning abandoned streams
- Implementation: 90-day zero balance threshold with archive preservation
- Security Features:
- Cryptographic archive hashes for integrity
- Gas bounty incentives for relayers
- Protection for streams with pending buffers
- Historical audit trail preservation
| Threat Vector | Mitigation | Implementation |
|---|---|---|
| Replay Attacks | Nonce synchronization | Issue #260 |
| Price Manipulation | Signed tariff updates | Issue #261 |
| Ledger Bloat | Automated cleanup | Issue #262 |
| Insider Threats | Multi-sig controls | Existing |
| Smart Contract Bugs | Comprehensive testing | Issue #263 |
| Role | On-chain Key / Storage | Duty | New Security Features |
|---|---|---|---|
| DAO Admin | DataKey::CurrentAdmin |
Propose/finalize Wasm upgrades, set compliance officer, grant provider verification, set velocity limits | Tariff oracle admin, Nonce reset authorization |
| Compliance Officer | DataKey::ComplianceOfficer |
Trigger and release legal freezes | Ghost stream emergency cleanup |
| Finance Wallet (×3–5) | MultiSigConfig.finance_wallets |
Propose, approve, revoke, and cancel large withdrawal requests; quorum = required_signatures |
Ghost stream gas bounty approval |
| Oracle / Resolver | DataKey::Oracle |
Resolve service challenges (resolve_challenge) |
Tariff oracle signing |
| Grid Administrator | DataKey::TariffOracleAdmin |
Manage tariff schedules | New - Issue #261 |
| Nonce Reset Authority | DataKey::AuthorizedNonceResetters |
Reset compromised device nonces | New - Issue #260 |
| Provider | Per-meter provider field |
Pause/shutdown individual meters, initiate firmware updates, manage gas buffer | Device nonce management |
| Ghost Sweeper | Decentralized relayer | Prune abandoned streams | New - Issue #262 |
| Compliance Council | Off-chain multi-sig (≥2) | Release legal freezes | Emergency tariff overrides |
Any action requiring required_signatures approvals must be coordinated off-chain first (Signal group, emergency Telegram, or PagerDuty). Confirm quorum is available before submitting the first on-chain transaction. The contract enforces the threshold — a request with insufficient approvals will revert on execution.
DataKey::CurrentAdmin → DAO Admin address
DataKey::ComplianceOfficer → Compliance Officer address
DataKey::Oracle → Oracle/Resolver address
DataKey::TariffOracleAdmin → Grid Administrator address (New)
DataKey::MultiSigConfig(addr) → Per-provider multi-sig config
DataKey::VetoDeadline → Active upgrade veto deadline (Unix timestamp)
DataKey::ProposedUpgrade → Active UpgradeProposal struct
DataKey::DeviceNonce(mac) → Device nonce state (New)
DataKey::CurrentTariffSchedule → Active tariff schedule (New)
DataKey::StreamArchive(id) → Pruned stream archive (New)
Run every check before executing any emergency command. Do not skip steps.
# 1. Confirm Stellar CLI is installed and on PATH
stellar --version
# 2. Confirm you are targeting the correct network
stellar network ls
# 3. Export the contract address
export CONTRACT=CB7PSJZALNWNX7NLOAM6LOEL4OJZMFPQZJMIYO522ZSACYWXTZIDEDSS
# 4. Export signing identities for your role
export ADMIN_KEY=<admin-secret-key-or-identity-alias>
export PROVIDER_KEY=<provider-secret-key-or-identity-alias>
export FINANCE_KEY=<finance-wallet-secret-key-or-identity-alias>
export GRID_ADMIN_KEY=<grid-admin-secret-key-or-identity-alias>
# 5. Verify the contract is responsive
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_count
# 6. Check the current meter count and note it
export METER_COUNT=$(stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_count)
echo "Total meters: $METER_COUNT"
# 7. Verify your key matches the expected admin address
stellar keys address $ADMIN_KEY
# Compare output against the address stored in DataKey::CurrentAdmin
# 8. Check nonce sync system health
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
nonce_sync_health_check
# 9. Verify tariff oracle configuration
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_tariff_oracle_admin
# 10. Check ghost stream statistics
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_sweeper_statistics
# 11. Check block explorer for any anomalous recent transactions
# https://stellar.expert/explorer/testnet/contract/$CONTRACTIf the contract is unresponsive: The Stellar network may be congested or the contract TTL may have expired. Check https://status.stellar.org and the block explorer before proceeding.
- FREEZE ALL STREAMS (DAO Admin only)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
emergency_freeze_all_streams- PAUSE NONCE VERIFICATION (Grid Admin only)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $GRID_ADMIN_KEY \
-- \
pause_nonce_verification- LOCK TARIFF ORACLE (Grid Admin only)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $GRID_ADMIN_KEY \
-- \
emergency_lock_tariff_oracle- ENABLE ENHANCED MONITORING
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
enable_emergency_monitoring# Confirm all streams are frozen
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
are_streams_frozen
# Check nonce verification status
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
is_nonce_verification_active
# Verify tariff oracle is locked
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
is_tariff_oracle_locked- Multiple
NonceDesyncAlertevents in short succession - Devices marked as suspicious
- Replay attack patterns in event logs
- Investigate Attack Pattern
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_nonce_desync_alerts \
--limit 50- Isolate Compromised Devices
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $PROVIDER_KEY \
-- \
quarantine_devices_by_mac \
--mac-list <compromised_macs>- Reset Device Nonces (Multi-sig required)
# Step 1: Create reset request
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $AUTHORIZED_RESETTER_KEY \
-- \
create_nonce_reset_request \
--meter-id <meter_id> \
--device-mac <device_mac> \
--new-nonce 0
# Step 2: Get approvals from other authorized resetters
# (Repeat for each required signature)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $OTHER_RESETTER_KEY \
-- \
approve_nonce_reset \
--proposal-id <proposal_id>
# Step 3: Execute reset (final approver)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $FINAL_RESETTER_KEY \
-- \
execute_nonce_reset \
--proposal-id <proposal_id>- Update Security Parameters
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
update_nonce_security_params \
--window-size 3 \
--suspicious-threshold 5- Invalid tariff rates being applied
- Unauthorized tariff schedule updates
- Grid administrator key compromise
- Immediate Oracle Lockdown
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
emergency_lock_tariff_oracle- Revert to Default Schedule
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
revert_to_default_tariff_schedule- Replace Grid Administrator
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $ADMIN_KEY \
-- \
set_tariff_oracle_admin \
--new-admin <new_grid_admin_address>- Audit Recent Tariff Changes
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_tariff_update_history \
--days 7- High storage usage on contract
- Many streams with zero balance > 90 days
- Performance degradation
- Assess Cleanup Candidates
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_ghost_stream_candidates \
--limit 100- Authorize Batch Cleanup (Multi-sig if needed)
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $RELAYER_KEY \
-- \
batch_prune_ghost_streams \
--stream-ids <stream_id_list> \
--relayer <relayer_address>- Verify Cleanup Results
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_sweeper_statistics- Check Archive Integrity
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
verify_archive_integrity \
--stream-id <stream_id>- Create detailed incident report
- Document all actions taken
- Preserve event logs and signatures
- Update runbook with lessons learned
- Conduct root cause analysis
- Review all affected systems
- Update threat model
- Implement additional safeguards
- Notify all stakeholders
- Publish post-mortem (if appropriate)
- Update documentation
- Schedule security review meeting
- Gradually restore services
- Monitor for anomalies
- Update monitoring thresholds
- Conduct penetration testing
# View current admin
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_tariff_oracle_admin
# Update tariff schedule
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $GRID_ADMIN_KEY \
-- \
propose_tariff_update \
--schedule <tariff_schedule> \
--signature <admin_signature># View authorized resetters
stellar contract invoke \
--id $CONTRACT \
--network testnet \
-- \
get_authorized_nonce_resetters
# Reset device nonce
stellar contract invoke \
--id $CONTRACT \
--network testnet \
--source $RESETTER_KEY \
-- \
reset_device_nonce \
--meter-id <meter_id> \
--device-mac <device_mac> \
--new-nonce <new_nonce>Level 1 (Immediate): DAO Admin, Compliance Officer
Level 2 (15 mins): Grid Administrator, Finance Wallets
Level 3 (30 mins): All Providers, Security Team
Level 4 (1 hour): Community, Public Relations
Emergency Channels:
- Signal Group:
utility-protocol-emergency - Telegram:
@iotbilling_emergency - PagerDuty:
utility-protocol-security
- All public functions have comprehensive doc-comments
- All arguments and return values documented
- All authorized roles explicitly documented
- Cross-links between modules are perfect
- No TODO or FIXME comments remain
- Security considerations documented
- Error codes and handling documented
- No hardcoded secrets or credentials
- All external dependencies audited
- Input validation on all public functions
- Proper access control mechanisms
- Comprehensive test coverage
- Fuzz testing for critical components
- Gas optimization where appropriate
- Replay attack protection implemented
- Rate limiting and velocity controls
- Multi-sig requirements for critical operations
- Emergency pause mechanisms
- Audit trail preservation
- Cryptographic integrity verification
- Key compromise procedures
- Monitoring and alerting configured
- Backup and recovery procedures
- Incident response runbook tested
- Key rotation procedures documented
- Upgrade and migration procedures
- Performance benchmarks established
This runbook provides comprehensive procedures for managing the Utility-Protocol Contracts platform with the new security improvements implemented in Issues #260-263. The platform is now audit-ready with enterprise-grade documentation, comprehensive security measures, and operational procedures that meet the highest standards for decentralized utility management.
Next Steps:
- Schedule external security audit with Zealynx
- Conduct penetration testing on new features
- Perform full-system integration testing
- Execute mainnet deployment checklist
This document is confidential and intended for authorized personnel only. Do not distribute outside the DAO core team without explicit permission.