Arbitrary code can be run with Controller as msg.sender
The Controller contract allowed a caller to supply an arbitrary contract address as a qToken for a QTokenPermit action, and then called permit() on that address with the Controller as msg.sender. An attacker could deploy a malicious contract implementing the expected interface and have the asset-bearing Controller call it, potentially enabling arbitrary code execution in the Controller's context.
Submitted by hyh
A malicious user can call Controller’s operate with ActionType.QTokenPermit, providing a precooked contract address as qToken, that will be called by Controller contract with IQToken(_qToken).permit(), which implementation can be arbitrary as long as IQToken interface and permit signature is implemented.
The Controller is asset bearing contract and it will be msg.sender in this arbitrary permit() function called, which is a setup that better be avoided.
Proof of Concept
When the Controller’s operate with a QTokenPermit action, it parses the arguments with Actions library and then calls internal _qTokenPermit:
_qTokenPermit calls the IQToken(_qToken) address provided without performing any additional checks:
This way, contrary to the approach used in other actions, qToken isn’t checked to be properly created address and is used right away, while the requirement that the address provided should implement IQToken interface and have permit function with a given signature can be easily met with a precooked contract.
Recommended Mitigation Steps
Given that QToken can be called directly please examine the need for QTokenPermit ActionType.
If current approach is based on UI convenience and better be kept, consider probing for IOptionsFactory(optionsFactory).isQToken(_qToken) before calling the address provided.
0xca11 (Rolla) confirmed, resolved, and commented:
Fixed in RollaProject/quant-protocol#82.
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
The _qTokenPermit function called IQToken(_qToken).permit() on a user-supplied address without verifying that the address was a legitimate qToken created by the factory.
Impact
Because the Controller holds assets and acts as msg.sender, an attacker's arbitrary code could potentially manipulate or drain those assets, though the report does not demonstrate a specific theft.
What the attacker needed
Ability to call Controller.operate; deploy a contract implementing IQToken.permit
The fix
The project fixed this by adding a check that the supplied address is a legitimate qToken, likely via IOptionsFactory(optionsFactory).isQToken(_qToken), before calling permit().
How it was found
- Deploy a malicious contract that implements the IQToken interface and a permit function with the expected signature.
- Call Controller's operate with ActionType.QTokenPermit, passing the malicious contract's address as qToken.
- The Controller calls permit() on the malicious contract with itself as msg.sender, executing the attacker's code in that context.
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 smart contract called Controller lets users ask it to call another contract's permit function. The problem is that it never checked whether the address it was told to call was a real, trusted token contract. An attacker could give it the address of their own contract, and the Controller would call it while acting as itself, which could let the attacker's code do things the Controller normally does.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.