Skip to content
Snippets Groups Projects
Commit e46d711b authored by Éloïs's avatar Éloïs
Browse files

fix (security): filtered calls should not enter the tx pool.

parent 77a8d0bb
No related branches found
No related tags found
No related merge requests found
...@@ -129,6 +129,11 @@ macro_rules! runtime_apis { ...@@ -129,6 +129,11 @@ macro_rules! runtime_apis {
tx: <Block as BlockT>::Extrinsic, tx: <Block as BlockT>::Extrinsic,
block_hash: <Block as BlockT>::Hash, block_hash: <Block as BlockT>::Hash,
) -> TransactionValidity { ) -> TransactionValidity {
// Filtered calls should not enter the tx pool.
if !<Runtime as frame_system::Config>::BaseCallFilter::contains(&tx.function)
{
return sp_runtime::transaction_validity::InvalidTransaction::Call.into();
}
Executive::validate_transaction(source, tx, block_hash) Executive::validate_transaction(source, tx, block_hash)
} }
} }
......
...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; ...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{KeyTypeId, Perbill, Permill}; pub use sp_runtime::{KeyTypeId, Perbill, Permill};
use common_runtime::IdtyNameValidatorImpl; use common_runtime::IdtyNameValidatorImpl;
use frame_support::traits::Contains;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -121,7 +122,7 @@ pub type Executive = frame_executive::Executive< ...@@ -121,7 +122,7 @@ pub type Executive = frame_executive::Executive<
>; >;
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl frame_support::traits::Contains<Call> for BaseCallFilter { impl Contains<Call> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &Call) -> bool {
!matches!( !matches!(
call, call,
......
...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; ...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{KeyTypeId, Perbill, Permill}; pub use sp_runtime::{KeyTypeId, Perbill, Permill};
use common_runtime::IdtyNameValidatorImpl; use common_runtime::IdtyNameValidatorImpl;
use frame_support::traits::Contains;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -123,7 +124,7 @@ pub type Executive = frame_executive::Executive< ...@@ -123,7 +124,7 @@ pub type Executive = frame_executive::Executive<
>; >;
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl frame_support::traits::Contains<Call> for BaseCallFilter { impl Contains<Call> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &Call) -> bool {
!matches!( !matches!(
call, call,
......
...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage; ...@@ -41,6 +41,7 @@ pub use sp_runtime::BuildStorage;
pub use sp_runtime::{KeyTypeId, Perbill, Permill}; pub use sp_runtime::{KeyTypeId, Perbill, Permill};
use common_runtime::IdtyNameValidatorImpl; use common_runtime::IdtyNameValidatorImpl;
use frame_support::traits::Contains;
use frame_system::EnsureRoot; use frame_system::EnsureRoot;
use pallet_grandpa::fg_primitives; use pallet_grandpa::fg_primitives;
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList}; use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
...@@ -122,7 +123,7 @@ pub type Executive = frame_executive::Executive< ...@@ -122,7 +123,7 @@ pub type Executive = frame_executive::Executive<
>; >;
pub struct BaseCallFilter; pub struct BaseCallFilter;
impl frame_support::traits::Contains<Call> for BaseCallFilter { impl Contains<Call> for BaseCallFilter {
fn contains(call: &Call) -> bool { fn contains(call: &Call) -> bool {
!matches!( !matches!(
call, call,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment