Windows: Defender's ShellCode.MKA!MTB on the AGC test executables matches GCC's divide-by-65 in UintStorageImageBinding #26777

Closed
opened 2026-11-24 21:14:09 +00:00 by Helldiverr · 0 comments
Helldiverr commented 2026-11-24 21:14:09 +00:00 (Migrated from github.com)
Contributor

Imported from boykopovar/AnyPS5. Originally posted by Helldiverr on 2026-11-24T21:14:09Z.


What happens

On Windows, Microsoft Defender quarantines agc_shader_replay.exe and 35 tests/agc_*_tests.exe as Trojan:Win64/ShellCode.MKA!MTB. The match is a static byte signature on one instruction sequence that GCC emits for number % 65 in RuntimeAbi::UintStorageImageBinding. It is not caused by generated machine code, which is the reason docs/dev/BUILD.md:76 gives.

Title, test or build step

The objcopy post-step of the AGC test targets (Invalid argument); ctest then reports those tests as Not Run. docs/dev/BUILD.md:76.

AnyPS5 commit

main 02cbc28a52 for the full build below. The source lines cited are unchanged on main c2a0c13039.

System

Windows 11 Pro 10.0.26300, Ryzen 9 9950X3D, WinLibs GCC 15.2.0 UCRT posix-seh r7, Release, BUILD_TESTING=ON. Defender real-time protection on with default settings, antimalware client 4.18.26100.4, engine 1.1.26100.4, signatures 1.463.453.0.

Steps to reproduce

  1. Configure and build main with the default preset and BUILD_TESTING=ON, with Defender's default settings.
  2. Run Get-MpThreatDetection afterwards. It lists ShellCode.MKA!MTB for agc_shader_replay.exe and the AGC test executables, and the build log shows objcopy ... Invalid argument for each of them.

In one full build of main 02cbc28a52 on this machine, Get-MpThreatDetection recorded 108 detections of these 36 files within 45 minutes, as builds and reruns relinked them. On another worktree, a focused build of one PR had agc_shader_mode_register_tests.exe quarantined six times in nine minutes.

Log

Trojan:Win64/ShellCode.MKA!MTB  build\core\libs\prx\libSceAgcDriver\agc_shader_replay.exe
Trojan:Win64/ShellCode.MKA!MTB  build\tests\agc_denormal_flush_elimination_tests.exe
Trojan:Win64/ShellCode.MKA!MTB  build\tests\agc_shader_mode_register_tests.exe
Trojan:Win64/ShellCode.MKA!MTB  build\tests\agc_spirv_module_tests.exe
... (36 files in all)

What was checked

Where the signature is. I bisected agc_spirv_module_tests.exe by relinking it from subsets of its archive members and having Defender scan each result three times.

  • The executable is detected only when it contains DescriptorBindingBuilder.cpp.obj. With that object and the test alone it is detected 3/3. Each of the other 121 members, without that object, gives clean 3/3.
  • Within that object only .text matters. Blanking .rdata or .text.unlikely stays detected; blanking .text is clean.
  • Within .text, the signature needs 15 bytes:
    • Blanking any one of three slices of them gives clean 3/3: bytes 0-2, 2-7 or 7-15. Blanking the cmp/ja just before them stays detected.
    • The bytes are 89 c2 b9 fd c0 0f fc 48 0f af d1 48 c1 ea 26.
    • In assembly: mov edx,eax; mov ecx,0xfc0fc0fd; imul rdx,rcx; shr rdx,38. This is GCC's division by 65.
  • A -g build maps them to RuntimeAbi::UintStorageImageBinding. That function computes number % count with Binding::Count = 65 and is inlined at DescriptorBindingBuilder.cpp:823.

It only fires on small executables.

  • A minimal int main(){return 0;} linked with that one object: as an EXE it is detected 3/3. Linked as a DLL it is clean 3/3. The same DLL with IMAGE_FILE_DLL cleared in its header is detected again, 3/3.
  • libSceAgcDriver.prx from the same build, the file a release ships, contains the same byte sequence with the same surrounding bytes. It is 23.8 MB and scans clean 3/3, also with the DLL flag cleared.
  • So players running a release are not affected; developers building the tests are.

objcopy is a consequence, not a cause. Defender removes the executable right after the link. The post-step at core/libs/CMakeLists.txt:65 that renames .eh_frame then finds no file and reports Invalid argument. Nothing in these executables is writable and executable: the code sits in an ordinary read-execute .text.

Other Defender verdicts seen in the same builds. These differ in kind from ShellCode.MKA!MTB: they are cloud machine-learning verdicts (!ml) on exact file hashes.

  • Some executables that relinker tests produce were flagged Trojan:Win32/Wacatac.C!ml or Wacatac.H!ml. Flipping one byte of such a file and rescanning came back clean.
  • relinker.exe itself was flagged Trojan:Win32/Bearfoos.A!ml once, as in #16960; a later build of it scanned clean.
  • BUILD.md:75 already covers these with the test-temp exclusion.

Releases are unsigned.

  • tools/package_release.py copies the built executables into the archive as they are.
  • .github/workflows/release.yml has no signing step.
  • No Authenticode signing happens anywhere in .github or tools.
  • Smart App Control (BUILD.md:78) blocks unsigned files outright. A signature also gives Defender's cloud reputation checks a publisher to attach reputation to, which an unsigned file never gets.

Possible directions (the maintainer's call):

  1. Correct BUILD.md:76. Name the real cause and the current count. I will open a docs PR for this and link it here.
  2. Submit a false positive to Microsoft. A sample from a project maintainer at the Defender submission portal ("Software developer", incorrectly detected) is the usual way to get a signature like ShellCode.MKA!MTB narrowed. The 15 bytes above can go with it.
  3. Sign the release binaries with Authenticode. For example SignPath's free tier for open-source projects, or Azure Trusted Signing, as a step in release.yml before package_release.py. This addresses Smart App Control and reputation verdicts for people running a release. It does not change the byte signature above, which hits test builds only.
  4. Change how UintStorageImageBinding computes the stage-local slot. For example, compare number against per-stage ranges instead of taking % 65. GCC would then emit different instructions. This is only a workaround for one signature, and another constant may match later.

I have not changed any Defender setting for these runs and have not submitted samples to Microsoft.

AI-assisted: yes

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:6591543148 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/26777). Originally posted by [Helldiverr](https://github.com/Helldiverr) on 2026-11-24T21:14:09Z. --- ### What happens On Windows, Microsoft Defender quarantines `agc_shader_replay.exe` and 35 `tests/agc_*_tests.exe` as `Trojan:Win64/ShellCode.MKA!MTB`. The match is a static byte signature on one instruction sequence that GCC emits for `number % 65` in `RuntimeAbi::UintStorageImageBinding`. It is not caused by generated machine code, which is the reason docs/dev/BUILD.md:76 gives. ### Title, test or build step The `objcopy` post-step of the AGC test targets (`Invalid argument`); ctest then reports those tests as `Not Run`. docs/dev/BUILD.md:76. ### AnyPS5 commit `main` 02cbc28a52 for the full build below. The source lines cited are unchanged on `main` c2a0c13039. ### System Windows 11 Pro 10.0.26300, Ryzen 9 9950X3D, WinLibs GCC 15.2.0 UCRT posix-seh r7, Release, `BUILD_TESTING=ON`. Defender real-time protection on with default settings, antimalware client 4.18.26100.4, engine 1.1.26100.4, signatures 1.463.453.0. ### Steps to reproduce 1. Configure and build `main` with the default preset and `BUILD_TESTING=ON`, with Defender's default settings. 2. Run `Get-MpThreatDetection` afterwards. It lists `ShellCode.MKA!MTB` for `agc_shader_replay.exe` and the AGC test executables, and the build log shows `objcopy ... Invalid argument` for each of them. In one full build of `main` 02cbc28a52 on this machine, `Get-MpThreatDetection` recorded 108 detections of these 36 files within 45 minutes, as builds and reruns relinked them. On another worktree, a focused build of one PR had `agc_shader_mode_register_tests.exe` quarantined six times in nine minutes. ### Log ```text Trojan:Win64/ShellCode.MKA!MTB build\core\libs\prx\libSceAgcDriver\agc_shader_replay.exe Trojan:Win64/ShellCode.MKA!MTB build\tests\agc_denormal_flush_elimination_tests.exe Trojan:Win64/ShellCode.MKA!MTB build\tests\agc_shader_mode_register_tests.exe Trojan:Win64/ShellCode.MKA!MTB build\tests\agc_spirv_module_tests.exe ... (36 files in all) ``` ### What was checked **Where the signature is.** I bisected `agc_spirv_module_tests.exe` by relinking it from subsets of its archive members and having Defender scan each result three times. - The executable is detected only when it contains `DescriptorBindingBuilder.cpp.obj`. With that object and the test alone it is detected 3/3. Each of the other 121 members, without that object, gives clean 3/3. - Within that object only `.text` matters. Blanking `.rdata` or `.text.unlikely` stays detected; blanking `.text` is clean. - Within `.text`, the signature needs 15 bytes: - Blanking any one of three slices of them gives clean 3/3: bytes 0-2, 2-7 or 7-15. Blanking the `cmp`/`ja` just before them stays detected. - The bytes are `89 c2 b9 fd c0 0f fc 48 0f af d1 48 c1 ea 26`. - In assembly: `mov edx,eax; mov ecx,0xfc0fc0fd; imul rdx,rcx; shr rdx,38`. This is GCC's division by 65. - A `-g` build maps them to [`RuntimeAbi::UintStorageImageBinding`](https://github.com/boykopovar/AnyPS5/blob/c2a0c13039ffc9d8b4e75d54823fc4ba65a3ab0c/core/shader/recompiler/RuntimeAbi.hpp#L114-L119). That function computes `number % count` with `Binding::Count` = 65 and is inlined at [DescriptorBindingBuilder.cpp:823](https://github.com/boykopovar/AnyPS5/blob/c2a0c13039ffc9d8b4e75d54823fc4ba65a3ab0c/core/shader/recompiler/Optimization/src/DescriptorBindingBuilder.cpp#L823). **It only fires on small executables.** - A minimal `int main(){return 0;}` linked with that one object: as an EXE it is detected 3/3. Linked as a DLL it is clean 3/3. The same DLL with `IMAGE_FILE_DLL` cleared in its header is detected again, 3/3. - `libSceAgcDriver.prx` from the same build, the file a release ships, contains the same byte sequence with the same surrounding bytes. It is 23.8 MB and scans clean 3/3, also with the DLL flag cleared. - So players running a release are not affected; developers building the tests are. **`objcopy` is a consequence, not a cause.** Defender removes the executable right after the link. The post-step at [core/libs/CMakeLists.txt:65](https://github.com/boykopovar/AnyPS5/blob/c2a0c13039ffc9d8b4e75d54823fc4ba65a3ab0c/core/libs/CMakeLists.txt#L65) that renames `.eh_frame` then finds no file and reports `Invalid argument`. Nothing in these executables is writable and executable: the code sits in an ordinary read-execute `.text`. **Other Defender verdicts seen in the same builds.** These differ in kind from `ShellCode.MKA!MTB`: they are cloud machine-learning verdicts (`!ml`) on exact file hashes. - Some executables that relinker tests produce were flagged `Trojan:Win32/Wacatac.C!ml` or `Wacatac.H!ml`. Flipping one byte of such a file and rescanning came back clean. - `relinker.exe` itself was flagged `Trojan:Win32/Bearfoos.A!ml` once, as in #16960; a later build of it scanned clean. - BUILD.md:75 already covers these with the `test-temp` exclusion. **Releases are unsigned.** - `tools/package_release.py` copies the built executables into the archive as they are. - `.github/workflows/release.yml` has no signing step. - No Authenticode signing happens anywhere in `.github` or `tools`. - Smart App Control (BUILD.md:78) blocks unsigned files outright. A signature also gives Defender's cloud reputation checks a publisher to attach reputation to, which an unsigned file never gets. **Possible directions (the maintainer's call):** 1. **Correct BUILD.md:76.** Name the real cause and the current count. I will open a docs PR for this and link it here. 2. **Submit a false positive to Microsoft.** A sample from a project maintainer at the Defender submission portal ("Software developer", incorrectly detected) is the usual way to get a signature like `ShellCode.MKA!MTB` narrowed. The 15 bytes above can go with it. 3. **Sign the release binaries with Authenticode.** For example SignPath's free tier for open-source projects, or Azure Trusted Signing, as a step in `release.yml` before `package_release.py`. This addresses Smart App Control and reputation verdicts for people running a release. It does not change the byte signature above, which hits test builds only. 4. **Change how `UintStorageImageBinding` computes the stage-local slot.** For example, compare `number` against per-stage ranges instead of taking `% 65`. GCC would then emit different instructions. This is only a workaround for one signature, and another constant may match later. I have not changed any Defender setting for these runs and have not submitted samples to Microsoft. AI-assisted: yes
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#26777
No description provided.