From f448b6fb24349f7a46094c324bc5736075a6059f Mon Sep 17 00:00:00 2001 From: Maurice <49980222+l4yton@users.noreply.github.com> Date: Sat, 23 Mar 2024 18:31:07 +0100 Subject: [PATCH] libafl_nyx: Add bounds check for Nyx input buffer (#1963) --- libafl_nyx/src/executor.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libafl_nyx/src/executor.rs b/libafl_nyx/src/executor.rs index 6cea8c8d46..83689fcb84 100644 --- a/libafl_nyx/src/executor.rs +++ b/libafl_nyx/src/executor.rs @@ -55,6 +55,16 @@ where let bytes = input.target_bytes(); let buffer = bytes.as_slice(); + + if buffer.len() > self.helper.nyx_process.input_buffer_size() { + return Err(Error::illegal_state(format!( + "Input does not fit in the Nyx input buffer.\ + You may want to increase the Nyx input buffer size: {} > {}", + buffer.len(), + self.helper.nyx_process.input_buffer_size() + ))); + } + let size = u32::try_from(buffer.len()) .map_err(|_| Error::unsupported("Inputs larger than 4GB are not supported"))?;