-
Notifications
You must be signed in to change notification settings - Fork 571
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
App running +rwx code at DR injection time crashes #5198
Comments
Failure up front in every app usually points at incompatibilities with security software injecting code into every process. |
Interesting - I disabled SEP from the tray and also ran |
I installed a new Win 10 Pro x64 VM, clean install, barely installed any software on it, disabled Windows Defender protection - and I'm still getting the same crash. This time the debug output doesn't contain those messages:
I thought maybe the TestExe project had some non-standard flags or something, so I created a new clean project, added a single Main.c file with this code:
It crashes just the same, with this similar albeit slightly different debug output:
|
Hmm.
|
Yes, no crash.
Will check tomorrow. Any specific version to check with?
No, it crashes - same crash (dll and offset), only this time the crash is in create_process.exe instead of my exe.
Same crash.
|
Tried it with other versions as well (DynamoRIO-Windows-8.0.18929.zip, DynamoRIO-Windows-8.0.18816.zip), same result (same crash). |
From the log file, DR injects and the app code it starts with is this non-library generated code:
That code calls LdrGetDllHandleByName and sets the output param to point to an address in the same allocation as its code, 0x00000272bb350008:
That's what crashes, as you said:
Normally, DR's initial app code for default options (-early_inject_location == INJECT_LOCATION_ThreadStart) is RtlUserThreadStart. It gets the target through a few methods but it starts with NtGetContextThread. Sometimes DR has to hook to take over, though it prefers calling NtSetContextThread. Its hook restore code is always run, though, and that blindly sets the target location to +rx. So it looks like you have something in these apps that is inserting generated code mixed with data that must be writable and executable, and DR is marking that code non-writable, and it then crashes trying to write. Looking at the loaded libraries: probably it is apphelp.dll with some compatibility layer? And that's why other people have not hit this problem and it is limited to certain machines and certain apps? If you run A proposed fix is to add the prior page prot bits to |
Running with |
Could you test with #5203? |
Can you provide me with a compiled package, or instruct me how to build it myself? |
https://github.com/DynamoRIO/dynamorio/releases/tag/cronbuild-8.0.18942-1 |
That solved my crash :) |
Thank you for testing the fix |
Updates DR to 3b4d7485 which fixes DynamoRIO/dynamorio#4958, eliminating basic blocks coming from the DR library. This also pulls in a fix for an injection crash from app compatibility layers: DynamoRIO/dynamorio#5198. Removes the workaround in the umbra_client_insert_app_to_shadow test that is now no longer needed. Issue: DynamoRIO/dynamorio#4958, DynamoRIO/dynamorio#5198
Describe the bug
I tried running my code with winafl and DynamoRIO in several ways (including both drrun.exe and afl-fuzz.exe), all failed with c0000005 (access violation). I saw it recommended somewhere to run with drrun.exe but without winafl, to see if that works, and that also gives an access violation, even when I removed everything from my test exe and left just "return 0":
C:\Code\MyResearch\DynamoRIO-Windows-8.0.18936\bin64\drrun.exe -- C:\Code\Test\TestExe\x64\Release\TestExe.exe
I can see the crash in windows' event log, brought below.
I also tried to check where that offset in ntdll is, and got to LdrGetDllHandleByName - the exception is when it tries to write to its out param.
To Reproduce
C:\Code\MyResearch\DynamoRIO-Windows-8.0.18936\bin64\drrun.exe -- C:\Code\Test\TestExe\x64\Release\TestExe.exe
TestExe.exe is a 64-bit exe compiled in Release with Visual Studio 2019 16.11.5, which contains a _tmain function that only returns 0.
Running TestExe.exe directly doesn't crash.
Running with -debug still crashes, see output below.
Expected behavior
Don't crash.
Screenshots or Pasted Text
In eventvwr (Windows Logs > Application), I can see:
And also:
Output of running with debug:
Versions
Using latest DynamoRIO release (DynamoRIO-Windows-8.0.18936.zip), Windows 10 21H1 (OS build 19043.1320). 64-bit versions for everything.
Additional context
I have SEP, but even when I disabled it - the crash still happened.
The text was updated successfully, but these errors were encountered: