Skip to content
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

Antivirus dynamic shell code execution #1071

Closed
rickshaw5724 opened this issue Aug 30, 2023 · 3 comments · Fixed by #1074 · May be fixed by #1072
Closed

Antivirus dynamic shell code execution #1071

rickshaw5724 opened this issue Aug 30, 2023 · 3 comments · Fixed by #1074 · May be fixed by #1072

Comments

@rickshaw5724
Copy link
Contributor

Environment

NetMQ Version:    4.0.1.13
Operating System: Windows 10
.NET Version:     .Net 6

Expected behavior

I would like to be able to have an option to force the NetMQ.Core.Utils.Clock's s_rdtscSupported to false, and therefore always fall back to using Stopwatch.GetTimestamp. As an idea add this Boolean:

public class SocketOptions
{
        /// <summary>
        /// If set, the time stamp counter is not read directly through opcode injection, rather
        /// <see cref="System.Diagnostics.Stopwatch.GetTimestamp"/> is used.
        /// </summary>
        public static bool DoNotUseRDTSC;

Then in Opcode.Open

        public static bool Open()
        {
            if (SocketOptions.DoNotUseRDTSC)
                return false;

Actual behavior

The method of injecting opcode into memory and invoking it to read the time stamp counter is being detected as dynamic shellcode by some anti-malware such as Sophos. When detected, the process executing the code is terminated. The detection as malware occurs when the Opcode.Open method is called and the s_codeBuffer is allocated with EXECUTE_READWRITE.

Steps to reproduce the behavior

Bind a publish socket to a tcp URL when running on a system protected by Sophos. Unfortunately, my companies corporate IT has deployed this feature everywhere and I can't argue it is able to detect actual malware scenarios. But I have a large engineering community where ZeroMQ is going to become more prevalent.

@drewnoakes
Copy link
Member

Sounds reasonable. Can you submit a PR?

@rickshaw5724
Copy link
Contributor Author

Sure, just submitted one.

@drewnoakes
Copy link
Member

#1072

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants