# Mean-Based Outlier Detection Vulnerability Allows Single Node to Sabotage Consensus

Seda's std-dev outlier filter uses arithmetic mean instead of median, letting one malicious node skew consensus and exclude honest reveals.

- Payout: Audit contest
- Severity: medium
- Program: Seda Protocol
- Found by: 0xNirix
- Disclosed: 2024-12-20
- Write-up quality: 6/10
- Original: https://github.com/sherlock-audit/2024-12-seda-protocol-judging/issues/230
- Library page: https://bugbountylibrary.com/r/sherlock%3A2024-12-seda-protocol%3AM-9
- Tags: area:web3 domain:web3 impact:dos impact:integrity kind:contest platform:sherlock sev:medium tech:go technique:source-review vuln:accounting-error

**Target:** seda-chain x/tally FilterStdDev.ApplyFilter / detectOutliersBigInt
**Root cause:** detectOutliersBigInt computes the arithmetic mean (sum.Div(sum,n)) instead of the median as the code comment specifies, so a single extreme submitted value skews mean and standard deviation and misclassifies honest values as outliers.
**Steps:**
1. Honest nodes submit reveals in a normal range.
2. Malicious node submits an extreme value near maxUint64.
3. Mean and stddev are computed from the skewed set.
4. Honest values deviate >k*sigma from the skewed mean and are flagged outliers.
5. Fewer than 2/3 non-outlier values remain, so consensus fails or the aggregated output is shifted.
**How found:** Code review noticed the doc comment says values are compared against the median, but the implementation uses the arithmetic mean; reasoned via Chebyshev's inequality that up to 1/k^2 values can fall outside k sigma, enabling targeted exclusion.
**Exploitation:** A single malicious node submits an extreme reveal to skew the mean/stddev filter, either blocking round finalization (consensus failure) or selectively excluding honest values to bias the final aggregated output, without controlling 1/3 of the network.
**Insight:** When a filter's doc comment names a robust statistic (median) but code uses a non-robust one (mean), treat it as a manipulation vector: check whether a single extreme input can shift the statistic enough to change set membership.

