text
stringlengths
0
1.99k
(ML505-V5LX110T), an FPGA board designed to emulate a full OpenSPARC T1
system, including the CPU, DDR memory controller, Ethernet interfaces, and
other peripherals. This setup, leveraging the open-source RTL and
FPGA-based emulation, provides the closest possible approximation to
testing on a commercial CPU.
----[ 3.3.1 *nix Password Authentication Analysis
The OpenSPARC project offers SunOS 5.11 and Ubuntu 7.10 ramdisk images for
the FPGA-emulated system. Both operating systems run a 64-bit kernel but
restrict user-mode programs to 32-bit execution. As noted in the SPARC
Assembly Language Reference Manual [2], certain 64-bit registers remain
accessible to 32-bit programs: "The global registers and output registers
can store full 64-bit integer values, while the input and local registers
are limited to 32-bit values in the lower half."
In Ubuntu 7.10's 32-bit libc-2.6.1.so, the strcmp() function leverages
64-bit registers for string comparisons. When memory addresses are
word-aligned, it uses the CMP instruction with 64-bit register operands to
perform efficient comparisons. As illustrated in the following assembly
snippet, LDXA loads 64-bit data into the registers (o2 and o3), which are
then compared using CMP:
LAB_0018d310 XREF[2]: 0018d328(j),
0018d310 90 02 20 08 add __s1,0x8,__s1
0018d314 86 22 80 01 sub o2,g1,g3
0018d318 80 a2 80 0b cmp o2,o3
0018d31c 12 60 00 29 bpne,pn %xcc,LAB_0018d3c0
0018d320 d4 da 10 40 _ldxa [__s1+g0] 0x82,o2
0018d324 80 88 c0 02 andcc g3,g2,g0
0018d328 22 6f ff fa bpe,a,pt %xcc,LAB_0018d310
0018d32c d6 da 50 48 _ldxa [__s2+__s1] 0x82,o3
I also analyzed Debian 9.0 SPARC64 and found that its libpam and libc
implementations closely resemble those in Ubuntu 7.10 SPARC32+. However, in
Debian 9.0, strcmp() uses the XOR instruction for data comparison instead
of CMP. This subtle change would make the backdoor ineffective if it
exclusively targets on the CMP instruction. That said, this is only a minor
issue for CPU vendors. They could either encourage compiler developers to
favor a specific instruction or implement the backdoor for both cases.
After all, only a few instructions are capable of performing data
comparisons.
Unlike Ubuntu, SunOS 5.11's libc is limited to 32-bit operands. For
simplicity, this analysis only focuses on Ubuntu.
In Ubuntu 7.10, user authentication is implemented through libpam
(Pluggable Authentication Modules), which also verifies passwords by
comparing hash strings. Our backdoor specifically exploits the CMP
instruction in this verification process.
Like most Linux distributions, Ubuntu 7.10 supports multiple hash
algorithms, such as MD5 and SHA256. The following example demonstrates two
hash strings, where the numeric value between the first two dollar signs
indicates the algorithm used for each hash (MD5: $1$, SHA-256: $6$):
"root:$1$7c71xB0y$mPkMSwwbMWgEXsyD6YV/C1:14168:0:99999:7:::"
"u:$6$zE3nVD4laY6MS31E$NK4TnaebdS.O9FX9Q.pg7/yH.fH5bi8bHCFJdFbEaPtmW/59KKB
7JDk53W21ZoLnKhrkmB4u5cXE.9ynmeIEw0:18811:0:99999:7:::"
Additionally, *nix systems commonly use salt in password hashing to
strengthen security. For example, an MD5 hash string follows the format
$1$<salt>$<hash>, where $1$ indicates the hashing algorithm, <salt> is a
random value, and <hash> is the resulting salted password hash.
Salting ensures that even one password produce millions of significantly
different hashes, making precomputation attacks (like rainbow tables)
infeasible, since storing every possible salted hash would be impractical.
The CPU backdoor faces the same issue: it cannot compare against all salted
hashes to identify one master password. However, during password
authentication, the CPU can still read the username in cleartext.
Our approach uses unique usernames to enable or disable the backdoor. For
instance, entering the secret username "00000000" will enable the backdoor.
After that, the CMPS instruction will return a match for all subsequent
hash string comparisons until the backdoor is disabled again. During this
period, an attacker can log in to any account using any password.
The secret username should be 8 bytes long, ensuring it fits precisely into
a 64-bit register. During password authentication, libpam first verifies
the username against entries in /etc/passwd, where the default first entry
is usually "root". When comparing the input "00000000" with the stored
"root" entry, the CPU executes a "CMP reg-rs1, reg-rs2" instruction. In
this case, reg-rs1 holds 0x726f6f7400000000, which corresponds to the ASCII
encoding of "root" followed by null padding to fill the 8-byte register.
Meanwhile, reg-rs2 contains 0x3030303030303030, the ASCII representation of
"00000000".
When these two values are compared, the CPU then examines subsequent hash
comparisons. It specifically looks for a pattern where both the rs1 and rs2
registers contain values beginning with "$1$".
Here is how *nix password authentication works. The crypt() function
generates the hash value. libpam passes both the user-input password and
the hash string stored in the /etc/shadow file to crypt(), as illustrated