Skip to content

Conversation

@kianenigma
Copy link
Contributor

That can re-instate them in the bags-list pallet

Identified by https://github.com/paritytech-secops/srlabs_findings/issues/559

While no severe consequence, this bug could cause non-validator and non-nominator stakers to retain a spot in the bags-list pallet, preventing other legit nominators/validators from taking their place.

Note that previously, this was not a possibility, because staking would always issue a T::VoterList::on_remove when someone chills, ensuring they are removed from the list. Moreover, an older version of pallet_bags_list::Pallet::rebag didn't allow new nodes to be added, only the score of existing nodes to be adjusted.

But, in recent versions of bags-list, we added a Lock ability that would block any changes to the bags list (during the election snapshot phase). This also had us update the rebag transaction to add or remove nodes from the list, which opened the door to this issue.

@kianenigma kianenigma requested a review from a team as a code owner October 3, 2025 13:37
@kianenigma kianenigma added the T2-pallets This PR/Issue is related to a particular pallet. label Oct 3, 2025
@sigurpol sigurpol self-requested a review October 3, 2025 13:40
@kianenigma kianenigma added the A4-backport-unstable2507 Pull request must be backported to the unstable2507 release branch label Oct 8, 2025
Copy link
Contributor

@sigurpol sigurpol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@sigurpol
Copy link
Contributor

sigurpol commented Oct 8, 2025

@kianenigma changes look good. Assuming we want this fix to be part of KAH RU 1.9.2, which branch should we target? Same for next WAH RU... we used to backport to 2509, what about now that stable2509 is ready to go?

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/18339057139
Failed job name: run-frame-omni-bencher

@kianenigma kianenigma changed the title Staking-Async Chill stakers should not have a score Staking-Async: Chill stakers should not have a score Oct 8, 2025
@kianenigma kianenigma added the A4-backport-stable2509 Pull request must be backported to the stable2509 release branch label Oct 8, 2025
kianenigma and others added 8 commits October 8, 2025 11:15
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: Paolo La Camera <paolo@parity.io>
@kianenigma kianenigma requested a review from andreitrand October 8, 2025 10:19
@kianenigma
Copy link
Contributor Author

/cmd prdoc --bump patch

fn score(who: &T::AccountId) -> Option<Self::Score> {
Self::ledger(Stash(who.clone()))
.map(|l| l.active)
.ok()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one question here: before this change, the second map (i.e. .map(|a| ...) would receive a struct with the type of l.active whereas after this change it will receive an option struct with the internal type of l.active. Why does this not affect the T::CurrencyToVote::to_vote(...) call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This because we want to use and_then here, which works better if you already pass it an Option, and it mutates it either into Some(_) or None, contrary to map which can only mutate the Option into a different Some(_) value.

This is a text-book example of when you use and_then vs. map.

Why does this not affect the T::CurrencyToVote::to_vote(...) call?

The final map, both in the previous code and now, receives a l.active, not an Option<_>.

Compare the type of F in

https://doc.rust-lang.org/std/option/enum.Option.html#method.and_then
and
https://doc.rust-lang.org/std/option/enum.Option.html#method.map

Final note: this type of error that you are trying to prevent me from is impossible in Rust, the compiler would never allow me to pass Option<X> to a function instead of X :)

@kianenigma kianenigma added this pull request to the merge queue Oct 8, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 8, 2025
@sigurpol sigurpol added this pull request to the merge queue Oct 8, 2025
Merged via the queue into master with commit 92118ec Oct 8, 2025
253 of 255 checks passed
@sigurpol sigurpol deleted the kiz-score-provider branch October 8, 2025 19:04
paritytech-release-backport-bot bot pushed a commit that referenced this pull request Oct 8, 2025
That can re-instate them in the bags-list pallet

Identified by
https://github.com/paritytech-secops/srlabs_findings/issues/559

While no severe consequence, this bug could cause non-validator and
non-nominator stakers to retain a spot in the bags-list pallet,
preventing other legit nominators/validators from taking their place.

Note that previously, this was not a possibility, because `staking`
would always issue a `T::VoterList::on_remove` when someone `chill`s,
ensuring they are removed from the list. Moreover, an older version of
`pallet_bags_list::Pallet::rebag` didn't allow new nodes to be added,
only the score of existing nodes to be adjusted.

But, in recent versions of `bags-list`, we added a `Lock` ability that
would block any changes to the bags list (during the election snapshot
phase). This also had us update the `rebag` transaction to add or remove
nodes from the list, which opened the door to this issue.

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 92118ec)
@paritytech-release-backport-bot

Successfully created backport PR for unstable2507:

paritytech-release-backport-bot bot pushed a commit that referenced this pull request Oct 8, 2025
That can re-instate them in the bags-list pallet

Identified by
https://github.com/paritytech-secops/srlabs_findings/issues/559

While no severe consequence, this bug could cause non-validator and
non-nominator stakers to retain a spot in the bags-list pallet,
preventing other legit nominators/validators from taking their place.

Note that previously, this was not a possibility, because `staking`
would always issue a `T::VoterList::on_remove` when someone `chill`s,
ensuring they are removed from the list. Moreover, an older version of
`pallet_bags_list::Pallet::rebag` didn't allow new nodes to be added,
only the score of existing nodes to be adjusted.

But, in recent versions of `bags-list`, we added a `Lock` ability that
would block any changes to the bags list (during the election snapshot
phase). This also had us update the `rebag` transaction to add or remove
nodes from the list, which opened the door to this issue.

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
(cherry picked from commit 92118ec)
@paritytech-release-backport-bot

Successfully created backport PR for stable2509:

kianenigma added a commit that referenced this pull request Oct 9, 2025
Backport #9926 into `stable2509` from kianenigma.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
kianenigma added a commit that referenced this pull request Oct 10, 2025
Backport #9926 into `unstable2507` from kianenigma.

See the
[documentation](https://github.com/paritytech/polkadot-sdk/blob/master/docs/BACKPORT.md)
on how to use this bot.

<!--
  # To be used by other automation, do not modify:
  original-pr-number: #${pull_number}
-->

Co-authored-by: Kian Paimani <5588131+kianenigma@users.noreply.github.com>
Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
fellowship-merge-bot bot pushed a commit to polkadot-fellows/runtimes that referenced this pull request Oct 14, 2025
alvicsam pushed a commit that referenced this pull request Oct 17, 2025
That can re-instate them in the bags-list pallet

Identified by
https://github.com/paritytech-secops/srlabs_findings/issues/559

While no severe consequence, this bug could cause non-validator and
non-nominator stakers to retain a spot in the bags-list pallet,
preventing other legit nominators/validators from taking their place.

Note that previously, this was not a possibility, because `staking`
would always issue a `T::VoterList::on_remove` when someone `chill`s,
ensuring they are removed from the list. Moreover, an older version of
`pallet_bags_list::Pallet::rebag` didn't allow new nodes to be added,
only the score of existing nodes to be adjusted.

But, in recent versions of `bags-list`, we added a `Lock` ability that
would block any changes to the bags list (during the election snapshot
phase). This also had us update the `rebag` transaction to add or remove
nodes from the list, which opened the door to this issue.

---------

Co-authored-by: Paolo La Camera <paolo@parity.io>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A4-backport-stable2509 Pull request must be backported to the stable2509 release branch A4-backport-unstable2507 Pull request must be backported to the unstable2507 release branch T2-pallets This PR/Issue is related to a particular pallet.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants