aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoruser <user@clank>2026-09-29 22:27:31 +0200
committeruser <user@clank>2026-09-29 22:27:31 +0200
commitcc78031f733cc27fdf65872a260e4ae59b9bbfc2 (patch)
tree13332193c8df513206ac855e67627fcf29cfaf03
parentemulator fuzz harness: TAs really do load; first fault refuted on silicon (diff)
downloadamd-psp-re-cc78031f733cc27fdf65872a260e4ae59b9bbfc2.tar.gz
amd-psp-re-cc78031f733cc27fdf65872a260e4ae59b9bbfc2.tar.xz
amd-psp-re-cc78031f733cc27fdf65872a260e4ae59b9bbfc2.zip
[ST] seventh pass: scan the code behind the TAs; one unresolved underflow shape in SYS_DRV
The TAs are bounded everywhere the three shapes can see, but a TA command is only the front door: every interesting TA reaches ASD or SYS_DRV through svc 0xF2, and neither had been put through these detectors. Both are in the IDA pipeline now and the boundary-free scanner needs only bytes and a load base. At the correct bases, SYS_DRV produced a cluster worth reading, five sites taking a length from offset 0x44, which is where a SYS_DRV RPC request keeps an argument. The result is one unresolved memory-corruption shape in sub_E0D6B4: a memcpy of len bytes followed by a zero-fill of size minus len, where the zero-fill length parameter is unsigned, the function is 28 bytes with no comparison of the two values, and the two values come from different structures, len from the source object and size from the caller's. The destination in the calling frame is a 144-byte stack buffer, so if len exceeds size the subtraction wraps and the fill runs off the stack. Unlike every earlier candidate this one is not disposed of by bounded or by not-host-controlled, since the arithmetic is genuinely unguarded and the two lengths are independent. What is missing is reachability: the single caller is an internal service routine working on key and curve globals, so the field is internal and no TA-controlled path has been shown. Tracing the writers of that field in both structures is the tractable next question. So still no new exercisable primitive, but this is the first candidate in seven passes whose arithmetic is actually wrong rather than merely unproven.
-rw-r--r--fw/AUDIT-TA-MEMSAFETY-HUNT.md35
-rw-r--r--fw/LEAD-SYSDRV-E0D6B4-LENGTH-MISMATCH-UNDERFLOW.md67
2 files changed, 102 insertions, 0 deletions
diff --git a/fw/AUDIT-TA-MEMSAFETY-HUNT.md b/fw/AUDIT-TA-MEMSAFETY-HUNT.md
index 4542298..8e8c7eb 100644
--- a/fw/AUDIT-TA-MEMSAFETY-HUNT.md
+++ b/fw/AUDIT-TA-MEMSAFETY-HUNT.md
@@ -365,3 +365,38 @@ produced a fabricated finding.
The harness (`psp_emu/harness/fuzz_newtas.py`) is nonetheless now a working, real-load,
own-Create TA fuzzer for all twelve TAs with two oracles, which is a usable instrument for
the next attempt — with the hardware confirmation step made mandatory.
+
+================================================================================
+# Seventh pass: the code BEHIND the TAs (ASD 1551 fns, SYS_DRV 1140 fns)
+
+The TAs themselves are bounded everywhere the three shapes can see. But a TA command is only
+the front door: every interesting TA reaches ASD (`svc 0xF2` service 2) or SYS_DRV
+(service 1), and neither had ever been put through these detectors. Both are now in the IDA
+pipeline with prototypes, and the boundary-free scanner only needs bytes plus a load base.
+
+Run at the correct bases (`ASD 0xD00100`, `SYS_DRV 0xE00100`), SYS_DRV produced a cluster
+worth reading: `len <- LOAD [r4, #0x44]` at five sites in `0xe0d6be..0xe0d86c`, and `+0x44`
+is where a SYS_DRV RPC request keeps an argument.
+
+**Result: one unresolved memory-corruption shape** —
+`fw/LEAD-SYSDRV-E0D6B4-LENGTH-MISMATCH-UNDERFLOW.md`:
+
+```c
+sub_E018A0(a1, a2, *(a2 + 68)); // memcpy(dst, src, len)
+sub_E019A0(*(a2 + 68) + a1, a3 - *(a2 + 68)); // zero_fill(dst+len, size-len)
+```
+
+`sub_E019A0`'s length parameter is **unsigned**, the function is 28 bytes with **no compare**
+of `len` against `a3`, and the two values come from **different structures** — `len` from the
+source object, `size` from the caller's. The destination in the calling frame is a **144-byte
+stack buffer**. If `len > size`, the subtraction wraps and the zero-fill runs off the stack.
+
+Unlike every earlier candidate this one is not disposed of by "bounded" or "not
+host-controlled": the arithmetic is unguarded and the two lengths are independent. What is
+missing is reachability — the single caller is an internal `SVC 0x5E` service routine working
+on key/curve globals, so `+0x44` is an internal field and no TA-controlled path to it has been
+shown. That is a tractable next question (trace the writers of `+0x44` in both structures)
+rather than another dead end.
+
+**Still no new exercisable memory-corruption primitive** — but this is the first candidate in
+seven passes whose arithmetic is actually wrong.
diff --git a/fw/LEAD-SYSDRV-E0D6B4-LENGTH-MISMATCH-UNDERFLOW.md b/fw/LEAD-SYSDRV-E0D6B4-LENGTH-MISMATCH-UNDERFLOW.md
new file mode 100644
index 0000000..0150398
--- /dev/null
+++ b/fw/LEAD-SYSDRV-E0D6B4-LENGTH-MISMATCH-UNDERFLOW.md
@@ -0,0 +1,67 @@
+# LEAD: SYS_DRV `sub_E0D6B4` — two independent length fields, unsigned subtraction, no compare
+
+**Component:** SYS_DRV (`sys_drv_code.bin`, load base `0xE00100`), reached from a TA via
+`svc 0xF2`. **Class:** unsigned-underflow-driven overlong zero-fill (memory corruption).
+**Status:** **lead.** The underflow shape is established; whether the two length fields can
+be made to disagree by anything a TA controls is **not** established.
+
+## The shape
+
+```c
+int __fastcall sub_E0D6B4(int a1, int a2, int a3)
+{
+ sub_E018A0(a1, a2, *(_DWORD *)(a2 + 68)); // memcpy(a1, a2, len)
+ return sub_E019A0(*(_DWORD *)(a2 + 68) + a1, a3 - *(_DWORD *)(a2 + 68));
+} // zero_fill(a1+len, a3-len)
+```
+
+* `sub_E018A0` is a **memcpy** (tail-jumps to `0xE01F4A`).
+* `sub_E019A0` is a **zero-fill**, and its second parameter is declared
+ `unsigned int` — confirmed from its own body, which branches on `a2 >= 4` and
+ `__CFSHL__(a2, 31)`.
+* The whole function is 28 bytes and contains **no comparison** of `len` against `a3`.
+
+So if `len > a3`, `a3 - len` wraps to a value near 2^32 and the zero-fill runs off the end of
+the destination. That is memory corruption, not a read.
+
+## Why the two lengths can differ in principle
+
+The call chain keeps the *copy length* and the *buffer size* in **different structures**:
+
+```
+sub_E0D6F0: sub_E0D6D0(dst: v14 /* 144-byte STACK buffer */, a2, a3: *(a1 + 68))
+sub_E0D6D0: sub_E0D6B4(a1 + 72, a2 + 72, a3)
+sub_E0D6B4: len = *(a2 + 72 + 68) <-- from the SOURCE structure
+ size = a3 = *(a1 + 68) <-- from a DIFFERENT structure
+```
+
+`len` is read from the source object and `size` from the caller's object, and nothing ties
+them together. The destination in `sub_E0D6F0` is `v14`, a **144-byte stack buffer** (there is
+a second, `v15`, also 144 bytes), so an overlong copy or zero-fill lands on the stack.
+
+## What is NOT established
+
+* **Reachability.** The single caller of `sub_E0D6F0` is a large internal service routine
+ (`SVC 0x5E` entry) that works on globals at `off_E09260 + {1212, 2424, 3636, 4848, 6060}`
+ and `off_E09264 + {72, 144, 216, 360}` — the layout of a key/curve context, not an RPC
+ request. So `+0x44` is an *internal* field, and whether a TA can influence it is unknown.
+* Whether any caller already guarantees `len <= a3` by construction (e.g. both fields written
+ from one source at init).
+* No hardware test. A TA-reachable trigger has not been identified, so there is nothing to
+ drive yet.
+
+## Why it is recorded anyway
+
+Every previous candidate in this hunt died on "the value is bounded" or "the value is not
+host-controlled". This one dies on neither yet: the arithmetic is genuinely unguarded, the
+destination is genuinely a 144-byte stack buffer, and the two lengths genuinely come from
+different objects. It is the only unresolved memory-corruption *shape* found in the code
+behind the TAs, and the remaining question is a tractable one — trace who writes `+0x44` of
+those two structures.
+
+## How it was found
+
+`fw/ta_corpus_memscan.py` (boundary-free, controlled against HDCP's confirmed overflow)
+applied to `sys_drv_code.bin` at base `0xE00100`. It reported `len <- LOAD [r4, #0x44]` at
+five sites clustered in `0xe0d6be..0xe0d86c`; `+0x44` is also where the SYS_DRV RPC request
+keeps an argument, which is what made the cluster worth reading.