Submitted by BenRai
https://github.com/code-423n4/2024-12-secondswap/blob/b9497bcf5100046a169276cb6b351ebc0eddc2cc/contracts/SecondSwap_VestingManager.sol#L149-L152
https://github.com/code-423n4/2024-12-secondswap/blob/b9497bcf5100046a169276cb6b351ebc0eddc2cc/contracts/SecondSwap_VestingManager.sol#L130-L134
When a listed vesting is delisted after the seller has claimed additional steps, the full listed amount is deducted from the sold value of the sellers Allocation data. This allows him to sell tokens which should have already been unlocked and claimable which breaks a core functionality of the protocol, namely the sell limit intended by the value set for maxSellPercent.
The SecondSwap_VestingManager contract manages the vesting and selling of tokens through the listVesting() function. This function checks if the vesting plan is sellable and verifies the users available tokens before allowing a sale. To determine how many tokens a user is allowed to sell, the users current allocation as well as the amounts he has sold and bought until now are taken into account. Each vesting has its own maxSellPercent value to limit the amount of unvested tokens that can be sold at any point in time. This value indicates how many percent of the currently locked tokens should be sellable. E.g. if the total amount of tokens for a vesting is 1000, there are 10 steps and the maxSellPercent is set to 50%,  this mean that in the beginning, when all tokens are still locked, a max of 1000 * 50% = 500 tokens should be sellable. At step 5 when only 500 tokens are locked, only 500 * 50% = 250 tokens should be sellable.
However, this invariant is broken if a seller unlist a listed vesting after he has claimed additional steps compared to when he created the listing. This is because the total refunded amount of tokens is deducted from the sold value without regard to the already unlocked and claimed steps of the seller.
Scenario Illustration
The vesting has 1000 tokens, 10 steps and 50% maxSellPercent
To prevent sellers being able to sell more tokens than specified in maxSellPercent after unlisting a vesting, consider adding a stepsClaimedSeller vriable to the Listing struct indicating the last step the seller has claimed when he created the listing:
In addition, the variable amountClaimable needs to be added to the Vesting struct:
Once the seller unlists a listing, the value of stepsClaimedSeller is compared to the sellers current stepsClaimed. If the seller has claimed additional steps since he initially listed the vesting, the number of steps is calculated and a proportional amount of the refunded tokens is added to amountClaimable making them claimable instantly:
amountToAdd = refundedAmount * (stepsClaimed  stepsClaimedSeller) / totalSteps
To ensure the calculation of available tokens stays accurate, the same amount needs to be added to amountClaimed.
The remaining amount of refunded tokens is deducted from the sold amount and is available for sale again. 
When claiming tokens the amount saved in amountClaimable is added to the amount transfered to the user and amountClaimable is set to 0.
sl1 (warden) commented:
calvinx (SecondSwap) commented:
Koolex (judge) commented:
For this audit, 28 reports were submitted by wardens detailing low risk and non-critical issues. The report highlighted below by oualidpro received the top score from the judge.
The following wardens also submitted reports: 0xGondar, 0xluk3, 0xStalin, Abhan, agadzhalov, Asher, aua_oo7, BajagaSec, BugPull, chaduke, dhank, ElKu, EPSec, falconhoof, FalseGenius, IzuMan, K42, KupiaSec, montecristo, newspacexyz, pontifex, pulse, Rhaydden, rspadi, slowbugmayor, Sparrow, and TheKhans.
