Skip to content

[RWF] pallet-alliance: init_members accepts duplicate roster members #12723

Description

@xlc

Summary

init_members sorts the Fellows and Allies lists but does not deduplicate them before
storage. This bypasses the uniqueness rule enforced by add_member, inflates counts,
and leaves remove_member able to remove only one copy.

This finding was found by Runtime Whitebox Fuzzer.

Severity / Sensitivity

Low severity, non-sensitive. The root initialization path stores duplicate entries within one public pallet roster.

Source Evidence

  • substrate/frame/alliance/src/lib.rs:570-573: sorts and stores without dedup.
  • substrate/frame/alliance/src/lib.rs:986-993: ordinary member addition rejects duplicates.
  • substrate/frame/alliance/src/lib.rs:1003-1008: removal deletes one binary-search match.
  • substrate/frame/alliance/src/lib.rs:1161-1170: try-state checks ordering but not uniqueness.

PoC Unit Test

Place this in substrate/frame/alliance/src/tests/generated_tests.rs, which is a
child of the existing test module and reuses its new_test_ext mock runtime.

use super::*;
use frame_support::assert_ok;

// RWF-INVARIANTS: inv_mu82au3m,inv_a3esidke,inv_isq8vczj
// RWF-RISKS: risk_6zc2x4az
#[ignore]
#[test]
fn test_risk_6zc2x4az_init_members_duplicate_within_list() {
	new_test_ext().execute_with(|| {
		assert_ok!(Alliance::disband(
			RuntimeOrigin::root(),
			DisbandWitness::new(3, 0),
		));
		assert_ok!(Alliance::init_members(
			RuntimeOrigin::root(),
			vec![1, 1],
			vec![],
		));
		assert_eq!(
			Alliance::voting_members(),
			vec![1],
			"init_members must not duplicate an account within a roster"
		);
	});
}

Reproduction Command

cargo test -p pallet-alliance \
  tests::generated_tests::test_risk_6zc2x4az_init_members_duplicate_within_list \
  -- --ignored --exact --nocapture

Observed Result

panicked at substrate/frame/alliance/src/tests/generated_tests.rs:19:9:
assertion `left == right` failed: init_members must not duplicate an account within a roster
  left: [1, 1]
 right: [1]

Expected Behavior

Reject duplicate input or normalize each role list with dedup before storage and
collective initialization.

Likely Fix Direction

Reject duplicate accounts within each input roster or sort and deduplicate before storing and notifying InitializeMembers.

RWF Metadata

  • Found by Runtime Whitebox Fuzzer

  • Finding: find_qkceaaa6r8

  • Target: pallet-alliance

  • Severity: low

  • Category: logic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions