FIELD NOTE / CLOCK-IN / NTAG 424 DNA

NFC · SUN/SDM · AES-CMAC · PC/SC · Claude Code

A QR code on the wall proves nothing. The sticker we put there instead can't be copied.

2026-11-27  ·  ~9 min read  ·  by Gal Tidhar

A client with several branches in Israel wanted staff to clock in and out from their own phones, with proof they were actually at the branch. This is the whole week: why GPS and QR codes don't prove presence, the chip that does, how its keys are stored nowhere, ordering stickers and a reader, programming the chip with software that didn't exist, a desk in Zagreb where macOS stopped answering, and the small app that got 50 stickers into an envelope.

The Sticker Station screen: a green GOOD counter at 6, a red BAD pile counter at 0, 'Waiting for the next sticker', and a log of VALID and WRITTEN lines with the chip IDs blacked out.
The Sticker Station mid-batch. Chip IDs are blacked out.

GPS wasn't enough

The staff app already had a GPS clock-in: you can clock in when the phone says it's inside a radius around the branch. That's fine as a convenience and weak as proof. Location can be spoofed with an app, and inside a building with a kitchen and a cold room GPS drifts tens of metres anyway. I wanted something physically on the wall that you can only use by standing in front of it.

Why a QR code (or a plain NFC tag) is no proof

A QR code is a URL printed on paper. A normal NFC sticker is a URL written on a chip. Either way it is the same URL every day. Photograph it once, or tap it once and copy the link, and you can "clock in" from home for the rest of the year. One photo in the shift's WhatsApp group and everyone is at work.

What NTAG 424 DNA does differently

NXP's NTAG 424 DNA has a feature NXP calls SUN (Secure Unique NFC), built on SDM (Secure Dynamic Messaging). When a phone reads it, the chip rewrites part of its own URL on the fly. Every tap opens a link with two extra parameters:

  • e=: the chip's UID and its tap counter, AES-encrypted with a key that lives on the chip.
  • c=: a CMAC, a cryptographic signature over that tap, made with a second key on the chip.

The counter goes up by one on every read and can't be reset. The server decrypts e=, recomputes the signature, and accepts the tap only if the signature matches and the counter is higher than the last tap it accepted for that sticker. A link someone photographed, forwarded or saved is a tap that was already used, so it's refused. Two copies of the same fresh link racing each other can't both win either: the counter is claimed with a compare-and-swap, so exactly one request moves it.

And the keys can't be read out of the chip. To make a valid c= you need the key, and the key never leaves the silicon, so the sticker can't be cloned onto another one.

The keys are stored nowhere

Every sticker has three keys of its own. None of them is in the database. Each one is computed when needed: AES-CMAC(master, label + chip UID). The database holds only the sticker's public ID, its UID, the branch it's paired to and the last counter. If the database leaks, whoever has it gets a list of stickers and numbers and nothing that can sign a tap.

The master key lives in a secrets manager (with a backup in a separate vault) and in the backend's environment secrets, where it can't be read back. One consequence I wrote down in capitals: the master is excluded from key rotation. Rotate it and every sticker on every wall is dead forever, because the keys burned into them were derived from the old one.

Ordering

On 20 November I ordered from ShopNFC in Italy: 50 NTAG 424 DNA stickers (22 mm, wet inlay, not for metal surfaces) and an ACS ACR1252U USB reader. EUR 92.30 all in, 0% VAT as an EU business-to-business order.

Before paying I emailed them two questions: do the stickers ship blank with the factory keys, and can the ACR1252U do NTAG 424 authentication and ChangeKey? Their answer was yes to both, with a catch: you need custom software that sends the raw commands (APDUs) to the reader. The phone apps that "write NFC" write a plain URL. Nothing off the shelf turns on SUN and installs your own keys.

Writing the programmer

So Claude Code wrote it, a single Python script, from NXP's datasheet and application note AN12196: AuthenticateEV2First (the three-pass mutual authentication), secure messaging (every command after that is encrypted and MAC'd with session keys), ChangeFileSettings to turn on SDM and set where the encrypted data and the signature go inside the URL, and ChangeKey. Before any real chip was touched it passed NXP's published test vectors and a software-simulated tag.

For each sticker it writes the URL, turns on SUN, installs the sticker's derived keys, with the authentication key last (change it first and you've locked yourself out of the rest), and then reads the sticker back exactly the way a phone would and verifies the link with the same math the server uses. Only then does it print a check mark.

The first sticker

26 November. Programmed, verified, and the iPhone did nothing. iPhones read NFC with the top edge, next to the camera, only when unlocked, and not while the sticker is still sitting on the USB reader, which is holding the field. Once I held it right, it opened the staff app. A manager's tap paired it to a branch from inside the app, and I clocked in and out with it. The database showed 7 taps counted, each one higher than the last.

The batch, and the Mac that stopped answering

Then the rest, at a desk in Zagreb. The stickers were going to Israel by post, so anything wrong had to be found before the envelope closed. There is no fixing a sticker on a wall 2,000 km away.

After a few stickers the script went silent. The reader beeped when a sticker went on, so the hardware saw it, and nothing was counted. No error, no success. I had a sticker in my hand and no idea whether it was good, garbage, or written twice. One I lifted halfway through a write, and it came out half-programmed: keys partly changed, unusable, into the bad pile. To make it more fun, the chip UIDs in this batch share their last four digits, so the short ID on screen made two different stickers look like the same one at least once. I wrote to Claude that I was confused as fuck, and a couple of stickers later: this sucks, build me an app.

The cause, found by sampling the stuck process with macOS's sample tool: the smart-card service (PC/SC) wedges after a few cards inside one long-running process. SCardConnect is called and never returns. Nothing in our code was wrong, and a retry inside the same process doesn't help.

If you program smart cards on a Mac: one fresh process per card. The wedge can't build up across cards if no process lives long enough to collect it.

Sticker Station

That's what the app is. A double-click Mac .app that opens a local page in the browser with two big counters, GOOD and BAD, and runs one new process per sticker underneath. It says every verdict out loud ("good 7", "written 8", "bad pile"), so you stop looking at the screen and just listen. A blank sticker gets written and verified. An already-written one is verified the way a phone would read it. A sticker left lying on the reader is counted once, not on every poll. The screenshot above is it in the middle of a run, including one transfer that dropped (the LOST line) and was retried on the next pass.

Checking before the post office

Three checks before anything went into the envelope:

  • Every sticker through the station, GOOD only.
  • A registry check: no duplicate UIDs, every sticker unpaired.
  • An iPhone tap on every sticker, which has to show the "pair this sticker" screen. That proves the live server accepted the signature and the counter, while claiming nothing: the sticker isn't paired to any branch yet.

In Israel

A branch manager sticks it on the wall, taps it with their phone, and pairs it to the branch from the staff app. Pairing is permission-gated, so not every employee can do it. No PC, no reader, no SQL. From then on, staff tap to clock in and out.

What I'd tell myself on day one

  • Ask the shop before paying. One email told me the reader could do it and that I'd need my own software.
  • Test the crypto against the vendor's vectors and a simulated chip first. A wrong ChangeKey on a real chip can be permanent.
  • Install the authentication key last, and verify by reading back like a phone, not by trusting the write.
  • One process per card on macOS. PC/SC will wedge otherwise.
  • Don't lift the sticker until it says so. That is the whole reason the station talks.
  • Never rotate the master. Every sticker depends on it.