zark
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Emoji Reply
Enable
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# Silo Finance V2 Audit Report – `xSILO` **Auditor:** [@zarkk01](https://x.com/zarkk01) **Date:** 25/5/2025 **Commit Hash:** [1a3c33efd7050d7e1b79808d1c29378b441675dd](https://github.com/silo-finance/silo-contracts-v2/commit/1a3c33efd7050d7e1b79808d1c29378b441675dd) **Repository:** [silo-contracts-v2](https://github.com/silo-finance/silo-contracts-v2/tree/1a3c33efd7050d7e1b79808d1c29378b441675dd) ## Overview ### xSILO Overview `xSILO` is a yield-bearing ERC4626 vault designed to manage `SILO` token deposits and distribute rewards transparently. Users deposit `SILO` and receive `xSILO` shares, which accrue rewards passively via the `Stream` smart contract so there is no need for manual claiming. Inspired heavily by Camelot DEX’s [xGRAIL](https://arbiscan.io/address/0x3CAaE25Ee616f2C8E13C74dA0813402eae3F496b) mechanism, `xSILO` introduces a flexible redemption policy: users may either redeem instantly (with a penalty) or initiate a vesting period to receive a more favorable conversion. During this vesting, `xSILO` shares are locked, and users forgo rewards. ### Audit Scope The audit focused on verifying the security and proper functionality of : - `XSilo.sol` - `XRedeemPolicy.sol` - `XSiloManagement.sol` - `Stream.sol` - `SiloToken.sol` ### Disclaimer This audit is not a guarantee of the absence of vulnerabilities. While every reasonable effort has been made to identify and analyze potential issues, smart contracts carry inherent risk. This is a time, resource and expertise bound effort aimed at identifying as many vulnerabilities as possible within the given constraints. ## Findings | Severity | Count | |------------|-------| | High | 1 | | Medium | 3 | | Low | 4 | ### High Severity #### High-1. Locked `xSILO` Shares Retain Reward Accrual During Vesting **Location:** [XRedeemPolicy.sol](https://github.com/silo-finance/silo-contracts-v2/blob/1a3c33efd7050d7e1b79808d1c29378b441675dd/x-silo/contracts/modules/XRedeemPolicy.sol) **Details:** When a user calls `redeemSilo(xSiloAmount, duration > 0)`, their `xSILO` shares are moved into the vault but remain part of `totalSupply` until `finalizeRedeem`. As a result, those shares keep accruing new rewards throughout the vesting period, without letting these rewards to be distributed to the other depositors until the finalisation of the redemption. ```solidity function redeemSilo(uint256 _xSiloAmountToBurn, uint256 _duration) external virtual nonReentrant returns (uint256 siloAmountAfterVesting) { // ... // if redeeming is not immediate, go through vesting process if (_duration != 0) { // ... @> _transferShares(msg.sender, address(this), _xSiloAmountToBurn); } else { // immediately redeem for SILO // ... } } ``` The problem is that redeemer is not earning those rewards (since at `finalizeRedeem` the `SILO` amount is fixed), but other depositors are **not** earning them **either** until `finalizeRedeem` gets called. In order to understand better this issue, consider this example: - Initial state: 10 xSILO, 100 SILO - Someone calls `redeemSilo` for 5 xSILO and six months duration - State: 10 xSILO (5 "locked" + 5 "active"), 100 SILO (50 "locked" + 50 "active") - New depositor A comes an deposits 100 SILO and gets minted 10 xSILO minted. - State: 20 xSILO (5 "locked" + 15 "active"), 200 SILO (50 "locked" and 150 "active"). - 600 SILO rewards are getting distributed from `Stream`. Supposedly since depositor A holds 2/3 of the "active" xSILO shares, he must take 2/3 of the SILO rewards (400 SILO). - However, if depositor A select to `redeemSilo` for 6 months (full) he will burn 10 xSILO shares and he will get 400 SILO (and not 500 SILO = 100 initial deposit + 400 from the rewards). **Recommendation:** Remove locked shares from reward‐earning immediately at redemption request. Concretely, in `redeemSilo` when `_duration > 0`: 1. Burn the user’s `xSILO` shares (via `_burnShares`) instead of transferring them into the vault. 2. Store the burned‐share amount in `RedeemInfo`. On **cancel**, re‐mint those shares back to the user; on **finalize**, simply withdraw against the already‐burned shares. This ensures vesting shares can’t earn any rewards after the request but also these rewards are distributed to the other depositors **real-time**. --- ### Medium Severity #### Medium-1. Attacker Can Drain All Remaining SILO If The Last Redemption Is Not Full **Location:** [XSilo.sol](https://github.com/silo-finance/silo-contracts-v2/blob/4f2e4a3829ece0cd4a7f0258e4c062993dd61f6f/x-silo/contracts/XSilo.sol#L53) **Details:** When the last honest holder withdraws their entire `xSILO` balance with zero-duration vesting (which applies a 50% redemption ratio), the vault’s `totalSupply` of `xSILO` falls to zero while still holding half of its `SILO` balance. Then, an attacker can steal the remaining `SILO` by repeating deposits of tiny amounts and instant withdrawals. To understand better the issue, consider this scenario : 1. We have 100e18 xSILO shares and 110e18 SILO. 2. Last withdrawer redeems his whole 100e18 xSILO instant so he gets a half cut and takes 55e18 SILO. 3. So, now we have 0 xSILO shares and 55e18 remaining SILO. 4. Attacker can now deposit and withdraw instantly tiny amounts, in order to take the whole 55e18 SILO rewards out of the vault. **Recommendation:** Seed the vault with a non-zero initial `xSILO` supply (like mint a small number of shares to the zero address or owner) so that `totalSupply` never reaches zero. #### Medium-2. Unclaimed Stream Rewards Lost When Switching to a New Stream **Location:** [XSiloManagement.sol](https://github.com/silo-finance/silo-contracts-v2/blob/1a3c33efd7050d7e1b79808d1c29378b441675dd/x-silo/contracts/modules/XSiloManagement.sol#L38) **Details:** In `XSiloManagement::setStream()`, the contract switches from an existing stream to a new one without first invoking `claimRewards()` on the old stream. Any emission rewards that have accrued but not yet been claimed will remain behind in the old `Stream` contract and become effectively unreachable by the vault. Also, the accounting system of the `XSilo` will be ruined. ```solidity function setStream(IStream _stream) external onlyOwner { _setStream(_stream, false); } function _setStream(IStream _stream, bool _skipBeneficiaryCheck) internal { require(stream != _stream, NoChange()); require(_skipBeneficiaryCheck || _stream.BENEFICIARY() == address(this), NotBeneficiary()); stream = _stream; emit StreamUpdate(_stream); } ``` **Recommendation:** In `setStream`, always call `stream.claimRewards()` on the existing stream before updating the reference. #### Medium-3. Instant Redemptions Can Be Sandwiched For Profit **Location:** [XRedeemPolicy.sol](https://github.com/silo-finance/silo-contracts-v2/blob/develop/x-silo/contracts/modules/XRedeemPolicy.sol) **Details:** An attacker can front-run a large “instant” redeem by first depositing, then let the victim’s instant redeem inflate the assets‐per‐share price, and finally do their own instant redeem with only the vesting penalty, locking in a profit. For example: - Initial state: 100 xSILO shares, 1000 SILO in vault so 10 SILO/xSILO - Attacker front-runs: deposits 10 SILO and mints 1 xSILO. - State: 101 xSILO shares, 1010 SILO in vault so still 10 SILO/xSILO - Victim redeem: instant burns 90 xSILO, receives 450 SILO. - State: 11 xSILO shares, 560 SILO so ≈50 SILO/xSILO - Attacker back-runs: instant burn 1 xSILO share for 25 SILO. - Instant profit for attacker 25-10 SILO = 15 SILO. **Recommendation:** Fix not trivial. Blocking instant redemptions and introduce 1 block wait time could solve the issue but will introduce business limits. --- ### Low Severity #### Low-1. Missing Event Emission in `emergencyWithdraw` Function The `emergencyWithdraw` function in the `Stream` contract allows the owner to withdraw all reward assets in case of an emergency. However, the function does not emit an event when the withdrawal occurs. Consider adding this event : ```diff + event EmergencyWithdraw(address indexed recipient, uint256 amount); ``` #### Low-2. Limited Asset Support in `emergencyWithdraw` Function The `emergencyWithdraw` function in the `Stream` contract only allows the owner to withdraw the `REWARD_ASSET` tokens in case of an emergency. This limitation could be problematic if other tokens are accidentally sent to the contract, as there would be no way to recover them. ```diff - function emergencyWithdrawToken() external onlyOwner { + function emergencyWithdrawToken(address token) external onlyOwner { ``` #### Low-3. Possible issue in `fundingGap` Calculation in `Stream` contract The `fundingGap` function calculates the difference between the required tokens for the entire remaining distribution period and the current balance. However, this calculation differs from the actual token requirements for the immediate `pendingRewards` function. The function calculates the gap until the end of the program `(distributionEnd - lastUpdateTimestamp)`, while `pendingRewards` calculates rewards until the current time `(Math.min(block.timestamp, distributionEnd) - lastUpdateTimestamp)`. ```diff function fundingGap() public view returns (uint256 gap) { if (lastUpdateTimestamp >= distributionEnd) return 0; - uint256 timeElapsed = distributionEnd - lastUpdateTimestamp; + uint256 timeElapsed = Math.min(block.timestamp, distributionEnd) - lastUpdateTimestamp; uint256 rewards = timeElapsed * emissionPerSecond; uint256 balanceOf = IERC20(REWARD_ASSET).balanceOf(address(this)); gap = balanceOf >= rewards ? 0 : rewards - balanceOf; } ``` #### Low-4. Incorrect Token Parameter Usage in `XSilo` Constructor The contract's constructor is using the token's symbol as the first parameter where the name is expected. This is a minor issue that doesn't affect functionality but could lead to confusion in the token's display name. The contract should use the token's name instead of its symbol. ```solidity constructor(address _initialOwner, address _asset, address _stream) XSiloManagement(_initialOwner, _stream) ERC4626(IERC20(_asset)) @> ERC20(string.concat("x", TokenHelper.symbol(_asset)), string.concat("x", TokenHelper.symbol(_asset))) {} ``` Gm sir, audit for xSILO is done and the report is ready. Good job happened with interesting issues arissed so, if any clarification is needed, please let me know. Especially for H1, if you need to understand it better. Thank you :)

Import from clipboard

Paste your markdown or webpage here...

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully