sherlock-2023-10-looksrare-m02

[M-02] Wound agent can’t invoke heal in the next round

보고서

Summary

문서에서 말한 바와는 다르게 2라운드 뒤부터 치료가 가능하다.

Keyword

logic flaw, gamefi

Vulnerability

문서에 따르면 부상을 입은 에이전트는 바로 다음 라운드부터 치료할 수 있다.

So for example if an agent is wounded in round 12. The first round they can heal is round 13,

하지만 실제로는 2라운드 뒤부터 치료할 수 있다.

    // No need to check if the heal deadline has passed as the agent would be killed
    unchecked {
        if (currentRoundId - woundedAt < 2) {
            revert HealingMustWaitAtLeastOneRound();
        }
    }

Impact

유저가 에이전트를 치료하기 위해 1라운드를 더 기다려야 하며, 이로 인해 더 적은 치료 성공 확률로 치료해야 한다.

Mitigation

    // No need to check if the heal deadline has passed as the agent would be killed
    unchecked {
-       if (currentRoundId - woundedAt < 2) {
+       if (currentRoundId - woundedAt < 1) {
            revert HealingMustWaitAtLeastOneRound();
        }
    }

Memo

로직이 좀 이상하네 하고 넘어갔는데 버그였다.. 문서와의 비교도 중요한 듯.. 당연히 문서대로 개발되어 있겠지 하고 넘어가지 말고 확인해야겠다.


tags: bughunting, looksrare, smart contract, solidity, gamefi, nft, logic flaw, severity medium