CVE-2026-55261 AI-generated analysis
platform/packages/modules/Nfc, libnfc-nci NFA NDEF-NFCEE (T4T) read path (libnfc-nci/src/nfa/ndefnfcee/t4t/nfa_nfcee_act.cc)
Clamps the per-packet memcpy in nfa_t4tnfcee_store_rx_buf to the remaining capacity of nfa_t4tnfcee_cb.p_dataBuf instead of relying on an all-or-nothing length check, and stops nfa_t4tnfcee_handle_file_operations (WAIT_READ_FILE) from overwriting a NFA_STATUS_FAILED set by the store routine with the raw frame status.
Root cause
nfa_t4tnfcee_store_rx_buf copies each received read-file APDU chunk (p_data->len bytes) into the heap buffer nfa_t4tnfcee_cb.p_dataBuf at nfa_t4tnfcee_cb.rd_offset. In the pre-fix code shown in the diff, an oversize chunk (rd_offset + len > p_dataBuf_len) was dropped entirely and nfa_t4tnfcee_cb.status was set to NFA_STATUS_FAILED. But in nfa_t4tnfcee_handle_file_operations, state WAIT_READ_FILE, once RW_T4tIsReadComplete() returned true, the code unconditionally wrote nfa_t4tnfcee_cb.status = p_rwData->raw_frame.status, overwriting the failure before nfa_t4tnfcee_notify_rx_evt() was called. The commit message calls this a heap buffer overflow in nfa_t4tnfcee_store_rx_buf. It says the drop causes truncated/incomplete NDEF data and the status overwrite masks the failure. The material does not show a memcpy without a bounds check at the pre-fix state of this branch (the pre-image already carries the 508390497 check).
How the fix works
- libnfc-nci/src/nfa/ndefnfcee/t4t/nfa_nfcee_act.cc:nfa_t4tnfcee_store_rx_buf: computes avail = p_dataBuf_len - rd_offset and n = min(p_data->len, avail). If n > 0, it memcpy's exactly n bytes to &p_dataBuf[rd_offset] and advances rd_offset by n, so the copy is bounded by the remaining capacity (given rd_offset <= p_dataBuf_len).
- Same function: if p_data->len > avail, it still logs the error, sets nfa_t4tnfcee_cb.status = NFA_STATUS_FAILED and emits android_errorWriteLog for 503545851 in addition to the existing 508390497 entry.
- libnfc-nci/src/nfa/ndefnfcee/t4t/nfa_nfcee_act.cc:nfa_t4tnfcee_handle_file_operations, case WAIT_READ_FILE: after RW_T4tIsReadComplete(), nfa_t4tnfcee_cb.status is replaced with p_rwData->raw_frame.status only while it is still NFA_STATUS_OK. A NFA_STATUS_FAILED set by nfa_t4tnfcee_store_rx_buf is therefore preserved and reported by nfa_t4tnfcee_notify_rx_evt().
- libnfc-nci/tests/src/nfa_nfcee_act_test.cc (new): NfaNfceeActTest.StoreRxBuf_NormalCopy and StoreRxBuf_OverflowClamped include the .cc directly. They verify that an oversize chunk fills the buffer only up to p_dataBuf_len, rd_offset lands at p_dataBuf_len, bytes beyond are untouched, and status becomes NFA_STATUS_FAILED.
Completeness
- The clamp covers the only memcpy into p_dataBuf in nfa_t4tnfcee_store_rx_buf. The diff shows it called from the WAIT_READ_FILE case. The index search found no other callers among its top results, though that search may be incomplete.
- The new code assumes rd_offset <= p_dataBuf_len. avail is an unsigned subtraction, so if that invariant were ever broken elsewhere, avail would wrap and the clamp would not bound the copy. The diff adds no explicit rd_offset <= p_dataBuf_len guard and no NULL check on p_dataBuf.
- The status-overwrite guard is applied only to the WAIT_READ_FILE completion path. Other states in nfa_t4tnfcee_handle_file_operations are unchanged by this commit.
- On overflow the read is now reported as failed, with the buffer filled to capacity. Before, the chunk was dropped and the failure could be masked by the raw frame status. The test asserts the new behavior.
Behavior changes
- An oversize read chunk is partially copied up to the remaining capacity (previously dropped entirely), and rd_offset advances to p_dataBuf_len.
- nfa_t4tnfcee_cb.status = NFA_STATUS_FAILED set during store now survives read completion in WAIT_READ_FILE and is delivered via nfa_t4tnfcee_notify_rx_evt(). Before, the raw frame status replaced it.
- A new android_errorWriteLog(0x534e4554, "503545851") entry is emitted alongside the existing 508390497 entry on overflow.
- New test source nfa_nfcee_act_test.cc adds the NfaNfceeActTest fixture, run via atest libnfc-nci-tests:NfaNfceeActTest.
Per major
- Android 14: Not affected per the bulletin. platform/packages/modules/Nfc is not present in this major's security tags (android-security-14.0.0_r31). The material does not show whether equivalent code exists elsewhere.
- Android 15: Not affected per the bulletin. platform/packages/modules/Nfc is not present in this major's security tags (android-security-15.0.0_r19). The material does not show whether equivalent code exists elsewhere.
- Android 16: Same fix: commit 3cfc747e2651 in android-security-16.0.0_r8 (cherry-pick of c51a26973ba8, Change-Id Ie601a3726a0e9e182ce3b759db2873500afb0bd7). Code context at android-security-16.0.0_r10 shows the clamped version in nfa_t4tnfcee_store_rx_buf. The resolver reports 5/8 lines of the patched region present.
- Android 17: Same fix: commit f5089c4c9b4e in android-security-17.0.0_r1 with an identical diff (same blob ids ed95becf2..d16420a97). The resolver reports 5/8 lines of the patched region present at android-security-17.0.0_r3.
Unknowns
- The material does not show an unchecked memcpy at the pre-fix state of this branch (the 508390497 check is already present), so the diff alone does not reveal the exact code path behind the heap overflow the commit message describes.
- How nfa_t4tnfcee_cb.p_dataBuf_len is allocated, and whether it can differ from the length the NFCEE reports, is not shown.
- Whether the libnfc-nci change ships via the Nfc mainline module or only via platform tags is not stated in the material.
- Why the resolver reports only 5/8 lines of the patched region present at the latest 16 and 17 tags is not explained in the material.
- Whether any NFC code equivalent to this path exists on Android 14/15 outside platform/packages/modules/Nfc is not shown.