text
stringlengths
0
1.99k
The OR instruction is part of the IBM Power ISA[19]. The basic operation is
defined as:
"or RA,RS,RB: The contents of register RS are ORed with the contents of
register RB and the result is placed into register RA. Some forms of or
Rx,Rx,Rx provide special functions; see Section 3.2 and Section 4.3.3, both
in Book II."
This appears to be a normal OR instruction with register operands. However,
when all three operands reference the same register (effectively performing
a NOP), it activates hidden system functions, such as adjusting process
priorities or issuing cache hints. For example, executing "or 2, 2, 2"
(using general-purpose register 2) silently sets the process priority to
"medium," appearing harmless while triggering background behavior.
Imagine if this instruction had hidden functionality, like adjusting
current privileges, then it could serve as a convenient backdoor.
--[ 3. Designing a CPU Backdoor
The known backdoors discussed earlier, along with proposed ideas [3][18],
require the attacker to already possess code execution capabilities within
the system. However, obtaining initial access often presents the greatest
challenge. To address this, we consider the login process. Password
authentication, a foundational security mechanism, relies on users
submitting credentials (username and password) for verification. However,
even robust password authentication fails if the CPU itself is backdoored,
enabling attackers to bypass verification silently.
----[ 3.1 Windows Password Authentication Bypass via Backdoored Instruction
Windows password authentication works as follows. During login, user
password is padded and hashed to 16 bytes using NTLM algorithm. The
MsvpPasswordValidate() function from msv1_0.dll then compares this hash
with the one stored in the SAM database using RtlCompareMemory(). If they
match, authentication succeeds. Below is the disassembly of
RtlCompareMemory():
ntdll!RtlCompareMemory:
76ff6970 56 push esi
76ff6971 57 push edi
76ff6972 fc cld
76ff6973 8b74240c mov esi,dword ptr [esp+0Ch]
76ff6977 8b7c2410 mov edi,dword ptr [esp+10h]
76ff697b 8b4c2414 mov ecx,dword ptr [esp+14h]
76ff697f c1e902 shr ecx,2
76ff6982 7404 je ntdll!RtlCompareMemory+0x18 (76ff6988)
ntdll!RtlCompareMemory+0x14:
76ff6984 f3a7 repe cmps dword ptr [esi],dword ptr es:[edi]
76ff6986 7516 jne ntdll!RtlCompareMemory+0x2e (76ff699e)
ntdll!RtlCompareMemory+0x18:
76ff6988 8b4c2414 mov ecx,dword ptr [esp+14h]
76ff698c 83e103 and ecx,3
76ff698f 7404 je ntdll!RtlCompareMemory+0x25 (76ff6995)
ntdll!RtlCompareMemory+0x21:
76ff6991 f3a6 repe cmps byte ptr [esi],byte ptr es:[edi]
76ff6993 7516 jne ntdll!RtlCompareMemory+0x3b (76ff69ab)
ntdll!RtlCompareMemory+0x25:
76ff6995 8b442414 mov eax,dword ptr [esp+14h]
76ff6999 5f pop edi
76ff699a 5e pop esi
76ff699b c20c00 ret 0Ch
ntdll!RtlCompareMemory+0x2e:
76ff699e 83ee04 sub esi,4
76ff69a1 83ef04 sub edi,4
76ff69a4 b904000000 mov ecx,4
76ff69a9 f3a6 repe cmps byte ptr [esi],byte ptr es:[edi]
ntdll!RtlCompareMemory+0x3b:
76ff69ab 4e dec esi
76ff69ac 2b74240c sub esi,dword ptr [esp+0Ch]
76ff69b0 8bc6 mov eax,esi
76ff69b2 5f pop edi
76ff69b3 5e
Since the hash data is exactly 16 bytes long and system-allocated memory is
typically word-aligned, RtlCompareMemory() optimizes the comparison
process. On 32-bit x86 systems, it performs four 32-bit (DWORD) comparisons
using REPE CMPSD, while on 64-bit x86 systems, it executes two 64-bit
(QWORD) comparisons via REPE CMPSQ, as shown below.
x86
"f3a7 repe cmps dword ptr [esi],dword ptr es:[edi]"
x86_64
"f348a7 repe cmps qword ptr [rsi],qword ptr [rdi]"
The esi and edi registers store the memory addresses of the two hash values
being compared, while ecx contains the number of comparisons to perform.
The repe (or repz) prefix instructs the CMPS instruction to repeat until
either ecx reaches zero or a mismatch is detected.In the Windows password