One Shot: Reloaded

First Flight #48
Beginner FriendlyNFT
100 EXP
View results
Submission Details
Severity: high
Valid

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

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.

Updates

Lead Judging Commences

bube Lead Judge 20 days ago
Submission Judgement Published
Validated
Assigned finding tags:

Predictable randomness

Support

FAQs

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