code-423n4 / 2023-03-wenwin-findings

1 stars 1 forks source link

When buying lottery tickets, you can mark the referral as yourself as well as the frontend operator. #296

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-03-wenwin/blob/91b89482aaedf8b8feb73c771d11c257eed997e8/src/Lottery.sol#L110-L131

Vulnerability details

Impact

If a user buys a lottery ticket and refers to himself in both the referral fee and operator fee, the protocol will be negatively impacted because of the unnecessary discount of the ticket. This behavior should be analyzed more in depth and consider a scenario of a facade/front website that it's only purpose is to serve lottery buyers by providing more rebates (player, referrer, and frontend reward).

Proof of Concept

    function testBuyTicketAndBeFrontend() public {
        vm.startPrank(USER);
        vm.label(USER, "USER");

        uint128 currentDraw = lottery.currentDraw();
        rewardToken.mint(5 ether);
        rewardToken.approve(address(lottery), 5 ether);

        uint128[] memory drawIds = new uint128[](1);
        drawIds[0] = currentDraw;
        uint120[] memory tickets = new uint120[](1);
        tickets[0] = uint120(0x0F);

        uint256[] memory ticketIds = lottery.buyTickets(drawIds, tickets, USER, USER);
}

Recommended Mitigation Steps

c4-judge commented 1 year ago

thereksfour marked the issue as duplicate of #483

c4-judge commented 1 year ago

thereksfour changed the severity to QA (Quality Assurance)