Questions tagged [security]

Questions relating to application security, safety, trust, and attacks against the Ethereum software stack and blockchain system.

Filter by
Sorted by
Tagged with
233 votes
20 answers
99k views

How can I securely generate a random number in my smart contract?

If I am writing a smart contract for some kind of (gambling) game, how can I generate a random number securely? What are the best practises and security trade-offs to be aware of?
J-B's user avatar
  • 8,911
12 votes
1 answer
2k views

I got scammed or suspect scam on Ethereum. What to do?

This is a general question and answer on ethereum.stackexchange.com to all "I got scammed, please help" posts. This applies to you if you think: You have been scammed You think something ...
Mikko Ohtamaa's user avatar
68 votes
6 answers
104k views

What number of confirmations is considered secure in Ethereum?

In Bitcoin, 6 confirmations are considered secure (very low probability of transaction/block reversal). What is the current number in Ethereum?
eth's user avatar
  • 85k
78 votes
4 answers
65k views

<address>.send vs <address>.transfer best practice usage?

I noticed that address's offer two member functions that perform the transfer of ether to the specified address. send returns false upon failure and transfer raises an exception. In the Solidity ...
Michael's user avatar
  • 1,035
29 votes
3 answers
22k views

How can I make new account by JSON-RPC?

I'd like to make new account by JSON-RPC.I've checked the wiki of Ethereum, however I could not find out how to do that. I've found call existed accounts, but it isn't what I want. eth_accounts ...
Toshi's user avatar
  • 2,357
28 votes
3 answers
10k views

How do gas refunds work?

Gas refunds are provided when clearing storage or calling SELFDESTRUCT on contracts. The Yellow Paper mentions that refunds are "being capped up to a maximum of half...". What exactly is ...
eth's user avatar
  • 85k
70 votes
3 answers
19k views

Why can't contracts make API calls?

The model that contracts can only accept and process data, instead of also being able to retrieve data from the Internet, seems limiting (even if not, it's less direct). If a concern is that data or ...
eth's user avatar
  • 85k
39 votes
2 answers
12k views

Is each Ethereum address shared by (theoretically) 2 ** 96 private keys?

Summary This is an extended question to How are ethereum addresses generated?. In Ethereum, a private key is 256-bit long, but an address is only 160-bit long. By "Pigeonhole Principle", it ...
Siu Ching Pong -Asuka Kenji-'s user avatar
56 votes
3 answers
25k views

How to reduce the chances of your Ethereum wallet getting hacked?

Summary The hack that occurred on May 12 2016 to steal 7,218 ethers from Patrick only affects miners where: Incoming RPC connections from the Internet on TCP port 8545 are forwarded to the machine ...
BokkyPooBah's user avatar
  • 40.2k
50 votes
3 answers
10k views

What is a recursive calling vulnerability?

What is a recursive calling vulnerability exactly? When creating smart contracts, DAOs or DAPPs, what measures can I take to ensure I am not vulnerable?
user36100's user avatar
  • 603
40 votes
3 answers
12k views

Can a contract safely rely on block.timestamp?

How safe is it to use block.timestamp as contract expiration time? If a miner provides an incorrect timestamp in a block header, how much can it be off before it is rejected by other nodes? Is there a ...
J-B's user avatar
  • 8,911
37 votes
1 answer
7k views

When can BLOCKHASH be safely used for a random number? When would it be unsafe?

I've seen more complicated ways for a contract to generate a random number. But the Ethereum Yellow Paper itself suggests a "trivial solution" using the BLOCKHASH opcode (see below, bold is mine). ...
eth's user avatar
  • 85k
35 votes
2 answers
7k views

Ethereum smart contract security checklist

Is there a tool, checklist of methodology to help reviewing smart contract security? E.g. for each of function you review Is there re-entry possibility and how it behaves on re-entry How it behaves ...
Mikko Ohtamaa's user avatar
25 votes
1 answer
4k views

What if I had the private key that had the public address of a contract?

Could I spend the money a contract owns if I had the private key that goes to the public address that a contract resides at? (I realize that I'd have a better chance of being struck by lightning ...
linagee's user avatar
  • 6,118
23 votes
3 answers
7k views

Account uniqueness guaranteed?

When we create an account in the Ethereum main network, how does the protocol guarantee the unique address of an account? Since even if we are not connected to the network we can create an account, is ...
Abhiram mishra's user avatar
22 votes
2 answers
5k views

What are effective techniques to encrypt/decrypt data stored in a smart contract?

Rather than sending and storing plain text in a smart contract, the use case objective is to encrypt first and then subsequently access the data and decrypt at the point of use. What is the most ...
Alan Wunsche's user avatar
  • 1,655
20 votes
2 answers
9k views

Is transfer() still safe after the Istanbul update?

In other words, is using transfer() safe? function transfer(address contractB) public { contractB.transfer(1000); //balances[msg.sender] -= 1000; } How about using call.gas? function ...
Robert Ggg's user avatar
11 votes
1 answer
3k views

Can I unlock an account using JSON-RPC?

The only way I can work with ETH is through --rpc mode. Normally I would prefer to use the Python interface. But I found myself in a situation where the RPC is very limited. For example, I can't ...
yanik's user avatar
  • 463
64 votes
7 answers
16k views

How can I verify that a contract on the blockchain matches the source code?

Given the (Solidity) source code of a smart contract, is there a way to deterministically compile the code and compare it with the code on the blockchain? I want to verify that the contract does what ...
J-B's user avatar
  • 8,911
22 votes
3 answers
4k views

TheDAO hack FAQ: How did the attack happen on 17 June 2016?

Can anyone explain that how the DAO attack happened? Vitalik Buterin explained here that it was performed by splitting a DAO from the main DAO but calling the split function recursively. We know that ...
14 votes
1 answer
4k views

Why isn't fast sync the default?

As I understand, fast sync has all the security guarantees of a full sync, but is faster. Is that correct? If so, why isn't fast sync the default?
Randomblue's user avatar
  • 2,600
13 votes
2 answers
8k views

Solidity functions - private visibility

Is the following function parameter (string name) only visible to the owner contract itself? function myFunction(string name) private returns (bool) { return true; } So nobody can read / see ...
Alex Darby's user avatar
22 votes
3 answers
7k views

How does the Ethereum ETH accounting system work and prevent double-spends?

In Bitcoin, the BTC accounting system is based on UTXOs (Unspent Transaction Outputs), which prevents the same BTC from being spent multiple times. I heard that Ethereum has a simpler account balance ...
Randomblue's user avatar
  • 2,600
20 votes
5 answers
7k views

Is there any safe way to send money from a cold wallet, using an untrusted computer?

You have 2 computers. One is 100% offline and, thus, trusted. Other is online. Private keys are stored on the offline computer and the online computer has no access to it. Is there any way to sign a ...
MaiaVictor's user avatar
  • 3,177
17 votes
2 answers
3k views

During a 51% attack, What Can the Attacker Actually Accomplish?

During an attack on the network, where the attacker has more than 51% of hashing power (or the equivalent of Ether in PoS), what can the attacker do and not do to the chain and the contracts on it? ...
HodlDwon's user avatar
  • 927
9 votes
1 answer
912 views

How many ethers have been drained through the recursive call attacks on The DAO?

The recursive call attacks on The DAO have now stopped as there are no more ethers in The DAO account. What are the amounts and percentages that can be attributed to the hostile and friendly attacks, ...
BokkyPooBah's user avatar
  • 40.2k
18 votes
5 answers
3k views

How will regular users be able to use dApps without buying ether?

Requiring users to get ether before they can use a dApp, is too much of a barrier for any kind of mainstream adoption. If dApps offer free ether in a naive way, they can be attacked by Sybils where a ...
eth's user avatar
  • 85k
16 votes
1 answer
970 views

Why were empty accounts allowed to be on the blockchain?

It's hard to see what the benefits of allowing empty accounts to be on the blockchain are. This was a known subtlety (see "note: there is a difference between zero-balance and nonexistent") and ...
eth's user avatar
  • 85k
9 votes
1 answer
6k views

How to unlock accounts programmatically after the node has started?

Is there any way of just unlocking accounts without opening the console with geth? I'm writing some scripts to automate cluster generation and I wish I could just call geth to unlocking some accounts ...
Henrique Barcelos's user avatar
51 votes
4 answers
12k views

Is there anything stopping me from using the ethereum blockchain as data storage?

As I understand it, smart contracts are currently immortal by default. Does this mean that I could create a contract that happened to contain an encoded form of baby photos and have it stored forever? ...
Shelvacu's user avatar
  • 1,405
21 votes
2 answers
8k views

Is it safe to reuse Ether addresses?

I believe it's viewed as unsafe in Bitcoin because of the way transactions are signed. Is this also true for Ether addresses?
clewisjr1's user avatar
  • 261
20 votes
3 answers
15k views

How to validate a private key?

I could not find any library that, given an hex value, returns true if the given string is a valid ether private key. Any hints?
Advanced's user avatar
  • 375
18 votes
1 answer
8k views

What happens if transaction runs out of gas before transaction completes?

As gas cost can only be estimated until the transaction is executed against the actual contract state at the time of execution on the blockchain, what happens if transaction runs out of gas before the ...
zanzu's user avatar
  • 5,350
8 votes
1 answer
1k views

How many The DAO recursive call vulnerability attacks have occurred to date?

The first identified The DAO recursive call vulnerability attack occurred on 17 June 2016, with the accounts identified in Which accounts are involved in mounting the recursive call vulnerability ...
BokkyPooBah's user avatar
  • 40.2k
2 votes
1 answer
604 views

State only node

Is it possible for the network clients to just keep the latest network state (without keeping track of the past transactions) while not harming the network security? That is, is it really needed to ...
Jan Beneš's user avatar
19 votes
3 answers
13k views

Is it possible to overflow uints?

The Ethereum token tutorial has a check for a uint256 overflow. function transfer(address _to, uint256 _value) { /* Check if sender has balance and for overflows */ if (balanceOf[msg.sender] ...
Noah Thorp's user avatar
14 votes
4 answers
10k views

What Hierarchical Deterministic (HD) wallets are available for Ethereum?

A Hierarchical Deterministic (HD) wallet has some nice features such as easier backup (instead of needing to backup multiple keystore files and the passwords for each of them). Are there any ...
11 votes
4 answers
1k views

"potential rewrite attack" message on Geth

When I was sending Ether using Mist I got the following message on Geth. I0528 18:34:57.312997 core/blockchain.go:959] imported 1 block(s) (0 queued 0 ignored) including 3 txs in 19.344963ms. #...
wacax's user avatar
  • 1,378
9 votes
1 answer
832 views

What data will zk-SNARKs protect?

Implementing zk-SNARKs is planned in Ethereum roadmap, what data will be obfuscated? transaction sender and receiver? data in transactions? data stored in contracts? variables and methods in ...
Satoshi Nakanishi's user avatar
8 votes
1 answer
2k views

How does a fallback function rejecting ether work?

A contract in Solidity can have a fallback function like: // This contract rejects any Ether sent to it. It is good // practise to include such a function for every contract // in order not to loose ...
eth's user avatar
  • 85k
28 votes
6 answers
44k views

Is there a way to generate ethereum paper wallets?

Is it possible to store ether on paper wallets or generate printable private keys offline somehow?
q9f's user avatar
  • 32.8k
25 votes
1 answer
13k views

Is Solidity block.number more secure than timestamp?

In Solidity, some properties such as block.timestamp are attackable by miners and are not (strongly) protected by the protocol. How about block.number, could a miner introduce a randomly high number? ...
SCBuergel's user avatar
  • 8,704
20 votes
3 answers
6k views

How does Oraclize handle the TLSnotary secret?

Oraclize claims to offer a provably honest secure retrieval of a webpage by taking advantage of TLSnotary (a service that allows an auditor to verify if a specific web page was accurately retrieved) ...
Jeff Coleman's user avatar
14 votes
2 answers
6k views

How to steal eth using delegatecall and selfdestruct

This documentation says Even if a contract’s code does not contain a call to selfdestruct, it can still perform that operation using delegatecall or callcode. This worries me. I've created ...
user1938620's user avatar
12 votes
1 answer
3k views

How does the stack depth attack make a send() silently fail?

From a blogpost on security from Christian Reitwiessner: Because of the maximal stack depth of 1024 the new bidder can always increase the stack size to 1023 and then call bid() which will cause the ...
mKoeppelmann's user avatar
  • 7,586
10 votes
1 answer
1k views

What about illegal smart contracts?

Trying to get a friend excited about smart contracts I referred him to an ethereum pyramid scheme as an easy to understand example but he only pointed out that all pyramid schemes are illegal. How ...
hcvst's user avatar
  • 2,008
9 votes
3 answers
2k views

Flash loan security considerations and attacks

What do developers need to be aware of to make their contracts and systems safe against flash loans? What do they have to think about and protect against?
eth's user avatar
  • 85k
9 votes
2 answers
1k views

Is sending some datas in the data field safe?

An airdrop ask to send it 0ETH with 150000 GAS and some datas in DATA field. Is it safe? What could be the aim of this transaction? Thanks.
Pat Hibulaire's user avatar
5 votes
2 answers
8k views

How do I "Add Data" to a send transaction in Solidity

In myetherwallet, there is an +Advanced: Add Data Section where I can add data to the transaction. How can I add this same data in a transaction I make in Solidity?
ZeroPointThree's user avatar
5 votes
2 answers
3k views

Honest lottery winner generation - pseudo random number obtaining

Suppose I would like to organize a honest lottery and prevent cheating when we need to find a winner. I known problem of random number in the known network arises. I would like to try the following ...
StanislavL's user avatar