[x] I have searched the existing issues and pull requests for duplicates.
Type of Issue
[x] New vulnerability addition
[ ] Feature request
[ ] Update existing vulnerability
Description
Deleting a mapping within a struct
It is a common assumption that deleting struct will delete all of it's data entirely but there is an exception. Deleting structs that contain dynamic data types does not delete the dynamic data. For example: If a mapping (or dynamic array) is inside a struct, and the struct is deleted, the mapping or array will not be deleted. The remaining data may be used to compromise the contract.
Checklist
Type of Issue
Description
Deleting a mapping within a struct
It is a common assumption that deleting
struct
will delete all of it's data entirely but there is an exception. Deleting structs that contain dynamic data types does not delete the dynamic data. For example: If amapping
(or dynamic array) is inside a struct, and the struct is deleted, the mapping or array will not be deleted. The remaining data may be used to compromise the contract.remove()
function above deletes an item ofstackBalance
. The mappingbalances
is never deleted, so remove does not work as intended.Sources