buckyos / SourceDAO

BSD 2-Clause "Simplified" License
2 stars 2 forks source link

Security Improvements for proposal contracts #5

Open weiqiushi opened 1 year ago

weiqiushi commented 1 year ago

Consider an attack on our centralized backend, where both the backend code and the database can be modified, it is possible to reach the following attack:

  1. someone creates a normal project proposal with a proposal id of 100
  2. through the code, he created a malicious Token release proposal, the proposal ID is 101
  3. by modifying the backend database, the ID of the project proposal is changed to 101 in the backend.
  4. when other people vote in the front-end, they see the description of the project proposal, but when they vote, they vote for the malicious proposal 101.
  5. when 101 is passed, it can operate the release token interface to release the token to itself. In order to stop this attack, we need to add validation to the chain to prevent the backend from voting for the wrong proposal. The solution I'm considering is as follows: Use the params[] validation function of the proposal.

If above scheme is applied, then the previous attack, will become: If the attacker only modifies the proposal ID, then when the front-end is displayed, modification 6 will prevent this proposal from being displayed If the attacker modifies both the proposal ID and the proposal parameters, then when the front-end is displayed, modification 5 will be displayed as a Token to release the proposal In both cases, the vote will not succeed and the attack fails In the case where the back-end code may have been modified, there is no need to do any other validation logic in the backend, because there is a possibility of being bypassed in both cases

weiqiushi commented 1 year ago

All current proposal`s params has been defined, porposals.md

weiqiushi commented 1 year ago

@alexsunxl