An unexpected code-breaking challenge

An unexpected code-breaking challenge

I've just been using the Scandinavian Airlines app to check us in to our flights. Unexpectedly, it turned into a code-breaking challenge!

In the SAS app you can check in. There's also a function to scan your passport as part of checking in. For the first time, for me, this had been enhanced to include scanning the chip on your passport.

Scanning passport details using the phone camera has been available in the app for a while, and generally worked ok. Sometimes it would get the passport number wrong, but it usually worked.

This time though, with the added chip-scanning step, it was a total failure. It just couldn't get the expiry date right.

But how...? Why...? How can it be wrong when they are reading the ACTUAL DATA directly from the passport?

I ploughed on and did all three of our passports. After each one, I started to notice a pattern. After scanning all three, I'm now pretty sure what is happening and it's quite an impressive bug!

Say you've got a passport expiry of 28 FEB 2027.
This ends up as 02 APR 2029.

Say you've got an expiry date of 06 MAR 2025.
This ends up as 03 JUNE 2025.

Say you've got an expiry date of 23 MAY 2029.
This ends up as 05 NOV 2030.

I've inserted a picture of some cake here to create a pause to see if you can work what is happening before continuing to read my explaination and what happened next.

A slice of twelve layered cocolate cake with some raspberries on top

Explaination

When the passport expiry is getting read, the date and the month are getting swapped. So the month is getting used as the day. The day though is getting used as the month, but for each multiple of twelve, an extra year gets added to the year.

The remainer then gets used as the month. Which is why 23 ends up as NOV (12+11) and 28 ends up as FEB (12+12+4).

I remember doing these kinds of puzzles as part of employment interviews back in the days when I used to be a developer! So, thanks SAS for giving me a bit of holiday entertainment with the bug in your app 😄 .

Update:

After I posted this on LinkedIn, a member of the team at SAS working on the app added a comment confirming it was a locale issue, saying they are working on a fix and that a new release will be made soon.

I had speculated elsewhere that the issue was probably caused by a locale issue. I was in the UK at the time with UK English as the language on my phone. It's left like a reasonably explaination that SAS had only tested this with Swedish and perhaps US English - and not a more respresentitive set of locales.

The machine readable zone of the passport chip stores the date of expiry as YYMMDD. So anything that goes wrong with the date is going to be the fault of processing, and given the nature of this bug - that it made the feature completely unusable for me - it felt likely that this was something that had slipped through the net due to insufficient testing. Alternatively, you could argue, it was insufficient understanding of the wider world the app would be used in.

Then, I had some flashbacks. Somewhere in the caverns of my mind, I could hear a developer crying out "works for me".

Update 2024-07-27:

SAS have released an app update for both Android and iPhone. Interestingly though the release notes say they have fixed an issue with the date of birth. I can't recall there being an issue with the date of birth, so hopefully they've actually fixed the problem with the expiry date!

Screenshot from Google Play with the release notes for the SAS application. The "What's new" text says: Resolved an issue with passport scanning on certain devices that cause the date of birth to be incorrectly recorded."

James Royal-Lawson - Senior digital advisor · Designer · Digital analyst · Economist · Podcaster

Machine-readable passport - Wikipedia
Locale (computer software) - Wikipedia
The “Works on My Machine” Certification Program
Joseph Cooney had a brilliant idea for a new application certification program [http://jcooney.net/archive/2007/02/01/42999.aspx]. But Vista’s bland white-on-gray badge, in my opinion, doesn’t properly communicate the.. authoritative.. nature of said program. With the help of Jon Galloway [http://weblogs.asp.net/jgalloway/], we