Documentation-Implementation Discrepancy in Agent Vault Access Control
The Agent Vault contract's depositCollateral and updateCollateral functions are documented as callable by anyone, but are implemented with an onlyOwner modifier. This prevents third parties from depositing collateral on behalf of the vault owner, reducing flexibility.
Originally disclosed on Immunefi
- Disclosed after under an hour
#46218 [SC-Insight] Documentation-Implementation Discrepancy in Agent Vault Access Control
Submitted on May 26th 2025 at 20:30:49 UTC by @Victor_TheOracle for Audit Comp | Flare | FAssets
- Report ID: #46218
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/flare-foundation/fassets/blob/main/contracts/assetManager/implementation/AgentVault.sol
- Impacts:
Description
Brief/Intro
The depositCollateral and updateCollateral functions in the Agent Vault contract are documented to be callable by anyone but are implemented with onlyOwner modifiers, restricting access to vault owners only. This prevents third-party funding mechanisms and flexible collateral management as described in the documentation.
Vulnerability Details
The documentation explicitly states that both depositCollateral and updateCollateral should be callable by anybody:
Documentation Claims:
depositCollateral: "NOTE: anybody can call this method, to allow the owner to deposit from any wallet."updateCollateral: "NOTE: anybody can call this method, to allow the owner to deposit from any source."
Actual Implementation:
function depositCollateral(IERC20 _token, uint256 _amount)
external override
onlyOwner //@audit Contradicts documentation
{
_token.safeTransferFrom(msg.sender, address(this), _amount);
assetManager.updateCollateral(address(this), _token);
_tokenUsed(_token, TOKEN_DEPOSIT);
}
function updateCollateral(IERC20 _token)
external override
onlyOwner //@audit Contradicts documentation
{
assetManager.updateCollateral(address(this), _token);
_tokenUsed(_token, TOKEN_DEPOSIT);
}
This implementation shows that it has deviated from what was documented.
Impact Details
The primary consequence of this access control discrepancy is loss of flexibility as third parties cannot assist with collateral management despite this functionality being explicitly documented.
References
- AgentVault documentation for the
depositCollateral, andupdateCollateralfunctions: https://github.com/flare-foundation/fassets/blob/fc727ee70a6d36a3d8dec81892d76d01bb22e7f1/docs/IAgentVault.md?plain=1#L1-L5 - AgentVault implementation: https://github.com/flare-foundation/fassets/blob/fc727ee70a6d36a3d8dec81892d76d01bb22e7f1/contracts/assetManager/implementation/AgentVault.sol#L93-L109
Proof of Concept
- The documentation clearly states that anybody can call the
depositCollateralandupdateCollateralmethods, to allow the owner to deposit from any wallet or source.
**depositCollateral** - Deposit vault collateral. Parameter `_token` is explicit to allow depositing before collateral switch.
NOTE: owner must call `token.approve(vault, amount)` before calling this method. NOTE: anybody can call this method, to allow the owner to deposit from any wallet.
**updateCollateral** - Update collateral after `transfer(vault, some amount)` was called (alternative to depositCollateral). Parameter `_token` is explicit to allow depositing before collateral switch.
NOTE: anybody can call this method, to allow the owner to deposit from any source.
- Owner tries to deposit or update collateral from another wallet, but the transaction fails with the "Ownable: caller is not the owner" error.
- This does not align with the documentation and it should be corrected.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the developers added an onlyOwner modifier to the functions but forgot to update the documentation, or vice versa.
Impact
The discrepancy reduces flexibility because third parties cannot assist with collateral management as documented.
What the attacker needed
Access to the contract; non-owner wallet
How it was found
- Read the documentation stating anyone can call depositCollateral and updateCollateral.
- Attempt to call depositCollateral or updateCollateral from a non-owner wallet.
- Observe the transaction fails with an ownership error.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
This report is about a mismatch between what the code's documentation says and what the code actually does. The documentation says anyone can call two functions to add collateral to a vault, but the code only lets the vault owner call them. That means a feature described in the docs does not work as promised.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.