Misleading Comment in merge Function Regarding Token Transfers to wrapped1155Factory
The merge function in the ConditionalScalarMarket contract has a comment that says only Long and Short ERC20 tokens are transferred to the wrapped1155Factory, but the code also transfers Invalid tokens. This could confuse developers about the token flow and, if unintended, lead to unexpected behaviour.
Originally disclosed on Immunefi
- Disclosed after under an hour
#39243 [SC-Insight] Misleading Comment in merge Function Regarding Token Transfers to wrapped1155Fac
Submitted on Jan 25th 2025 at 17:32:48 UTC by @huntercheto for Audit Comp | Butter
- Report ID: #39243
- Report Type: Smart Contract
- Report severity: Insight
- Target: https://github.com/immunefi-team/audit-comp-butter-cfm-v1
- Impacts:
- Contract fails to deliver promised returns, but doesn't lose value
Description
Brief/Intro
The merge function in the ConditionalScalarMarket contract contains a misleading comment that suggests only the Long and Short ERC20 tokens are being transferred to the wrapped1155Factory, while it also involves the Invalid, leading to confusion.
Vulnerability Details
In the merge function, the comment inaccurately states that the contract only transfers Long/Short ERC20 tokens to the wrapped1155Factory, while the Invalid ERC20 tokens are also being transferred. This could cause a misunderstanding of the token flow in the contract. The relevant code is as follows:
// Contract transfers Long/Short ERC20 to wrapped1155Factory and gets
// back Long/Short ERC1155.
wrapped1155Factory.unwrap(
conditionalTokens, wrappedCTData.shortPositionId, amount, address(this), wrappedCTData.shortData
);
wrapped1155Factory.unwrap(
conditionalTokens, wrappedCTData.longPositionId, amount, address(this), wrappedCTData.longData
);
wrapped1155Factory.unwrap(
conditionalTokens, wrappedCTData.invalidPositionId, amount, address(this), wrappedCTData.invalidData
);
Impact Details
This is an INSIGHT, as the misleading comment could lead to confusion and misinterpretation of the code.
But this is a CRITICAL issue if the intent was to work only with the Long and Short tokens, as the Invalid tokens are also being transferred, which could lead to unintended behavior.
Proof of Concept
Proof of Concept
A proof of code is not needed as the issue is straightforward and can be easily identified in the code itself.
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 comment was not updated when the code was changed to also transfer Invalid tokens.
Impact
The misleading comment could lead to confusion and misinterpretation of the code, and if the intent was to work only with Long and Short tokens, the extra Invalid token transfer could lead to unintended behaviour.
What the attacker needed
None
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 comment in the code says only two types of tokens are sent to another contract, but the code actually sends three. This mismatch can confuse people reading the code and might cause mistakes if the extra token transfer was not intended.