I developed a simple smart contract to store two privacy preferences for a user. I am testing and evaluating this contract on a private blockchain via Ganache.
I am currently validating the security of it but I have some doubts. In my research I identified three flaws that could affect this contract: Reentrancy, Front-Running and DoS with Block Stuffing (Details of the attacks can be seen here).
My main question is:
- How to evaluate these issues in the developed contract?
1) To evaluate Reentrancy I thought of invoking one of the contract's functions several times at the same time. Would this idea be valid? How can I do to invoke this function several times at the same time?
2) For Front-Running I thought of monitoring the mempool and checking if I can observe the transaction before it is executed. The question is: how to do this via ganache?
3) For DoS, I thought again about calling a function repeatedly until the gas limit of the block is reached. Would this idea be valid?
Below is the contract code:
pragma solidity ^0.5.0;
contractPrivacyPreferences {
bool preference = false;
bool monitoringType = false;
mapping (address => bool) addresses;
contructor () public {
adresses [address(0x00281055afc982d96fab65b3a49cac8b878184cb16)] = true;
}
function changePreferences() public {
if (addresses [msg.sender])
preference = true;
}
function changeMonitoringType () public {
if (addresses [msg.sender]) {
monitoringType = true;
}
function preferenceStatus() public view returns (bool) {
return preference;
}
function monitoringStatus() public view returns (bool) {
return monitoringType;
}
}