Slow Tan Swallow
Medium
Doing vouchByAddress
then increaseVouch
would be more beneficial for users as they would receive some part of the entry fee. Thus users can exploit this to get some part of their paid fee back and lower the fees for the rest of the users.
This happens as increaseVouch
would applyFees
and since our user would own some percentage of the total vouch balance, he would be entitled to that % of the fees.
function increaseVouch(uint256 vouchId) public payable nonReentrant {
// ...
(uint256 toDeposit, ) = applyFees(msg.value, true, subjectProfileId);
}
function applyFees(...) internal returns (uint256 toDeposit, uint256 totalFees) {
// ...
if (vouchersPoolFee > 0) {
vouchersPoolFee = _rewardPreviousVouchers(vouchersPoolFee, subjectProfileId);
}
function _rewardPreviousVouchers(...) internal returns (uint256 amountDistributed) {
// ...
uint256 remainingRewards = amount;
for (uint256 i = 0; i < totalVouches && remainingRewards > 0; i++) {
Vouch storage vouch = vouches[vouchIds[i]];
if (!vouch.archived) {
//@autism since our user already has `vouch.balance` he would receive % of the fees he pays
// amount * balance / totalBalance
uint256 reward = amount.mulDiv(vouch.balance, totalBalance, Math.Rounding.Floor);
if (reward > 0) {
vouch.balance += reward;
remainingRewards -= reward;
}
}
}
See Attack Path
for a good example
applyFees
acting as weights, distributing to all users
Users receiving rewards for their own vouching
No response
Users to first vouchByAddress
then increaseVouch
Bob has 9 ETH vouched to him
Normal case
- Alice vouches 20 ETH to Bob, where 10% of that goes to the rest of the vouchers
- Alice has vouched 18 ETH to Bob (2 ETH paid as fee)
Attack
- Alice vouches 10 ETH to Bob (1 ETH fee)
- Bob has 18 ETH vouched for him (50% is from Alice - 9 ETH)
- Alice vouches again 10 ETH to Bob (sending 1 ETH as rewards)
- However since Alice holds 50% of his vouches (9 ETH) she claims 50% of the fees (0.5 ETH)
First scenario Alice vouched 20ETH and pays 2 ETH fees, as it should. Second scenario Alice vouched 20ETH and pays only 1.5 ETH in fees.
Note that the more the vouch increase is split between TX the more our user will save on fees.
Users can reduce the fees they pay. They also steal some fees from the rest of the vouchers
No response
Consider not returning any fees to msg.sender
who increases it's vouch.