RyanSkraba commented on code in PR #3861:
URL: https://github.com/apache/avro/pull/3861#discussion_r3610597907
##########
lang/py/avro/io.py:
##########
@@ -393,12 +459,28 @@ def skip_double(self) -> None:
self.skip(8)
def skip_bytes(self) -> None:
- self.skip(self.read_long())
+ # The length prefix is attacker-controlled: a negative value would seek
+ # backwards (corrupting the decoder position, e.g. an infinite loop
+ # during schema resolution) and an oversized value past EOF. Validate
it
+ # the same way ``read`` does before skipping.
+ n = self.read_long()
+ if n < 0:
+ raise avro.errors.InvalidAvroBinaryEncoding(f"Requested {n} bytes
to skip, expected positive integer.")
Review Comment:
Redundant with skip(n) also checking negative bytes -- remove or align error
messages?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]