Input values are not sanitized after they are deserialized, making it far too easy for Leo to earn SOL (#9706)
* sanitize gossip protocol messages * sanitize transactions * crds protocol sanitize
This commit is contained in:
committed by
GitHub
parent
c372a39dd3
commit
8ef097bf6f
21
sdk/src/sanitize.rs
Normal file
21
sdk/src/sanitize.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub enum SanitizeError {
|
||||
Failed,
|
||||
IndexOutOfBounds,
|
||||
ValueOutOfRange,
|
||||
}
|
||||
|
||||
pub trait Sanitize {
|
||||
fn sanitize(&self) -> Result<(), SanitizeError> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Sanitize> Sanitize for Vec<T> {
|
||||
fn sanitize(&self) -> Result<(), SanitizeError> {
|
||||
for x in self.iter() {
|
||||
x.sanitize()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user