Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

out-of-bounds reads #8

Closed
totaam opened this issue Jun 3, 2016 · 2 comments
Closed

out-of-bounds reads #8

totaam opened this issue Jun 3, 2016 · 2 comments

Comments

@totaam
Copy link
Contributor

totaam commented Jun 3, 2016

The parsing functions do not check against the end of the buffer, causing out-of-bounds reads.
This can lead to crashes if the operating system checks for this sort of thing, or this can cause memory contents to be leaked to an attacker.
Here's a very simple poc:

from rencode import _rencode as rencode
v = "1024:shortstring"
s = rencode.loads(v)
print("loads(%s)=%s" % (v, s))
@aresch
Copy link
Owner

aresch commented Jun 5, 2016

I am not seeing this problem. The check_pos() https://github.com/aresch/rencode/blob/master/rencode/rencode.pyx#L470
function should handle this and we call it practically everywhere while decoding the byte string.

>>> v = b"1024:shortstring"
>>> s = rencode.loads(v)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/rencode/rencode.pyx", line 546, in rencode._rencode.loads (rencode/rencode.c:7425)
  File "/rencode/rencode.pyx", line 508, in rencode._rencode.decode (rencode/rencode.c:6958)
  File "/rencode/rencode.pyx", line 431, in rencode._rencode.decode_str (rencode/rencode.c:5825)
  File "/rencode/rencode.pyx", line 477, in rencode._rencode.check_pos (rencode/rencode.c:6434)
IndexError: Tried to access data[1028] but data len is: 16

@totaam
Copy link
Contributor Author

totaam commented Jun 6, 2016

Sorry about that, I had somehow reverted to an older version during testing.
This bug is invalid, closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants