-
Notifications
You must be signed in to change notification settings - Fork 221
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
crash due to absurd memory allocation #232
Comments
So first of all I'd like to understand why you think that this sequence of bytes represents a config file? Did this come out of some fuzzying tool? |
Yes, I'm evaluating if it would be reasonable to send users config files from other users in my program. The program is https://github.com/cortex/ripasso/ and it's a password manager, that can be used in a group setting, and having a common config file that is shared between the group would be useful. |
While I understand your usecase... wouldn't it be better if some sync mechanism would do this (think git or syncthing) instead of reinventing the wheel in your program? |
Yes, the transportation layer for the config file would be git in my case. The (highly theoretical) scenario would be if one of the users checked in a config file that would case some sort of problem for the other users, the first users computer could get hacked for example, and I wouldn't want an attacker to be able to move laterally to the other users machines by committing a payload to the config file. I fully realize that this is an extremely hypothetical scenario, but the reason why I use rust is that it's a more language than c/c++. And that's why I have been going over all my dependencies with a fuzzer and reporting the bugs that I have found. A crash due to a large memory allocation isn't really a security problem, at most it would be a DoS, but it's kind of annoying if it happens and would feel like a bug, so I thought that it warranted a bug report at least :) |
It's not a real solution, but if random non-text characters are causing issues, you could try a simple heuristic like https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=d5ca35753f54ac7902c40a571acfa1a9 Is this a problem in |
Hi. Does this issue still exist in later versions of this crate? |
Hi, it seems like that, had to modify the above program slightly to reproduce the issue:
produced this output:
|
So the byte array above is parsed to this expression:
Which is then parsed as a expression indexing That index is then used later to grow the cache for indexing the loaded documents. That is of course an absurd size... I am not sure yet where to fix this (or whether to fix this at all because this is really obscure). 🤔 Still, non-segfaulting software is always better than segfaulting one, of course, so I think we should fix this even for the sake of it. |
One solution for the future could maybe be to use the try_reserve functions from rust-lang/rust#48043 Until that is merged I'm not sure that there is a good way to handle this class of problem, since it's hard to know compile-time how memory constrained the running environment will be. Feel free to close this if you want :) |
Some config file generate an extreme memory allocation when read, that leads to a crash.
Example program that generates the error:
Output:
Stacktrace:
The text was updated successfully, but these errors were encountered: