I am learning smart contract programming on Ethereum (using Solidity) and realizing that security is highly important here. Why? Because of 2 reasons: they deal with high-stake financial transactions, and smart contracts are immutable once you deploy them. Hence, you have to be really sure about the safety of your code before deploying it. To ascertain this, several static analysis tools are being built and many researchers are actively publishing papers regarding their security.

Now, the security of a smart contract ultimately boils down to safeguarding the internal private variables being changed by a "non-owner" (of the contract). There are several variables and functions, a few public entry-points into the smart contract, and you have to ensure that no entry point leads to malicious consequences.

However, this kind of safeguarding sounds eerily familiar. Isn't that what we have been doing when designing web APIs or classes or RPCs or just any kind of architecture where calls from outside are being made to our internal code base? What exactly sets smart contracts apart in terms of security?

2 Answers 2


Ethereum-style smart contracts are entirely public and immutable, whereas classic web APIs can have private data, private logic, and can be updated at any time by the server operator. Thus, we have different security goals in each setting.

The important property of a smart contract is that it works exactly as expected. Since smart contracts might control significant funds, there is substantial motivation in applying formal methods and static analysis to verify correctness as far as possible. You are correct that there is already a large body of work in that field, but there's always room for further developments and for applying existing techniques to new programming languages and new problems.

You are potentially wrong in assuming that smart contracts have entry points and private data. Anyone can run the smart contract and observe its internal state, unless cryptographic techniques are used to protect the data. In principle, anyone could also falsify the output of the smart contract, but that is useless since the Blockchain uses a consensus mechanism. If we look at the classic C-I-A triad of security goals, Ethereum-style smart contracts do ensure the integrity of computations (via the consensus mechanism, e.g. proof of work or proof of stake) and their availability (through the distributed blockchain design). But they do not afford confidentiality except through the usage of cryptographic techniques.

  • Except they are not "immutable," if the devs choose to mutate them... like they did after the DAO hack...
    – hft
    Commented Sep 16, 2021 at 22:42
  • There are also commonly bugs in smart contracts such that they do not "work[] exactly as expected."
    – hft
    Commented Sep 16, 2021 at 22:43
  • @hft The DAO hack was resolved via a hard fork of the Ethereum blockchain – a highly unusual event, not something a normal smart contract developer can count on. Indeed, bugs are common and bugs are a problem. That is why my answer is saying that there is a lot of interest in applying formal methods and static analysis to smart contracts.
    – amon
    Commented Sep 17, 2021 at 9:02
  • @amon - on the CIA triad... isn't A traditionally Availability (isc2.org/Certifications/CISSP/CISSP-Student-Glossary)? Commented Sep 24, 2021 at 16:23
  • @MartinThompson You're right, A is typically Availability. I've edited accordingly. While that's the “official” definition, it's sometimes useful to look at availability through the lens of authorization: that something is available to authorized users, and not available to unauthorized users.
    – amon
    Commented Sep 24, 2021 at 16:31

A smart contract is much more attractive to an attacker than most other forms of software. Their motivations are higher, because of the potential of acquiring something of high financial value. The potential scale of the reward is high as the contract automates financial transactions - the bug can be exploited multiple times, earning value each time.

Things with financial value are of interest to an attacker - and that changes the effort you should put into defending them. Much like in the "real world" :)

-- edit after comment ---

Yes, technically, it's "just software" - so all the usual activities apply. The language is different, which means that there are likely to be different classes of bugs which are "most popular", but it does just come down to making sure your software does what you want. And will no doubt suffer the usual problems of inadequate descriptions of "what we want" which result in flaws, as well as the low-level implementation failures which don't quite do what the spec said. Another difference (as noted elsewhere in another answer) is that your code is, by the nature of the way the smart contracts work, public - so motivated people can go digging without having to faff about extracting binaries and reverse engineering things.

  • Yes. That is correct. However, what I am asking is how is securing them "technically" different. I am afraid if the researchers are trying to re-solve an already solved problem (solved in other security domains).
    – shivams
    Commented Sep 13, 2021 at 14:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .