-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Modify the UID and GIDs of fuzzing target #2462
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
Conversation
src/afl-fuzz-init.c
Outdated
|
||
PFATAL("Unable to create '%s'", afl->sync_dir); | ||
|
||
} | ||
|
||
if (mkdir(afl->out_dir, 0700)) { | ||
printf("out_dir = %s\n", afl->out_dir); |
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.
that is a debug printf I guess?
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.
Indeed, I forgot this one. I will remove it next commit.
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.
still waiting for that ... :)
Looks like a niche issue but it does not hurt, so why not :-) |
I've tested this behavior and it's working. The code uses two variables for handling the uid : the actual value and one boolean that indicates when the uid value is meaningful. Thus, the default value 0 can be used as any other value. I have done this for clarity purpose. I can use only one variable if you prefer. I'm currently working on patching the code for the docker image (the failing CI checks). |
I think you only need to fix utils/afl_network_proxy . |
I have fixed the docker build but I don't manage to setup a working afl server and client (even on the stable branch) so I haven't checked that the UID/GID modification works in that case. I have also removed the debug |
Thank you! |
Hello,
This commit adds two new environment variables (
AFL_FORKSRV_UID
andAFL_FORKSRV_GID
) that allow, when running the target using the fork server, to use specific user and group IDs.Example of Linux session:
Under the hood, the fork server calls
setregid
,setgroups
andsetreuid
right before launching the target usingexecv
. Unfortunately when the UID and GIDs of afl-fuzz and the forkserver are different, the communication between them is faulty: files and shared memory have default permission rights set to 600 and UID/GID set to the ones of afl-fuzz. When only the GID is modified this isn't problematic (access granted using the common UID) but when the UID is modified we need to set permission rights to 660 so the fork server can access entities using the common group ID. In case both are modified, we even need to change the group ownership of the entities so afl-buzz binary can access them using its UID and the fork server using its GID.This new ownership scheme constitutes the most of the commit since the default permission and the potential new group has to be passed to all function creating communication entities (files and shared memory). I have modified the creation of the entities related to the forkserver and left the other one intact but I might have missed cases and thus I think a review by an experimented AFL developer is required.
Finally, I have used the constructions shown bellow several times. If there's macro more handy that automatically deals with errno please tell me so I can improve the code.
Thank you very much,
Pierre Graux