|
|
|
|
|
by IvyMike
4067 days ago
|
|
I think DasIch is saying "why allow file(1) to open sockets, write to arbitrary files, and run external programs"? Given the correct input, at least a month ago, it could do all of those things. (I am not sure that attempting to enforce this within the file(1) binary is optimal... after all, even though the attack surface is much reduced, file(1) could still have a bug somewhere prior to the sandboxing. If you could do a "chpriv -write_to_disk -socket -run_external_program /bin/file" that the OS would enforce, that would be cool. Someone should create that.) |
|
If by "open sockets" you mean open existing sockets in read-only mode, it's so that it can identify them as sockets. If by "open sockets" you mean create new sockets, I don't think it does do that:
https://github.com/threatstack/libmagic/search?utf8=%E2%9C%9...
> write to arbitrary files
It appears it only does this if running on OS/2 and investigating what's inside a compressed file. Under these conditions, a temporary file is necessary for platform-specific reasons:
https://github.com/threatstack/libmagic/blob/3dea7072b8d7e92...
https://github.com/threatstack/libmagic/blob/3dea7072b8d7e92...
It also writes to a non-arbitrary mmapped file (the magic database), because that's how such databases work; you query them by writing to them in a particular way:
https://github.com/threatstack/libmagic/blob/3dea7072b8d7e92...
> run external programs
I can't find any examples where it does that. Do you know of any?