sherlock-audit / 2024-02-telcoin-platform-audit-update-judging

3 stars 1 forks source link

Nyxaris - Missing Validation of External XYZ Tokens in convertFromEXYZ Function #13

Closed sherlock-admin4 closed 8 months ago

sherlock-admin4 commented 8 months ago

Nyxaris

high

Missing Validation of External XYZ Tokens in convertFromEXYZ Function

Summary

The convertFromEXYZ function does not use the isXYZ check to validate the token before performing operations.

Vulnerability Detail

The isXYZ function is intended to validate whether a token is recognized as a valid external XYZ token. However, in the convertFromEXYZ function, there is no call to isXYZ to ensure that the origin or target tokens are indeed valid external XYZ tokens before proceeding with the conversion.

Impact

The absence of this validation could allow unauthorized or unintended tokens to be used in the conversion process, potentially leading to incorrect accounting, loss of funds, or exploitation of the contract's logic.

Code Snippet

code

function convertFromEXYZ(
        address wallet,
        address safe,
        StablecoinSwap memory ss
    ) public virtual whenNotPaused nonZero(ss) onlyRole(SWAPPER_ROLE) {
        if (
            Stablecoin(ss.origin).totalSupply() - ss.oAmount <
            getMinLimit(ss.origin)
        ) revert InvalidMintBurnBoundry(ss.origin);

        Stablecoin(ss.origin).burnFrom(wallet, ss.oAmount);
        ERC20PermitUpgradeable(ss.target).safeTransferFrom(
            safe,
            ss.destination,
            ss.tAmount
        );
    }

Tool used

Manual Review

Recommendation

Implement a check using the isXYZ function to validate the origin and target tokens before executing the conversion logic in the convertFromEXYZ function. This ensures that only approved external XYZ tokens are used in the conversion process.

sherlock-admin4 commented 8 months ago

2 comment(s) were left on this issue during the judging contest.

WangAudit commented:

swapper role is trusted and controlled by telcoin team

takarez commented:

invalid