The Information is reporting today on Apple’s five-year struggle to tackle iPhone repair fraud. The scheme centres around crime gangs who were buying or stealing iPhones, removing valuable parts like CPUs and screens, and then claiming their devices were broken at Apple Stores and getting the Genius to replace them under warranty. The parts were then sold on.

At its peak, Apple was seeing 60% of warranty repairs in China and Hong Kong as being fraudulent, literally costing Apple billions of dollars per year. Apple first started taking the problem seriously in 2013, and the report goes on to detail the cat and mouse game that then ensued between the criminals and Apple as the company tried to tackle iPhone repair fraud …

Apple retail had taken a very laid back approach, swapping out faulty iPhones as long as they didn’t appear to be intentionally damaged. It had been estimated by executives that fraud represented less than 10% of claims.

However, in 2013, an Apple data scientist counted the number of iPhones that switched Apple IDs after being repaired. This provided a very good estimate of the number of fraudulent replacements, as legitimate customers would naturally log back in to the same Apple ID they were already using. Criminals getting repairs for stolen iPhones lit up like red flags across Apple’s system. The problem of iPhone repair fraud was finally taken seriously inside Apple.

This counting showed the actual reality; more than 60% of repairs in China were fraudulent. The Information says that in the 2013 financial year, Apple had set aside $1.6 billion for warranty repair costs. The company ended up spending $3.7 billion in that period, with much of that gap explained by Chinese fraud.

Initially, Apple stopped allowing walk-in repairs and required reservation systems that supposedly ensured proof of ownership was provided. The system was beaten by hackers who exploited vulnerabilities in the web system who sniped all the time slots.

Apple then required candidate iPhone devices to run software diagnostics which would identify any fake parts inside, without requiring store staff to disassemble components and perform inspections. The thieves circumvented this by simply making the iPhones not turn on.

Some criminals were even more sophisticated. They acquired Apple customer records for iPhones that had already been sold, and then configured their fake iPhones to report these already sold serial numbers, including physical etching. This would fool Apple into providing warranty repairs for iPhones that should really already have expired coverage.

Apple adapted, but the fraudsters were relentless. In one particularly violent case, a manager at an Apple Store was threatened with a cattle prod when criminals tried to bribe out customer data.

Apple now requires all warranty iPhone replacements to be sent off to special repair centers that can do more rigorous testing. Apple even added security measures to its iPhone components, including invisible dyes on batteries, and coating iPhone CPUs in special waterproof sealants that are tuned to specific wavelengths.

The Information report blames Apple’s internal secrecy as one reason why it took Apple so long to get on top of this problem. It took time for supply chain logistics, manufacturing and AppleCare departments to collaborate and work together on meaningful solutions.

It took almost five years, but it seems like Apple’s practices is finally countering the criminals and iPhone repair fraud is being reduced. It is now estimated that fraudulent repairs in China have dropped from the peak of 60% to about 20%. However, Apple is now facing similar issues in other markets, like Turkey and the United Arab Emirates. It’s a never-ending war for the world’s biggest company.