capacitor-community / background-geolocation

A Capacitor plugin that sends you geolocation updates, even while the app is in the background.
MIT License
180 stars 56 forks source link

Prevent Android GPS spoofing #48

Closed pdrhlik closed 2 years ago

pdrhlik commented 2 years ago

Is your feature request related to a problem? Please describe. It is easy to use Fake GPS apps on Android to simulate a location. It would be great to have an option to prevent this. It shouldn't be a problem with iOS because it's supposedly a lot harder if not impossible to do so.

Describe the solution you'd like If a location could be marked as isMock or something similar, that would be great.

Describe alternatives you've considered Users in my apps save locations in a certain radius to score points so I can calculate distances between these points to see if it was possible. It solves the worst cases but doesn't help me find users who are more clever and for example check time of their locations.

Additional context This SO answer offers an exact suggestion on how to deal with that - https://stackoverflow.com/questions/6880232/disable-check-for-mock-location-prevent-gps-spoofing.

pdrhlik commented 2 years ago

I made a fork of this repo and added a new isMock property to the location object that checks if a location was served from a mock provider. I tested it with these apps: Fake GPS, GPS Emulator, Fake GPS Location PROFESSIONAL and I have successfully it every time.

It always returns false on iOS since it's almost impossible to fake the location there.

It was added in b577f4e3a0f092b19a1cf4aacc049f0bec414be1 in my fork at pdrhlik/background-geolocation. Let me know if you want a PR for this or not.

diachedelic commented 2 years ago

Thanks @pdrhlik . This feature is now available in v1.1.0 and v0.3.14.