Add randomness reference across four skills#35
Open
claucondor wants to merge 7 commits into
Open
Conversation
…en AGENTS routing
peterargue
reviewed
May 27, 2026
|
|
||
| ### Detection | ||
|
|
||
| Grep heuristic: any `.cdc` file that contains `revertibleRandom` AND (`panic(` OR `assert(`) in the same scope, AND has state mutation in the same `execute` block. Manual review required — not every same-tx use of `revertibleRandom` is exploitable, only those where the caller has incentive to revert. |
Collaborator
There was a problem hiding this comment.
this detection rule is specific to transactions, but malicious transactions are probably not available to the user trying to scan for vulnerabilities.
Maybe frame this differently. something like detection by looking for randomness being used synchronously to make a decision where an external users could use the panic/assert approach to game the system
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Documents the four ways to generate randomness on Flow. Each API verified
on the emulator before writing. The reference set opens with an upfront
answer to the question every Flow dev hits: can you get randomness the
caller cannot revert on? (Yes, via the commit-reveal pattern with
RandomConsumer.)randomness.mdcoveringrevertibleRandom<T>(),RandomBeaconHistory.sourceOfRandomness,RandomConsumer+Xorshift128plus, plus a decision matrix and 10 documented gotchas(view-fn constraint, in-block script repetition, modulo bias, deploy
order, etc.)
randomness-vulns.mdwith 6 vulnerabilityclasses — abort-on-bad-roll (reproduced 10/10 attempts on emulator),
modulo bias, reveal-too-early, public Consumer capability,
single-Request misuse, script-based randomness in tests
secure-randomness.mdwith 6 templates(native roll, beacon read, commit, reveal, setup, PRG multi-draw) plus
an anti-template for the abort-on-bad-roll pattern
use-flow-revertible-random.mdplus a securitywarning expanding the existing entry in
hooks.mdso users hitting thecatalog see the "no economic outcomes" rule and the link to the
deep-dive
protocol-architecture.mdto the new references