Smart Contract / Write to Arbitrary Storage Location



Write to Arbitrary Storage Location (CWE-78) is a type of vulnerability in Smart Contract that allows an attacker to write data to an arbitrary memory location. This memory location could be outside of the smart contract’s allocated memory, making it vulnerable to malicious attacks. This vulnerability is commonly found in Solidity (SWC) smart contracts and can be exploited by a malicious actor to gain control of a smart contract. According to the OWASP Testing Guide, this type of vulnerability can be identified by examining the source code of a smart contract.


This type of vulnerability can have a high risk impact on the smart contract. It can allow an attacker to gain control of the contract and potentially manipulate the data stored in the contract. This can lead to financial losses or data leakage.


The best way to mitigate this risk is to ensure that all of the code within the smart contract is thoroughly inspected and tested. This can be done by manually examining the code or by using security tools to scan the code for potential vulnerabilities. Additionally, it is important to deploy the smart contract on a secure platform, such as the Ethereum Virtual Machine (EVM).


The following code from the CVE directory is an example of this vulnerability:

contract MyContract {
  address public owner;

  function MyContract() {
    owner = msg.sender;

  function setOwner(address _owner) {
    owner = _owner;

This code allows an attacker to set the owner of the contract to a malicious address. If the owner of the contract is not checked before setting the owner, the malicious address can be set as the owner of the contract.

Curious? Convinced? Interested?

Arrange a no-obligation consultation with one of our product experts today.