0

I'm looking for a way to design

Mobile APP <--> Server API which:

  • authorize user and app for work with server using OAuth2.0
  • validate on server, that it's legitimate application

Problem I face now: Application in Oauth2.0 terminology is a public clients: there is no way to secure any static information in application bundle - any one can extract such info and reuse it in fake application.

And if I add some additional method for register new instance of application on Server - there is nothing stop fake application from doing the same thing.

Is there ANY way to exchange data between Application and Server without involving REST API, or get verified information aboute calling application.

I know that answer is platform specific - I'm interesting in information on any platform as I can search analog for others.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
cgi
  • 190
  • 1
  • 8

2 Answers2

1

For mobile apps use Authorization Code Flow (PKCE) which generates a runtime secret, so that there's no need for a fixed one to be deployed with the app.

A rogue app can potentially use the Client Id and Redirect URI of your app, but one way to deal with that is to use Claimed HTTPS Scheme Based Redirects, as recommended in Financial Grade APIs / Native Apps.

If interested in this approach, my blog has a couple of detailed examples:

Gary Archer
  • 22,534
  • 2
  • 12
  • 24
  • Thanks for idea, but PKCE doesn't verify public application. It's just remove fixed secret, but fake application steel can use client_id of real application. – cgi Dec 22 '20 at 05:38
  • If you use Claimed HTTPS Scheme redirects, then an app trying to use your client id will not be able to receive a login response - I've updated my original answer (and the links) above. – Gary Archer Dec 22 '20 at 09:49
  • Thanks for clarifications, wil look for claimed HTTPS Schemes – cgi Dec 22 '20 at 13:00
0

The Difference Between WHO and WHAT is Accessing the API Server

I'm looking for a way to design

Mobile APP <--> Server API which:

  • authorize user and app for work with server using OAuth2.0 <--- WHO
  • validate on server, that it's legitimate application <--- WHAT

Before I dive into your questions I would like to first clear a misconception that I usually find among developers of any seniority, that is about the difference between who and what is accessing an API server

I wrote a series of articles around API and Mobile security, and in the article Why Does Your Mobile App Need An Api Key? you can read in detail the difference between who and what is accessing your API server, but I will extract here the main takes from it:

The what is the thing making the request to the API server. Is it really a genuine instance of your mobile app, or is it a bot, an automated script or an attacker manually poking around your API server with a tool like Postman?

The who is the user of the mobile app that we can authenticate, authorize and identify in several ways, like using OpenID Connect or OAUTH2 flows.

Think about the who as the user your API server will be able to Authenticate and Authorize access to the data, and think about the what as the software making that request in behalf of the user.

So, you need to bear in mind that the guarantee that you know who is in the request cannot guarantee you that the request comes indeed from what your API server expects, a genuine and unmodified version of your mobile app.

Possible Solution

And if I add some additional method for register new instance of application on Server - there is nothing stop fake application from doing the same thing.

Is there ANY way to exchange data between Application and Server without involving REST API, or get verified information aboute calling application.

If your API server can have a high degree of confidence that the request are indeed from what it expects, a genuine and unmodified version of you mobile app then registering a new instance of the application and exchanging data with the API server can be done with the confidence that a bad actor is not involved.

You can resort to UBA and RASP solutions to help you with knowing what is making the API requests:

UBA - User Behavior Analytics:

User behavior analytics (UBA) as defined by Gartner is a cybersecurity process about detection of insider threats, targeted attacks, and financial fraud. UBA solutions look at patterns of human behavior, and then apply algorithms and statistical analysis to detect meaningful anomalies from those patterns—anomalies that indicate potential threats. Instead of tracking devices or security events, UBA tracks a system's users. Big data platforms like Apache Hadoop are increasing UBA functionality by allowing them to analyze petabytes worth of data to detect insider threats and advanced persistent threats.

RASP:

Runtime application self-protection (RASP) is a security technology that uses runtime instrumentation to detect and block computer attacks by taking advantage of information from inside the running software.

RASP technology is said to improve the security of software by monitoring its inputs, and blocking those that could allow attacks, while protecting the runtime environment from unwanted changes and tampering.

UBA is based on negative identification models that do their best to differentiate the bad from the good by identifying what is bad, not what is good, thus they are prone to false positives. The UBA solution is based on analyzing each API request and they don't have client side realtime intelligence gathering from whats going on the mobile app and its device.

RASP solutions are client side, and the API server has no visibility for what they are detecting and blocking. Once they are client side they can be bypassed without the API server know it happened, therefore it will accept the API requests from this bypass.

I recommend you to read this answer I gave to the question How to secure an API REST for mobile app?, especially the sections Hardening and Shielding the Mobile App, Securing the API Server and A Possible Better Solution.

So, the possible better solution section in the linked answer mentions the use of a Mobile App Attestation solution that will combine realtime background communication between a cloud service and the mobile app to attest the mobile app is genuine and unmodified, and that is running in a trusted device. The API server will then be able to know with a very high degree of confidence that what is making the request is indeed a genuine and unmodified version of the mobile app running in a trusted device.

Do You Want To Go The Extra Mile?

In any response to a security question I always like to reference the excellent work from the OWASP foundation.

For APIS

OWASP API Security Top 10

The OWASP API Security Project seeks to provide value to software developers and security assessors by underscoring the potential risks in insecure APIs, and illustrating how these risks may be mitigated. In order to facilitate this goal, the OWASP API Security Project will create and maintain a Top 10 API Security Risks document, as well as a documentation portal for best practices when creating or assessing APIs.

For Mobile Apps

OWASP Mobile Security Project - Top 10 risks

The OWASP Mobile Security Project is a centralized resource intended to give developers and security teams the resources they need to build and maintain secure mobile applications. Through the project, our goal is to classify mobile security risks and provide developmental controls to reduce their impact or likelihood of exploitation.

OWASP - Mobile Security Testing Guide:

The Mobile Security Testing Guide (MSTG) is a comprehensive manual for mobile app security development, testing and reverse engineering.

Exadra37
  • 11,244
  • 3
  • 43
  • 57