In Base struct having 3 separate fields that map from _protocol is error-prone. If you later introduce new fields, etc, you need not forget to delete them in function protocolRemove, etc. I think it would be better to have a separate struct for protocol-related data and map to that.
Recommended Mitigation Steps
An example solution, replace:
mapping(bytes32 => address) protocolManagers;
mapping(bytes32 => address) protocolAgents;
mapping(bytes32 => bool) protocolIsCovered;
with:
struct ProtocolInfo {
address manager;
address agent;
bool covered;
}
struct Base {
...
mapping(bytes32 => ProtocolInfo) protocolInfo;
...
}
Then you can delete all fields this way: delete gs.protocolInfo[_protocol]; Similar solution may be applied to PoolStorage (protocolBalance, protocolPremium, isProtocol).
Handle
pauliax
Vulnerability details
Impact
In Base struct having 3 separate fields that map from _protocol is error-prone. If you later introduce new fields, etc, you need not forget to delete them in function protocolRemove, etc. I think it would be better to have a separate struct for protocol-related data and map to that.
Recommended Mitigation Steps
An example solution, replace: mapping(bytes32 => address) protocolManagers; mapping(bytes32 => address) protocolAgents; mapping(bytes32 => bool) protocolIsCovered; with: struct ProtocolInfo { address manager; address agent; bool covered; } struct Base { ... mapping(bytes32 => ProtocolInfo) protocolInfo; ... } Then you can delete all fields this way: delete gs.protocolInfo[_protocol]; Similar solution may be applied to PoolStorage (protocolBalance, protocolPremium, isProtocol).