Security Considerations

⚠️ Current Security Status (Hackathon Phase)

Important Warning: Gelap is currently in the Alpha / Hackathon phase.

While the protocol incorporates advanced privacy and security features, the smart contracts and SP1 circuits have not yet undergone a formal third-party security audit.

  • Current Status: Internal Self-Audit & Testing.

  • Audit Roadmap: A comprehensive professional audit is scheduled for the next phase of development (Post-Hackathon).

  • Recommendation: Please treat the current deployment as experimental software. Do not deposit funds you cannot afford to lose.


Overview

This document outlines security considerations, best practices, and potential vulnerabilities for the Gelap shielded pool system.

Threat Model

Assets at Risk

  • User Funds: ERC20 tokens deposited in the shielded pool

  • Privacy: Transaction amounts and participant identities

  • System Integrity: Merkle tree state and nullifier tracking

Threat Actors

  • Malicious Users: Attempting double-spends or invalid transactions

  • Front-runners: Trying to manipulate withdrawal transactions

  • Contract Exploiters: Looking for smart contract vulnerabilities

  • Privacy Attackers: Attempting to deanonymize transactions

Security Features

✅ Implemented Protections

1. Double-Spend Prevention

Mechanism: Nullifier tracking

Protection:

  • Each note can only be spent once

  • Nullifiers are checked before state updates

  • Reverts if nullifier already used

2. Front-Running Protection

Mechanism: Receiver validation in withdrawals

Protection:

  • Receiver address is part of the ZK proof

  • Cannot redirect withdrawal to different address

  • Prevents MEV attacks on withdrawals

3. Invalid State Transition Prevention

Mechanism: SP1 ZK proof verification

Protection:

  • All state transitions must have valid proof

  • Ensures balance conservation

  • Validates Merkle tree updates

4. Input Validation

Mechanism: Require statements

Protection:

  • Prevents zero-address exploits

  • Ensures valid amounts

  • Validates all inputs

Potential Vulnerabilities

⚠️ Areas Requiring Attention

1. SP1 Program Correctness

Risk: If the SP1 program has bugs, invalid proofs could be generated

Mitigation:

  • Thorough testing of SP1 program

  • Formal verification of critical logic

  • Security audit of prover code

  • Use well-tested cryptographic libraries

2. Merkle Tree Overflow

Risk: Tree limited to 2^32 leaves

Current State:

Mitigation:

  • Monitor tree growth

  • Plan migration strategy before limit

  • Consider multiple trees or rollup integration

3. ERC20 Token Compatibility

Risk: Non-standard ERC20 tokens may behave unexpectedly

Examples:

  • Fee-on-transfer tokens

  • Rebasing tokens

  • Tokens with hooks

Mitigation:

  • Whitelist supported tokens

  • Document incompatible token types

  • Add token validation checks

4. Encrypted Memo Privacy

Risk: Encrypted memos could leak information if not properly encrypted

Mitigation:

  • Use strong encryption (AES-256-GCM)

  • Unique nonces for each memo

  • Document encryption requirements

  • Consider removing memos if not needed

5. Verifier Contract Trust

Risk: Malicious or buggy SP1 verifier could accept invalid proofs

Mitigation:

  • Use official SP1 verifier deployments

  • Verify verifier contract source code

  • Monitor for verifier upgrades

  • Consider multi-verifier approach

Best Practices

For Users

Key Management

  • Use Hardware Wallets: Store private keys securely

  • Backup Notes: Save all note data (commitment, blinding, amount)

  • Never Reuse Blinding Factors: Always use fresh randomness

  • Secure Note Storage: Encrypt local note database

Transaction Safety

  • Verify Addresses: Double-check receiver addresses

  • Test Small Amounts: Start with small transactions

  • Monitor Events: Track your deposits and withdrawals

  • Use Trusted Provers: Only use verified prover services

For Developers

Smart Contract Development

  • Follow Checks-Effects-Interactions: Prevent reentrancy

  • Use SafeERC20: Handle token transfers safely

  • Validate All Inputs: Never trust user input

  • Emit Events: Enable off-chain tracking

  • Add Access Control: If admin functions needed

Prover Development

  • Validate Inputs: Check all prover inputs

  • Use Constant-Time Operations: Prevent timing attacks

  • Secure Randomness: Use cryptographically secure RNG

  • Test Edge Cases: Boundary conditions and overflows

  • Audit Dependencies: Review all libraries used

For Operators

Deployment

  • Audit Before Mainnet: Professional security audit required

  • Test on Testnet: Extensive testing before production

  • Verify Contracts: Ensure source code matches deployment

  • Monitor Deployments: Track contract activity

  • Emergency Plan: Have incident response ready

Monitoring

  • Track Nullifiers: Monitor for unusual patterns

  • Watch Gas Costs: Detect potential DoS attacks

  • Monitor Tree Growth: Plan for capacity limits

  • Alert on Anomalies: Set up automated alerts

  • Regular Audits: Periodic security reviews

Known Limitations

1. No Upgradability

Current State: Contract is not upgradeable

Implications:

  • Cannot fix bugs without migration

  • Cannot add features post-deployment

  • State migration required for upgrades

Consideration: Implement proxy pattern for future versions

2. No Emergency Pause

Current State: No pause mechanism

Implications:

  • Cannot stop operations if bug found

  • Users could lose funds before fix

Consideration: Add Pausable pattern for critical functions

3. No Access Control

Current State: All functions are permissionless

Implications:

  • Cannot restrict malicious actors

  • No admin controls

Consideration: This is by design for decentralization, but consider adding optional admin functions for emergency situations

4. Linear Nullifier Checking

Current State: Gas cost increases with number of nullifiers

Implications:

  • Expensive for transactions with many inputs

  • Potential DoS vector

Consideration: Optimize with batch verification or alternative data structures

Privacy Considerations

What is Private

  • ✅ Transaction amounts

  • ✅ Sender identity

  • ✅ Receiver identity

  • ✅ Transaction graph

What is Public

  • ❌ Deposit events (commitment visible)

  • ❌ Withdrawal events (receiver, amount visible)

  • ❌ Total value locked

  • ❌ Number of transactions

  • ❌ Merkle root changes

Privacy Leaks

Timing Analysis

Risk: Transaction timing could reveal patterns

Mitigation:

  • Use random delays

  • Batch transactions

  • Mix with other users' transactions

Amount Correlation

Risk: Unique amounts could link deposits to withdrawals

Mitigation:

  • Use common denominations

  • Split large amounts

  • Add random change outputs

Network Analysis

Risk: IP addresses could deanonymize users

Mitigation:

  • Use Tor or VPN

  • Run own prover locally

  • Use privacy-focused RPC endpoints

Audit Recommendations

Scope

  • Smart contract code

  • SP1 program logic

  • Cryptographic implementations

  • Merkle tree operations

  • Integration points

Focus Areas

  1. Nullifier Generation: Ensure uniqueness and unlinkability

  2. Merkle Proofs: Validate correctness

  3. Balance Conservation: Verify no token creation

  4. Access Control: Check permission boundaries

  5. Reentrancy: Test all external calls

Audit Checklist

Incident Response

If Vulnerability Found

  1. Assess Severity

    • Critical: Funds at risk

    • High: Privacy breach possible

    • Medium: DoS or degradation

    • Low: Minor issues

  2. Immediate Actions

    • Pause operations (if possible)

    • Notify users via official channels

    • Assemble response team

    • Document the issue

  3. Remediation

    • Develop fix

    • Test thoroughly

    • Deploy to testnet

    • Audit the fix

    • Deploy to mainnet

    • Migrate state if needed

  4. Post-Incident

    • Post-mortem analysis

    • Update documentation

    • Improve testing

    • Compensate affected users if applicable

Security Resources

Tools

  • Slither: Static analyzer

  • Mythril: Security analysis

  • Echidna: Fuzzing tool

  • Manticore: Symbolic execution

  • Foundry: Testing framework

References

Responsible Disclosure

If you discover a security vulnerability:

  1. Do NOT disclose publicly

  2. Email: security@gelap.xyz

  3. Include:

    • Description of vulnerability

    • Steps to reproduce

    • Potential impact

    • Suggested fix (if any)

  4. Wait for response before disclosure

  5. Coordinate disclosure timeline

Bug Bounty

Consider launching a bug bounty program:

  • Platform: Immunefi or HackerOne

  • Scope: Smart contracts and prover

  • Rewards: Based on severity

  • Critical: Up to $100,000

  • High: Up to $50,000

  • Medium: Up to $10,000

  • Low: Up to $1,000

Conclusion

Security is an ongoing process. Regular audits, monitoring, and updates are essential for maintaining a secure system. Always prioritize user safety and privacy.

Last updated