Reading the NFC Chip UID
The NFC chip UID is read by a device from an NFC chip either by reading a specific portion of memory, by calling an NFC chip command or from a software subsystem that performs one of these; which method is used is based on the NFC tag type and NFC chip type. It is possible to encode the UID into the NFC user memory or mirror the UID into an NDEF record; although both methods are insecure. The NFC chip UID can be used in a security system to prevent and detect the cloning of an NFC tag, but only if the system is properly designed.
Reading an NFC Chip UID with Mobile Apps
It is straightforward for desktop NFC software systems to read the NFC chip UID, however mobile apps can be more complex based on what software is running on the device. The native functionality for iPhone and Android is to read the NDEF data from the NFC chip; the native functionality does not read the UID as it has no reason to. Both iPhone and Android have NFC SDKs that allow 3rd party apps to read the NFC chip UID, but this requires a 3rd party app to be used. Previously the iOS NFC SDK (Core NFC) did not allow access to reading the UID even for 3rd party apps, but that has since been added to the current version of Core NFC. The code to read a UID for each platform is here:
Reading the NFC Chip UID with Android
To read the NFC chip UID with the Android NFC SDK, use the following:
Reading the NFC Chip UID with iPhone / iOS Core NFC Framework
To read the NFC chip UID with Core NFC, the appropriate NFC standards interface must first be used then the following:
NDEF UID Mirroring
Several modern NFC chip types are able to mirror data elements such as the NFC chip UID into an NDEF record stored in user memory. When the user memory is read by NFC software, the NFC chip replaces the placeholder data (all 0s) in user memory with the real data from the NFC chip. This replacement is internal to the NFC chip and the software has no awareness that it is occurring. From the software’s perspective, it just sees the NDEF data with the UID included. UID mirroring is functionality equivalent to encoding the UID into user memory “UID encoding“, the only difference is when the replacement occurs; at tag reading time or at tag encoding time. UID mirroring is equally as insecure as UID encoding and should not be used in a security system as it is trivial to clone an NFC chip with mirroring enabled.