CoolFace
Apppublic

diamond-in/protocol-onyx

sourceHugging Faceupdated 1y agoView on Hugging Face
0likes
App README

Enzyme Onyx Protocol - Bug Bounty Security Analysis

Bounty Status Tests

๐ŸŽฏ Quick Summary

This repository contains a comprehensive security analysis of the Enzyme Onyx Protocol as part of the Immunefi bug bounty program.

7 vulnerabilities have been identified, including:

  • โ€”โš ๏ธ 1 CRITICAL - Inflation/Donation Attack
  • โ€”โš ๏ธ 1 HIGH - Price Manipulation
  • โ€”โš ๏ธ 3 MEDIUM - Various DOS and logic issues
  • โ€”โš ๏ธ 2 LOW - Fee bypass and griefing

Estimated Total Bounty: $92,000 - $300,000


๐Ÿ“‹ Quick Links

DocumentDescription
VULNERABILITY_REPORT.mdComplete analysis of all 7 vulnerabilities
SETUP_AND_RUN.mdHow to install Foundry and run tests
test/exploits/Proof-of-Concept exploit code

๐Ÿ”ฅ Critical Findings

Vulnerability #1: Inflation/Donation Attack (CRITICAL)

Bounty Estimate: $50,000 - $200,000

An attacker can become the first depositor with 1 wei, donate large amounts to inflate share price, causing subsequent depositors to receive 0 shares due to rounding. The attacker then redeems their share, stealing victim funds.

POC: test/exploits/InflationAttack.t.sol

Impact: Direct theft of user funds


Vulnerability #2: Price Manipulation (HIGH)

Bounty Estimate: $20,000 - $50,000

Deposit and redeem requests have no slippage protection. Share price can change significantly between request and execution, allowing malicious admins or MEV bots to profit from users.

POC: test/exploits/PriceManipulation.t.sol

Impact: Temporary freezing of funds / Griefing


Vulnerability #3: Stale Rate DOS (MEDIUM)

Bounty Estimate: $10,000 - $20,000

If asset rate expires, all operations revert: deposits, redemptions, fee claims. Complete protocol lock until admin updates rates.

POC: test/exploits/StaleRateDOS.t.sol

Impact: Temporary freezing of funds


๐Ÿš€ Quick Start

1. Install Foundry

bash
curl -L https://foundry.paradigm.xyz | bash
foundryup

2. Run Tests

bash
cd protocol-onyx

# Run all exploit POCs
forge test --match-path "test/exploits/*.sol" -vvv

# Or run individually
forge test --match-contract InflationAttack -vvv
forge test --match-contract PriceManipulation -vvv
forge test --match-contract StaleRateDOS -vvv

3. Test on Forked Network

bash
# Set your RPC URL
export ETH_RPC_URL="https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY"

# Run on fork
forge test --match-path "test/exploits/*.sol" --fork-url $ETH_RPC_URL -vvv

Note: Foundry installation required. See SETUP_AND_RUN.md for detailed instructions.


๐Ÿ“Š Vulnerability Summary Table

#VulnerabilitySeverityImpactPOCEst. Bounty
1Inflation/Donation AttackCRITICALDirect theftLink$50k-$200k
2Price ManipulationHIGHFreezing/GriefingLink$20k-$50k
3Stale Rate DOSMEDIUMFreezingLink$10k-$20k
4Retroactive Fee RateMEDIUMGriefingIn Report$5k-$10k
5Fee Rounding BypassLOWTheft of yieldIn Report$1k-$5k
6Insufficient BalanceMEDIUMFreezingIn Report$5k-$10k
7No Min DurationLOWGriefingIn Report$1k-$5k

๐Ÿ“ Repository Structure

.
โ”œโ”€โ”€ README.md                           # This file
โ”œโ”€โ”€ VULNERABILITY_REPORT.md             # Detailed vulnerability analysis
โ”œโ”€โ”€ SETUP_AND_RUN.md                    # Setup and testing instructions
โ””โ”€โ”€ protocol-onyx/                      # Cloned Enzyme Onyx repository
    โ”œโ”€โ”€ src/                            # Protocol smart contracts
    โ”‚   โ”œโ”€โ”€ components/
    โ”‚   โ”‚   โ”œโ”€โ”€ fees/                   # Fee handling contracts
    โ”‚   โ”‚   โ”œโ”€โ”€ issuance/               # Deposit/redeem queues
    โ”‚   โ”‚   โ””โ”€โ”€ value/                  # Valuation contracts
    โ”‚   โ”œโ”€โ”€ shares/                     # Core Shares contract
    โ”‚   โ””โ”€โ”€ global/                     # Global state
    โ””โ”€โ”€ test/
        โ””โ”€โ”€ exploits/                   # ๐Ÿ”ด POC exploit tests
            โ”œโ”€โ”€ InflationAttack.t.sol
            โ”œโ”€โ”€ PriceManipulation.t.sol
            โ””โ”€โ”€ StaleRateDOS.t.sol

๐ŸŽฏ Affected Contracts

The following in-scope contracts contain vulnerabilities:

Critical Issues:

  • โ€”โœ… ERC7540LikeDepositQueue.sol - Inflation attack vector
  • โ€”โœ… Shares.sol - Acknowledged inflation risk
  • โ€”โœ… ValuationHandler.sol - Share price calculation

High Issues:

  • โ€”โœ… ERC7540LikeDepositQueue.sol - No slippage protection
  • โ€”โœ… ERC7540LikeRedeemQueue.sol - No slippage protection

Medium Issues:

  • โ€”โœ… ValuationHandler.sol - Stale rate DOS
  • โ€”โœ… ContinuousFlatRateManagementFeeTracker.sol - Retroactive rate
  • โ€”โœ… ERC7540LikeRedeemQueue.sol - Balance check

Low Issues:

  • โ€”โœ… FeeHandler.sol - Rounding errors

๐Ÿ”ฌ Testing Details

Test Coverage

  • โ€”3 POC files with comprehensive attack scenarios
  • โ€”10+ test functions covering different attack vectors
  • โ€”Mitigation tests showing proposed fixes
  • โ€”Console logging for clear attack visualization

Example Test Output

=== INFLATION ATTACK POC ===

Step 1: Attacker deposits 1 wei as first depositor
Attacker receives shares: 1
Total supply after: 1

Step 2: Attacker donates 1,000,000 USDC to Shares contract
Donation amount: 1000000 USDC

Step 3: Share price after donation
Total value in contract: 1000000 USDC
Total shares: 1
Price per share: 1000000 USDC per share

Step 4: Victim deposits 10,000 USDC
Victim shares ACTUAL (after Solidity rounding): 0

=== VULNERABILITY CONFIRMED ===
Victim receives 0 shares but deposits 10,000 USDC
Attacker steals victim's funds through donation attack

๐Ÿ›ก๏ธ Recommended Fixes

Fix #1: Inflation Attack

solidity
// Require minimum first deposit
uint256 MIN_SHARES = 1e6;
require(netShares >= MIN_SHARES || totalSupply() >= MIN_SHARES, "Shares too low");

Fix #2: Price Manipulation

solidity
// Add slippage protection
struct DepositRequestInfo {
    address controller;
    uint40 canCancelTime;
    uint256 assetAmount;
    uint256 maxSharePrice;  // NEW
}

require(sharePriceInValueAsset <= request.maxSharePrice, "Slippage exceeded");

Fix #3: Stale Rate DOS

solidity
// Add grace period
uint256 GRACE_PERIOD = 1 days;

if (block.timestamp >= rateInfo.expiry + GRACE_PERIOD) {
    revert RateExpired();
} else if (block.timestamp >= rateInfo.expiry) {
    emit StaleRateWarning(_asset);
}

๐Ÿ“ˆ Impact Assessment

Inflation Attack (CRITICAL)

  • โ€”Likelihood: High (easily exploitable on first deposit)
  • โ€”Impact: Critical (complete loss of user funds)
  • โ€”Affected Users: All depositors after attacker
  • โ€”Value at Risk: Unlimited

Price Manipulation (HIGH)

  • โ€”Likelihood: Medium (requires admin cooperation or MEV)
  • โ€”Impact: High (partial loss of funds)
  • โ€”Affected Users: Users with pending requests
  • โ€”Value at Risk: Depends on price swing

Stale Rate DOS (MEDIUM)

  • โ€”Likelihood: Low (admin error or unavailability)
  • โ€”Impact: Medium (temporary lock, no fund loss)
  • โ€”Affected Users: All users
  • โ€”Value at Risk: Opportunity cost

๐Ÿ”— Resources

Enzyme Onyx

  • โ€”GitHub: https://github.com/enzymefinance/protocol-onyx
  • โ€”Commit: b98576fa39213b3c8aecb8b5b104c9acaa24eff0
  • โ€”Immunefi: https://immunefi.com/bug-bounty/enzyme-onyx/

Bug Bounty Program

  • โ€”Platform: Immunefi
  • โ€”Max Bounty: $200,000
  • โ€”Scope: 12 smart contracts
  • โ€”POC Required: Yes โœ…

Development Tools

  • โ€”Foundry: https://book.getfoundry.sh/
  • โ€”Solidity: https://docs.soliditylang.org/

โš–๏ธ Responsible Disclosure

DO โœ…

  • โ€”Test on local or forked networks only
  • โ€”Report through Immunefi platform
  • โ€”Provide clear POCs and documentation
  • โ€”Suggest mitigations
  • โ€”Follow disclosure timeline

DON'T โŒ

  • โ€”Exploit on live networks
  • โ€”Share publicly before fix
  • โ€”Attempt extortion
  • โ€”Manipulate real funds
  • โ€”Test without permission

๐Ÿ“ž Contact & Support

Immunefi Submission

  1. 1.Visit: https://immunefi.com/bug-bounty/enzyme-onyx/
  2. 2.Click "Submit a Bug"
  3. 3.Provide all documentation
  4. 4.Wait for triage

Questions?

  • โ€”Immunefi Support: support@immunefi.com
  • โ€”Foundry Issues: https://github.com/foundry-rs/foundry/issues

๐Ÿ“„ License

  • โ€”Security research: Educational purposes only
  • โ€”POC code: MIT License
  • โ€”Enzyme Onyx protocol: BUSL-1.1 License

โœจ Acknowledgments

This security analysis was performed as part of the Immunefi bug bounty program. All vulnerabilities will be reported responsibly to allow the Enzyme team time to fix before public disclosure.

Analysis Date: October 13, 2025 Analyst: Security Researcher Program: Immunefi - Enzyme Onyx


๐Ÿšจ Disclaimer

This repository is for security research and educational purposes only. Do not use this information to exploit live systems or harm users. All testing should be performed on local or forked test networks only.

Be ethical. Be responsible. Be rewarded. ๐Ÿ›ก๏ธ