T1546.008: accessibility-binary replacement atomics never replace the binary on a fresh host (cmd IF/ELSE + & binds the payload to ELSE)

Author: zkhan-bhisCreated Sep 22, 2026Updated Sep 22, 2026

Summary

The six T1546.008 "replace an accessibility binary with cmd.exe" atomics never replace the target binary on a host where the *_backup.exe does not already exist (i.e. a fresh machine, and every CI runner). They exit 0 and look successful, but only the backup copy is made — takeown, icacls, and the actual copy /Y cmd.exe <binary> are silently skipped.

Affected tests in atomics/T1546.008/T1546.008.yaml:

GUID Name Binary
934e90cf-29ca-48b3-863c-411737ad44e3 Replace binary of sticky keys sethc.exe
1db380da-3422-481d-a3c8-6d5770dba580 Replace utilman.exe … utilman.exe
5e4fa70d-c789-470e-85e1-6992b92bb321 Replace Magnify.exe … Magnify.exe
2002f5ea-cd13-4c82-bf73-e46722e5dc5e Replace Narrator.exe … Narrator.exe
825ba8ca-71cc-436b-b1dd-ea0d5e109086 Replace DisplaySwitch.exe … DisplaySwitch.exe
210be7ea-d841-40ec-b3e1-ff610bb62744 Replace AtBroker.exe … AtBroker.exe

Root cause

Each command ships four steps that the command_prompt executor joins into one line with &. The first step is an IF … (…) ELSE (…):

bat
IF NOT EXIST C:\Windows\System32\sethc_backup.exe (copy C:\Windows\System32\sethc.exe C:\Windows\System32\sethc_backup.exe) ELSE ( pushd ) & takeown /F C:\Windows\System32\sethc.exe /A & icacls C:\Windows\System32\sethc.exe /grant Administrators:F /t & copy /Y C:\Windows\System32\cmd.exe C:\Windows\System32\sethc.exe

In cmd.exe, a & … command list that follows IF cond (…) ELSE (…) binds to the ELSE branch. So the parse is effectively:

IF NOT EXIST backup ( copy … backup )
ELSE ( pushd  &  takeown …  &  icacls …  &  copy /Y cmd.exe <binary> )

On a fresh host the backup does not exist, so the IF-true branch runs (just the backup copy) and the entire ELSE branch — takeown, icacls, and the replacement — is skipped. The binary is never replaced. On a second run the backup now exists, the ELSE branch runs, and it works — which is why this is easy to miss when testing locally on a machine that has already been through it once.

Evidence

Observed across multiple runs on fresh Windows Server runners: a single file-create for sethc_backup.exe, no takeown.exe or icacls.exe process spawned, and no write to sethc.exe. Control commands (&-chained steps in unrelated atomics) spawn their child processes normally in the same runs, so this is the cmd IF/ELSE binding, not the executor dropping children.

Suggested fix

Put each step on its own line (the command_prompt executor runs them independently) instead of relying on &, or wrap the IF in its own cmd /c. For example:

yaml
    command: |
      IF NOT EXIST C:\Windows\System32\sethc_backup.exe copy C:\Windows\System32\sethc.exe C:\Windows\System32\sethc_backup.exe
      takeown /F C:\Windows\System32\sethc.exe /A
      icacls C:\Windows\System32\sethc.exe /grant Administrators:F /t
      copy /Y C:\Windows\System32\cmd.exe C:\Windows\System32\sethc.exe

The same change applies to all six atomics listed above.

Environment

Windows Server, command_prompt executor, run elevated, fresh host (no pre-existing *_backup.exe).

Source: redcanaryco/atomic-red-team