One Shot: Reloaded

First Flight #47
Beginner FriendlyNFT
100 EXP
Submission Details
Impact: high
Likelihood: high

Weak randomness in rap battle allows for challenger to manipulate the outcome

Author Revealed upon completion

Root + Impact

Description

When a challenger joins the arena, the battle immediately occurs and the winnner is determined randomly using timestamp in seconds.

This is extremely vulnerable to an attack where a malicious challenger could choose to only join an arena when the timestamp is favorable for them. The fact that the time is taken in seconds is even worse than if it was milliseconds, since even an untrained rapper will have a 50 seconds timestamp inside which they can't loose.

// In rap_battle::go_on_stage_or_battle
@> let rnd = timestamp::now_seconds() % (if (total_skill == 0) { 1 } else { total_skill });
@> let winner = if (rnd < defender_skill) { defender_addr } else { chall_addr };

Risk

Likelihood:

A challenger has the possibility to join the battle only during a time where they ensure a win.

Impact:

Every defender will loose battles

Recommended Mitigation

Refactor the battle mechanics to use real randomness instead of pseudo-randomness with timestamp.

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.