4 ms·
I think the even crazier thing is Windows having a function to allocate memory in another process (https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/
by rwmj 5y ago
I think the even crazier thing is Windows having a function to allocate memory in another process (https://docs.microsoft.com/en-us/windows/win32/api/memoryapi/nf-memoryapi-virtualallocex https://docs.microsoft.com/en-us/windows/win32/api/memoryapi...). That seems like a potential source for all kinds of impossible to track bugs.
> The customer is a major anti-virus software vendor! The customer has important functionality in their product that that they have built based on this technique of remote code injection, and they cannot afford to give it up at this point.
Oh now it makes sense.
- jrtc27 5y agoYou can allocate memory in another process on Unix too: use ptrace to make the other process call malloc (use PTRACE_SETREGS to set PC to malloc and the first argument register to the number of bytes, then intercept the return). GDB will use this if you tell it something like `p foo("bar")`, as it needs to allocate memory for that string somewhere.
- watermelon0 5y agoWhat would be the use case of AV software needing to perform remote code injection?
- rwmj 5y agoThere's barely a case for AV software existing at all. It's the root cause for all kinds of impossible to track bugs and performance regressions.
- DarkWiiPlayer 5y agoThe best kind of antivirus is the one that stays quiet unless you specifically ask it to scan a file. Did someone say Clam AV just now?
- Darvon 5y agoWhy did you download an executable that you don't trust? Don't even scan it, just delete it and go find one you do trust.
- fennecfoxen 5y agoTrust, but verify.
- deleted 5y ago[deleted]
- sebazzz 5y agoCries in Symantec Endpoint Protection with "file access scans" turned on, compiling a fairly average .NET solution
- Diggsey 5y agoInjecting code into another process is well supported :P 1) VirtualAllocEx some memory to hold the path to a DLL you want to inject. 2) WriteProcessMemory to write the path to that memory. 3) CreateRemoteThread passing in the address of `LoadLibrary` and the pointer to the previously allocated memory. It's no coincidence that `LoadLibrary` has a signature which can directly be passed to `CreateRemoteThread`!
- codedokode 5y agoIsn't this a way to introduce bugs? For example: - injected DLL can change some process-related settings and break main program - injected DLL can call non-reenterable function from a system library simultaneously with main program
- bmm6o 5y agoNo need to go that far. If you allow an untrusted process to write to your memory, you've already lost. One thing I haven't seen called out yet is that there is security associated with this API call - ordinary users can only call this on processes that they own. (And as far as the terminology, these aren't "bugs" since they aren't defects in the software.)
- barchar 5y agoI mean sure. If you can do this you can debug the process (how do you think debuggers are implemented?) and ofc once you're debugging a process you can introduce bugs and cause random havoc. Linux can do this too with ptrace. And mac has something similar I'm sure, you gotta be able to debug. Now, the target process can implement countermeasures against you, that's what anti-debug is, but it's impossible in the general case to defend yourself against a debugger with the same privilege level as you. (it is an arms race though, so sometimes it's easiest to resort to kernel-mode anti-anti-debug techniques even against pure user-mode anti-debug. If you do that you need to disable KPP, and you can't disable KPP in the supported way because the supported way is to attach a kernel debugger to the kernel, which will make it obvious that someone is debugging!)
- asveikau 5y ago
- CodeArtisan 5y agoCode injection is common in video gaming, it is used by the Steam overlay, OBS Studio, anticheats, profilers, ...