Open sebastianmontero opened 9 months ago
I think we should have a single structure for the application fields, where the custodian fields are optional, this would restrict the possibility of calling the extrinsic with an invalid configuration of fields.
[High] Reachable panic via
index out of bounds
ingated-marketplace
palletSummary
An
index out of bounds
panic can be triggered by a malicious actor calling an extrinsic in thegated-marketplace
pallet.Issue details
The set_up_application helper function can be called with input such that
fields.len() > custodian_fields.as_ref().unwrap().1.len()
-- for example, if there are elements infields
but not incustodian_fields.1
.In such cases, the function will try to access a non-existent index in
custodian_fields.1
, throwing an index out of bounds exception. This causes the runtime to panic and could potentially cause a deny-of-service of the chain.The helper function is directly reachable from the following extrinsics:
For example here:
Risk
Since this can be triggered by a call to an extrinsic, an attacker could cause a validator node to crash by submitting a specific crafted extrinsic and cause them to miss their block authoring slot. This could lead to a denial-of-service of the whole chain with only very low cost requirements for the attacker.
Mitigation
Validate the arguments prior to calling
set_up_application
, e.g., ensure thatcustodian_fields.as_ref().unwrap().1.len() == fields.len()
holds before calling the function. Note that this change needs to be applied everywhereset_up_application
is called. Alternatively, modifyset_up_application
to gracefully handle errors.