An unexpected code-breaking challenge
I've just been using the Scandinavian Airlines app to check me and my family in to our flights back to Sweden. 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 explanation and what happened next.
Explanation
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 remainder then gets used as the month. Which is why 23 ends up as NOV (12+11) and 28 ends up as APR (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 felt like a reasonably good explanation that SAS had only tested this with Swedish and perhaps US English - and not a more representative 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!