Ethereum Smart Contracts Exploitation Using Right-To-Left-Override Character
A Right-To-Left-Override (RTLO) Unicode character can be inserted into Solidity smart contract source code to visually reorder characters, making malicious logic appear benign. An attacker could use this to deceive developers or auditors into approving a contract that behaves differently from what it appears to do, potentially draining funds.
skylightcyber.com
Published on skylightcyber.com
During the 2019 RSA conference in San Francisco, we presented our work with XM Cyber, analyzing potential security quirks and oddities in Solidity, a popular language for writing Ethereum smart contracts. One of the demonstrated techniques utilized a Right-To-Left-Override character to modify the behavior of a smart…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
The source code editor or viewer does not neutralise or warn about bidirectional Unicode control characters, allowing the visual representation of code to differ from its actual byte sequence.
Impact
An attacker could deceive developers or auditors into approving a contract that contains hidden malicious logic, potentially leading to full drainage of funds; the technique is not detected by common tools.
What the attacker needed
Ability to submit a pull request or contract; victim reads code in a vulnerable viewer
The fix
Static analysis tools should flag contracts containing RTLO or non-ASCII characters, and code viewers should alert users to such characters; Slither added this detection in version 0.6.3.
How it was found
- Insert a Right-To-Left-Override character in a comment or code line to reverse the visual order of subsequent characters.
- The reversed display makes a function call appear to pass arguments in a safe order while the actual code passes them in a harmful order.
- A developer or auditor reading the displayed code sees benign logic and approves the contract.
- The contract, when deployed, executes the harmful logic (e.g., making a guessing game unwinnable).
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 write-up has not been written yet. The Original tab links to the source.
A special invisible character can flip the order in which text is displayed on screen, so code that looks harmless actually does something else. In smart contracts, people trust the source code they read, so hiding malicious logic this way can trick them into approving a contract that steals money.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.