Skip to content
Business logic Audit finding Intermediate

QTokens with the same symbol will lead to mistakes

The QToken symbol only includes the last two digits of the expiry year, so tokens with different expiry years can share the same symbol. An attacker could exploit this ambiguity to trick users into buying the wrong option on a DEX.

IllIllI Follow

Originally disclosed on Code4rena

Submitted by IllIllI

The README.md states:

Bob can then trade the QToken with Alice for a premium. The method for doing that is beyond the scope of the protocol but can be done via any smart contract trading platform e.g. 0x.

It is therefore important that tokens be easily identifiable so that trading on DEXes is not error-prone.

Impact

Currently the QToken name includes the full year but the QToken symbol only contains the last two digits of the year, which can lead to mistakes. If someone mints a QToken with an expiry 100 years into the future, then the year will be truncated and appear as if the token expired this year. Normal centralized exchanges prevent this by listing options themselves and ensuring that there are never two options with the same identifier at the same time. The Rolla protocol does not have any such protections. Users must be told to not only check that the symbol name is what they expect, but to also separately check the token name or the specific expiry, or they might buy the wrong option on a DEX, or have fat-fingered during minting on a non-Rolla web interface. It’s important to minimize the possibility of mistakes, and not including the full year in the symbol makes things error-prone, and will lead to other options providers winning out.

The 0x REST interface for swaps has the ability to do a swap by token name rather than by token address. I was unable to figure out whether there was an allow-list of token names, or if it is easy to add a new token. If there is no, or an easily bypassed, access-control for adding new tokens, I would say this finding should be upgraded to high-severity, though I doubt this is the case.

Proof of Concept

        /// concatenated symbol string
        tokenSymbol = string(
            abi.encodePacked(
                "ROLLA",
                "-",
                underlying,
                "-",
                _uintToChars(day),
                monthSymbol,
                _uintToChars(year),
                "-",
                displayStrikePrice,
                "-",
                typeSymbol
            )
        );

QTokenStringUtils.sol#L115-L130

    /// @return 2 characters that correspond to a number
    function _uintToChars(uint256 _number)
        internal
        pure
        virtual
        returns (string memory)
    {
        if (_number > 99) {
            _number %= 100;
        }

        string memory str = Strings.toString(_number);

        if (_number < 10) {
            return string(abi.encodePacked("0", str));
        }

        return str;
    }

QTokenStringUtils.sol#L181-L199

Recommended Mitigation Steps

Include the full year in the token’s symbol.

0xca11 (Rolla) confirmed, resolved, and commented:

Resolved in RollaProject/quant-protocol#86.


The original report as published on Code4rena, by IllIllI. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the symbol generation truncates the year to two digits, so tokens with different expiry years can produce the same symbol.

Impact

Users could buy the wrong option on a DEX, and the report notes that if 0x's token-name allow-list is missing or bypassable, the severity would be higher.

What the attacker needed

Tokens traded on a DEX; user relies on symbol only

The fix

The issue was fixed by including the full year in the token's symbol.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A token symbol is a short ticker like 'BTC'. Here, the symbol for an options token leaves out the full year, so two tokens that expire in different years can look identical. That could make someone buy the wrong one by mistake.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by IllIllI

View all

119 more disclosed reports, best first.

More from Rolla contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.