`PodUnwrapLocker` can be drained due to an arbitrary input
The debondAndLock function in PodUnwrapLocker accepts any address as the pod without validating it, so an attacker can supply a malicious contract that reports the same token twice. This lets the attacker withdraw twice the amount of tokens they deposited, draining tokens other users have locked in the contract.
Source: https://github.com/sherlock-audit/2025-01-peapods-finance-judging/issues/37
Found by
0xgh0st, X77, gegul
Summary
PodUnwrapLocker can be drained due to an arbitrary input
Root Cause
PodUnwrapLocker provides a functionality to debond your pod tokens without paying a fee by locking them for a period of time. The issue is that the function allows an arbitrary pod input which allows for a complete drain of the contract:
function debondAndLock(address _pod, uint256 _amount) external nonReentrant {
// NO CHECK FOR THE POD HERE
}
Internal Pre-conditions
No response
External Pre-conditions
No response
Attack Path
- A malicious contract is provided as the pod upon calling
debondAndLock() - In the line below, pod returns an array of 2 addresses which are both the same token, token
X(token to be drained, deposited by other users who are using the contract functionality):
IDecentralizedIndex.IndexAssetInfo[] memory _podTokens = _podContract.getAllAssets();
- In the line below, we store the token
Xbalances in both of the array fields, let's say 100 tokens:
for (uint256 i = 0; i < _tokens.length; i++) {
_tokens[i] = _podTokens[i].token;
_balancesBefore[i] = IERC20(_tokens[i]).balanceOf(address(this));
}
- We then call
debond()on our contract which transfers in 100 tokens ofX - In the line below, we fill the received amounts array with 100 tokens twice:
for (uint256 i = 0; i < _tokens.length; i++) {
_receivedAmounts[i] = IERC20(_tokens[i]).balanceOf(address(this)) - _balancesBefore[i];
}
- We return our own config with a 0 duration to immediately withdraw and store our received amounts in the locks mapping
- We go over our token
Xtwice with 100 amount in both fields, receiving 200 tokens even though we put in 100
Impact
Theft of funds
PoC
No response
Mitigation
Do not allow arbitrary pods
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 function never checks that the supplied pod address is a legitimate, registered pod, so a malicious contract can return duplicated token entries and inflate the credited amounts.
Impact
An attacker could steal tokens deposited by other users who are using the contract's locking functionality.
What the attacker needed
Attacker can deploy a malicious contract; victim tokens locked in the contract
The fix
The function should reject pod addresses that are not legitimate registered pods.
How it was found
- Call debondAndLock() with a malicious contract as the pod.
- The malicious pod returns an array of two addresses that are both the same token X.
- The contract records token X's balance in both array fields.
- The malicious pod's debond() transfers in 100 tokens of X.
- The received amounts are filled with 100 tokens twice.
- The malicious pod returns a zero-duration config, and the attacker withdraws 200 tokens for 100 deposited.
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.
A pod is a token that bundles other tokens together. This contract lets people lock their pod tokens for a while to avoid a fee, and it trusts whatever pod address it is given. An attacker can give it a fake pod that lies about which tokens it holds, so the contract counts the same tokens twice and pays out more than was put in.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.