Detect sun.misc.Unsafe
out of bounds reads and writes
#891
Unanswered
Marcono1234
asked this question in
Q&A
Replies: 1 comment 4 replies
-
Indeed, that would be a useful bug detector / sanitizer! Currently it's not supported but intercepting calls to Docs on how to write custom hooks can be found at https://github.com/CodeIntelligenceTesting/jazzer/blob/main/docs/advanced.md#custom-hooks |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Can Jazzer detect out of bounds reads and writes caused by one of the
sun.misc.Unsafe
methods, such asUnsafe.getByte
?Use case:
Some Java libraries use
Unsafe
for better performance. However, the methods ofUnsafe
allow reading and writing to arbitrary memory addresses without any validation. So if there is a bug in the library (e.g. integer overflow or missing validation) it might read or write data it is not supposed to. If the address is too off, it can trigger anEXCEPTION_ACCESS_VIOLATION
JVM crash, but if the address is still within the memory region of the JVM process it doesn't (?).So I think it would be useful if that could be detected.
It seems Jazzer does not detect that and in case of a JVM crash it also does not save the corpus (?)1, but maybe my setup is wrong. This is my test code (executed using Maven):
For the
Unsafe
methods which take an additionalObject
argument and where that argument is an array I assume validation would be possible. For the other cases I am not sure if / how easy it would be to detect this. I found https://github.com/serkan-ozal/mysafe which seems to go into a similar direction, but I haven't tried it.Footnotes
It just prints "==13516== ERROR: libFuzzer: fuzz target exited" and seems to hang afterwards. Maybe related to Crash only hs_err_pid #666? ↩
Beta Was this translation helpful? Give feedback.
All reactions