Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Ensure a bad datastream cannot cause problems #701

Merged
merged 3 commits into from
Oct 27, 2021
Merged

Conversation

gavofyork
Copy link
Member

No description provided.

@KiChjang KiChjang requested a review from bkchr October 27, 2021 11:26
@gavofyork
Copy link
Member Author

(Approved by auditors.)

@gavofyork gavofyork merged commit 0793aa8 into master Oct 27, 2021
@gavofyork gavofyork deleted the gav-audit146 branch October 27, 2021 11:40
gavofyork added a commit that referenced this pull request Oct 27, 2021
* Ensure a bad datastream cannot cause problems

* Formatting

* Formatting
@JoshOrndorff
Copy link
Contributor

Maybe a dumb question, but what's the practical difference. The only change my eye can spot is changing an if let to a match that only matches on the same one case.

@4meta5
Copy link
Contributor

4meta5 commented Oct 27, 2021

The Ok arm of the match statement added another condition as well if remaining_fragments.len() < last_remaining_fragments.len() -- this line

apopiak pushed a commit that referenced this pull request Nov 3, 2021
* Ensure a bad datastream cannot cause problems

* Formatting

* Formatting
bkchr pushed a commit that referenced this pull request Nov 3, 2021
* Ensure a bad datastream cannot cause problems (#701)

* Ensure a bad datastream cannot cause problems

* Formatting

* Formatting

* formatting

Co-authored-by: Gavin Wood <gavin@parity.io>
apopiak added a commit that referenced this pull request Nov 8, 2021
* Update references

* update deps

* set substrate deps for pallet-asset-tx-payment

* add DisabledValidatorsThreshold to parachain template

* add DisabledValidatorsThreshold to statemint runtimes

* adjust imports

* update Cargo-lock

* add DisabledValidatorsThreshold to mock config

* cargo +nightly fmt

* adjust on_disabled type

* remove on_chain_votes function in ParachainHost impl

* remove ScrapedOnChainVotes

* bump polkadot-collator version

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* update Cargo.lock

* set spec_versions to 500

* Statemine cannot execute.

* disallow XCM execute on statemint

* cargo fmt

* remove unnecessary dep on node-primitives

* select parachains-common/std feature when building rococo-runtime with std

* adjust Statemint to the three digit spec_version format

* Add script to generate simple changelogs (#668)

* Update weights from v4 for v5 comparison (#673)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* Fix benchmarks after Parachain Template (#677)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* benchmarks fix for parachain template

* Weights updates for Statemine v5 (#682)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* weights updates for statemine v5

* mention Storage in construct_runtime macro for pallet-xcm (#680)

* Use pallet-xcm for version wrapping (#689)

* use PolkadotXcm for XcmRouter WrapVersion

* use PolkadotXcm for version wrapping

Co-authored-by: Bryan Chen <xlchen1291@gmail.com>

* patch weight for batch_all from rerun

* Runtime version bump to v503 (#694)

* adjust genesis value generation scripts to output entries array + add script to derive encoded call

* add script to generate shell spec from runtime wasm

* Ensure a bad datastream cannot cause problems (#701)

* Ensure a bad datastream cannot cause problems

* Formatting

* Formatting

* update Polkadot (to 0.9.11 169bab55d)

* bump spec versions

* Allow Queries and Subscriptions

Fixes

Formatting

* fix build

* make fmt happy

* statemint imports

* slight naming changes in script

* add shell genesis data + wasm + chainspec

* adjust generated shell spec with production config values

* update Substrate and Polkadot to master

* fix deps

* swap out bootnodes for statemint shell

* add a script for verifying the shell chain spec

* add sha checksum for head data

* remove verification script

* remove hex wasm file

* update Substrate and Polkadot again and fix compilation

* update and fix lock file

* formatting

* remove redundant dispatch_as weight

Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: Gav Wood <gavin@parity.io>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Bryan Chen <xlchen1291@gmail.com>
Co-authored-by: joepetrowski <joe@parity.io>
chevdor added a commit that referenced this pull request Nov 11, 2021
* disable permissionless asset creation for Statemint (#669)

* disable permissionless asset creation for Statemint

* Companion for polkadot#3728 (#693)

* Update mock runtime API

* update Polkadot packages

Co-authored-by: joao-paulo-parity <joao-paulo@parity.io>

* Ensure a bad datastream cannot cause problems (#701)

* Allow Queries and Subscriptions (#700)

* Bump syn to 1.0.81 (#707)

* Update Substrate & Polkadot (#709)

* Udpate polkadot substrate (#713)

* fmt with latest nightly

* Bump subwasm version (#716)

* Companion for `dispatch_as` (#715)

* dispatch as companion

* Upstream Statemine Release v5 Changes to Master (#720)

* set substrate deps for pallet-asset-tx-payment

* add DisabledValidatorsThreshold to parachain template

* add DisabledValidatorsThreshold to mock config

* adjust on_disabled type

* remove on_chain_votes function in ParachainHost impl

* remove ScrapedOnChainVotes

* bump polkadot-collator version

Co-authored-by: Chevdor <chevdor@users.noreply.github.com>

* set spec_versions to 500

* Statemine cannot execute.

* disallow XCM execute on statemint

* remove unnecessary dep on node-primitives

* select parachains-common/std feature when building rococo-runtime with std

* adjust Statemint to the three digit spec_version format

* Add script to generate simple changelogs (#668)

* Update weights from v4 for v5 comparison (#673)

* updates weights

* pallet_unique benchmarks added + weights upstream from v4

* Fix benchmarks after Parachain Template (#677)

* pallet_unique benchmarks added + weights upstream from v4

* benchmarks fix for parachain template

* Weights updates for Statemine v5 (#682)

* pallet_unique benchmarks added + weights upstream from v4

* weights updates for statemine v5

* mention Storage in construct_runtime macro for pallet-xcm (#680)

* Use pallet-xcm for version wrapping (#689)

* use PolkadotXcm for XcmRouter WrapVersion

* use PolkadotXcm for version wrapping

Co-authored-by: Bryan Chen <xlchen1291@gmail.com>

* patch weight for batch_all from rerun

* Runtime version bump to v503 (#694)

* adjust genesis value generation scripts to output entries array + add script to derive encoded call

* add script to generate shell spec from runtime wasm

* Ensure a bad datastream cannot cause problems (#701)

* Ensure a bad datastream cannot cause problems

* update Polkadot (to 0.9.11 169bab55d)

* bump spec versions

* Allow Queries and Subscriptions

* statemint imports

* slight naming changes in script

* add shell genesis data + wasm + chainspec

* adjust generated shell spec with production config values

* update Substrate and Polkadot to master

* swap out bootnodes for statemint shell

* add a script for verifying the shell chain spec

* add sha checksum for head data

* remove verification script

* remove hex wasm file

* update Substrate and Polkadot again and fix compilation

* remove redundant dispatch_as weight

Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: Chevdor <chevdor@users.noreply.github.com>
Co-authored-by: Gav Wood <gavin@parity.io>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Bryan Chen <xlchen1291@gmail.com>
Co-authored-by: joepetrowski <joe@parity.io>

* Rework the runtime upgrade test (#727)

* Rework the runtime upgrade test

* Update test/service/tests/runtime_upgrade.rs

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>

* Remove randomness collective flip new (#726)

* randomess collective flip removed

* remove migration for statemint

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>

* adjust XCM unit weights to 1B (#735)

* Align Call Indices between Westmint and Statemint (#731)

* align construct_runtime calls between statemint runtimes

* bump westmint transaction_version

* bump spec_version (#733)

* point back to Polkadot 0.9.12

* adjust code to work with 0.9.12 again

* adjust network test back to polkadot 0.9.12

* Align the Statemint Runtimes  (#736)

* align the different Statemint runtimes so they are more similar in structure

* align Unpaid Execution filter

* revert changes to Unpaid execution filter for Westmint

* Bump spec versions (#742)

Co-authored-by: Alexander Popiak <alexander.popiak@parity.io>
Co-authored-by: Chris Sosnin <48099298+slumber@users.noreply.github.com>
Co-authored-by: joao-paulo-parity <joao-paulo@parity.io>
Co-authored-by: Gavin Wood <gavin@parity.io>
Co-authored-by: Keith Yeung <kungfukeith11@gmail.com>
Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
Co-authored-by: Guillaume Thiolliere <gui.thiolliere@gmail.com>
Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Bastian Köcher <info@kchr.de>
Co-authored-by: Ignacio Palacios <ignacio.palacios.santos@gmail.com>
Co-authored-by: Bryan Chen <xlchen1291@gmail.com>
Co-authored-by: joepetrowski <joe@parity.io>
@chevdor chevdor added the T6-XCM This PR/Issue is related to XCM. label Nov 22, 2021
bkchr added a commit that referenced this pull request Jan 5, 2022
With #701 we tried to fix some infinite loop related to encoded blobs, however that lead actually to
not being able to process encoded blobs at all. The reason for this is that `decode_all` doesn't
consume the given input. The point of this function is that it returns an error if the data couldn't
be decoded or there is still data left. However, this means that the check
`remaining_fragments.len() < last_remaining_fragments.len()` would always fail.

We remove the while loop, because we decode the entire fragment anyway or it fails. Aka, we don't
need to loop here. Next we remove the broken check and we directly reset the
`remaining_fragments` (because `decode_all` doesn't consume anything).
bkchr added a commit that referenced this pull request Jan 19, 2022
* xcmp-queue: Fix handling of encoded blobs

With #701 we tried to fix some infinite loop related to encoded blobs, however that lead actually to
not being able to process encoded blobs at all. The reason for this is that `decode_all` doesn't
consume the given input. The point of this function is that it returns an error if the data couldn't
be decoded or there is still data left. However, this means that the check
`remaining_fragments.len() < last_remaining_fragments.len()` would always fail.

We remove the while loop, because we decode the entire fragment anyway or it fails. Aka, we don't
need to loop here. Next we remove the broken check and we directly reset the
`remaining_fragments` (because `decode_all` doesn't consume anything).

* Restore correct behavior

We need to use a while loop, because there can be multiple `Vec<u8>`s. We also need to use `decode`,
because `decode_all` would otherwise return an error if the input is not empty afterwards.

* Remove unused import
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
T6-XCM This PR/Issue is related to XCM.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants