Usage of `tx.origin` to determine the user is prone to attacks
The smart contract uses tx.origin to identify the user on whose behalf a function is called, which can be exploited by a malicious contract to act on the user's behalf. An attacker could trick a user into interacting with a malicious contract, leading to loss of funds.
Source: https://github.com/sherlock-audit/2024-08-velar-artha-judging/issues/82
The protocol has acknowledged this issue.
Found by
Bauer, Greed, Japy69, KupiaSec, Waydou, bughuntoor, ctf_sec, y4y
Summary
Usage of tx.origin to determine the user is prone to attacks
Vulnerability Detail
Within core.vy to user on whose behalf it is called is fetched by using tx.origin.
self._INTERNAL()
user : address = tx.origin
This is dangerous, as any time a user calls/ interacts with an unverified contract, or a contract which can change implementation, they're put under risk, as the contract can make a call to api.vy and act on user's behalf.
Usage of tx.origin would also break compatibility with Account Abstract wallets.
Impact
Any time a user calls any contract on the BOB chain, they risk getting their funds lost. Incompatible with AA wallets.
Code Snippet
https://github.com/sherlock-audit/2024-08-velar-artha/blob/main/gl-sherlock/contracts/core.vy#L166
Tool used
Manual Review
Recommendation
Instead of using tx.origin in core.vy, simply pass msg.sender as a parameter from api.vy
Discussion
T1MOH593
Escalate
Noticed there were 19 escalations on preliminary valid issues. This is final escalation to make it 20/20 🙂
sherlock-admin3
Escalate
Noticed there were 19 escalations on preliminary valid issues. This is final escalation to make it 20/20 🙂
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
WangSecurity
bruh
WangSecurity
Planning to reject the escalation and leave the issue as it is.
WangSecurity
Result: Medium Has duplicates
sherlock-admin4
Escalations have been resolved successfully!
Escalation status:
- T1MOH593: rejected
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 contract uses tx.origin instead of msg.sender to determine the user, which can be manipulated by intermediate contracts.
Impact
Any time a user calls any contract on the BOB chain, they risk getting their funds lost, and the contract is incompatible with Account Abstraction wallets.
What the attacker needed
User interacts with a malicious contract
The fix
Instead of using tx.origin in core.vy, simply pass msg.sender as a parameter from api.vy.
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.
In blockchain, tx.origin is a global variable that tells you the original sender of a transaction, even if the transaction goes through other contracts. Using it to identify the user is risky because a malicious contract can call the vulnerable contract and the vulnerable contract will think the user initiated the call, allowing the attacker to act as the user.
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.