-
-
Notifications
You must be signed in to change notification settings - Fork 363
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
Refactor how ASLR and implement rz_sys_execv using RzSubprocess #4202
Conversation
@gogo2464 if you want to try this on windows, it could be useful. |
081b93e
to
c71b76c
Compare
i'm currently testing this on windows. |
bf7f92a
to
2e79a43
Compare
2e79a43
to
3ab2c4d
Compare
So i have tested this extensively on windows and you cannot disable ASLR programmatically, only enable it. |
This makes perfect sense from the security PoV. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It breaks one unit test on Windows:
|
This comment was marked as resolved.
This comment was marked as resolved.
does |
Is |
only for the current process, check: Line 762 in d86e8ae
|
on windows no and never will. RZ_LOG_ERROR("On Windows, ASLR mitigation policies cannot be made less restrictive if they are already enabled.\n");
RZ_LOG_ERROR("It is possible to disable ASLR by modifying the PE header and removing the following flags:\n");
RZ_LOG_ERROR("- IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE\n");
RZ_LOG_ERROR("- IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA.\n");
RZ_LOG_ERROR("Or as Administrator from PowerShell by running: `Set-ProcessMitigation -Name file.exe -Disable ForceRelocateImages`\n"); |
it is supposed to be used for spawning processes with aslr or not. |
Then the FreeBSD case is wrong. Changing sysctl is global and affects all processes that are started after the switch. On FreeBSD it is possible to do |
might we consider patching the PEB for disabling aslr? |
I'd say it makes sense, because it follows all other plaforms except Linux and MacOS for which it is possible to set ASLR state on the program startup. |
or you can use the procctl api with PROC_ASLR_CTL. |
Your checklist for this pull request
Detailed description
Refactors the code and moves the code into the same function.
Adds support to windows via
SetProcessMitigationPolicy
but works only when ASLR is disable and we want to enable it.Also now on linux we try to disable ASLR programmatically using the
personality
function instead of OS wide which works also when the user is not root.These changes also implements non-native
rz_sys_execv
by usingRzSubprocess
.Test plan
Unfortunately this cannot be tested easily in the regression suite.
gcc example.c
noaslr.rz
:Then run
rz-run noaslr.rz
multiple times.If the value output is the same then ASLR is correctly disabled.
Closing issues
Fix #4147