Software Development

Landscapes in Mobile Application Security

There are different aspects in Cloud and Mobile application security – and in different angles you can look in to it.

Within the first decade of the 21st century – internet worldwide increased from 350 million to more than 2 billion and Mobile phone subscribers from 750 million to 5 billion – and today it hits 6 billion mark – where the world population is around 7 billion. Most of the mobile devices out there – even the cheapest ones could be used to access the internet.

Let me do a quick survey here. How many of you have, password protected your laptops? Answer is obvious – almost all. But do you know that only 30% of mobile users, password protect their mobile devices ? This leaves out 4.2 billion mobile devices – unprotected – out there. I am using multi-factor authentication to secure my corporate email account on Google Apps. I am using world’s deadliest – the most complex password ever to protect my corporate Salesforce account. Now what ? I leave my mobile phone unprotected. I am already logged in to Google Apps – I am already logged in to Salesforce. Now I leave all my confidential information accessible to anyone having access to my mobile device.

How about password reset? Google, Microsoft, Yahoo – and almost all cloud service providers use mobile phone based password resets. Having temporary access to your mobile device, someone can take your accounts for the life time.

Multi-factor authentication for mobile applications is also not well thought yet. That is mostly because with the false assumption – “My mobile is under my control always”. 113 cell phones are lost or stolen every minute in the U.S and $7 million worth of smartphones are lost daily. Both Google step-2 authentication and Facebook Code Generator always rely on a mobile phone for protecting web based access. But, none of their mobile applications are protected with multi-factor authentication. Phone based multi-factor authentication won’t work for mobile applications.

Why do we need to worry about all these at the corporate level? 62% of mobile workers currently use their personal smartphones for work.

Screen Shot 2013-10-31 at 4.46.57 AM

These are well known facts or threats in the mobile world. Different vendors have their own solutions. Apple let you lock your device over the Internet or even wipe off  all it’s data. And again most of the mobile device management (MDM) solutions let you take control over your lost device. But, then again – how much time you leave for it to be on wrong hands will do enough damage. MDM solutions out there need to go beyond it’s simple definition to be an integral part of the corporate Identity Management system.

Over the last few years – almost – all the cloud service providers are becoming mobile friendly. All of them have provided RESTful JSON based APIs. Amazon AWS, Google Cloud Storage, Salesforce, Dropbox all of them have REST APIs . Except AWS – all the others are secured with OAuth 2.0. AWS uses its own authentication scheme.

OAuth 2.0 has ‘proven success’ in securing REST APIs. But for mobile applications OAuth 2.0 can be miserably misleading. It has four defined grant types. Authorization Code, Implicit, Resource Owner Password and Client Credentials.

Authorization code and the implicit are mostly being used for browser based applications. Its a mis-belief among application developers, that the Resource Owner and the Client Credentials grant types are for mobile applications. Those require you to provide your credentials to the application – directly. As a practice avoid it. If you develop a mobile application to access a secured cloud API using OAuth – use either the authorization code or the implicit grant type. There, your application needs to pop-up the native browser to redirect the user to the OAuth authorization server.

But – still that does not make you 100% not vulnerable to further attacks. Whenever there is a redirection through the browser – there is a possibility of a phishing attack. A rogue OAuth client application can have a “Login with Facebook” button – which will redirect you to a rogue OAuth authorization server – which looks like Facebook – where you will misinterpret it as Facebook and give away the credentials.

There are many countermeasures that can be taken against phishing. But, sadly – most of the OAuth authorization servers, including Facebook and Twitter do not follow any. Your Facebook or Twitter account credentials can be quite easily phished through your mobile phone – than from a laptop computer. It’s quite easier than you think.

If you have developed mobile applications with OAuth 2.0 – you might have encountered another limitation. You need to bake in – your client key and the client secret into the mobile application itself. This is required in the first phase of the OAuth flow – and it’s the identification of the client to the OAuth authorization server. What would happen if someone steals this from the device ?

Let’s have a look at an example. We have a mobile application which will access the Facebook friend list of an end user and stores that friend list in Google Cloud Storage using its REST API. Facebook friend list belongs to the end-user – but the Google Cloud Storage belongs to the mobile application. Mobile application has to register with Facebook as an OAuth client and gets a client key and a secret. Then using Authorization Code grant type – it can get an access token to – access the end-users friend list on-behalf of him. To store this in Google Cloud Storage, the application has to use client credentials grant type – where the authorization server is Google. To get this done – we need to bake-in the client key and the client secret into the application itself. Anyone getting access to these keys, will get access to the Google Cloud Storage too. This is an area still under research with no permanent solution yet. Solutions over there like – restrictions based on IP addresses, device Ids – will only make things bit harder – but, not fully impossible.

OAuth 2.0 has become the de facto standard for mobile application authentication. This, it self has given the applications a better failover capability in case of an attack. The recent attack against Buffer – a social media management service, which lets users cross-post in to social networking sites like Facebook and Twitter – is a very good example. Twitter, Facebook got flooded with posts from Buffer. But revoking the client key of Buffer sorted out the issue. And also attack on Buffer did not give the full control of users’ Facebook and Twitter accounts to attackers – as it was not storing passwords.

It takes an average of 20 seconds for a user to log into a resource. Not having to enter a password each time a user needs to access a resource saves time and makes users more productive and also reduces the frustration of multiple log-on events and forgotten passwords. Users only have one password to remember and update, and only one set of password rules to remember. Their initial login provides them with access to all resources, typically for the entire day or the week.

What are the challenges in building a single sign-on solution for mobile applications ?

If you provide multiple mobile applications for your corporate employees, to be installed in their mobile devices – its a pain to ask them to relogin to each application separately. Possibly all of them may be sharing the same user store. This is analogous to a case where Facebook users login into multiple third party mobile applications with their Facebook credentials.

In mobile world – this can be done in two ways.

First, each native mobile application – when it is needed to authenticate a user  – should popup the native browser – and start the OAuth flow. Your company should have a centralized OAuth authorization server, running on top of the corporate user store. All your mobile applications will redirect the user to the same Authorization Server – creating a single login session under the domain of the centralized authorization server – which indirectly facilitates single-sign on.

Screen Shot 2013-10-31 at 4.48.07 AM

Screen Shot 2013-10-31 at 4.50.40 AM

The other approach is known as “Native SSO”. The user experience in Native SSO is very much better than the browser based SSO. Here you need to have a native mobile application developed for the corporate identity provider (IdP) – or the authorization server – which will be invoked by the other applications to initiate the OAuth flow – instead of popping up the browser. Although Native SSO provides better – improved user experience – it also makes phishing attacks much easier.

Screen Shot 2013-10-31 at 4.51.27 AM

Screen Shot 2013-10-31 at 4.52.15 AM

The other drawback in Native SSO is – it has a phase – which is not standard based. Your application should know beforehand who your Identity Provider is – and should program according to it’s interface to initiate Native SSO. Currently there is an attempt by OpenID Foundation to  build a standard Single Sign On (SSO) model for native applications installed on mobile devices. This introduces an OpenID Connect Client called an Authorization Agent – which  can obtain tokens on behalf of other installed native applications – thereby provisioning tokens to those applications and so enabling a Single Sign On experience for end users. The spec is at its very initial stage – and would require many more iterations before becoming a standard.

Lets take another example. Previous case we had an assumption that we only have a single user store – which is behind the centralized authorization server. Let’s take that assumption out. We need users outside our domain – say, from federated partners – to access our mobile applications and consume services. There needs to be a bootstrap process to establish trust between those federated partners and our authorization server. Doing this in a standard manner – the partners would require to support one of the federation standards out there. The best would be the SAML. So – we need to add partner SAML IdPs as trusted IdPs to our authorization server. And also we can define an authorization policy against each IdP – so that we know which rights they would have in our authorization server. When user being redirected to the authorization server – either through browser based or native SSO – he can pick against which IdP he wants authenticate. Based on the choice the user will be redirected to his home SAML IdP – and once authenticated – authorization server will resume the OAuth flow. This is a one time thing – and for other subsequent requests from other mobile applications – flow will be seamless to the user and would not required to being redirected to his home SAML IdP.

Screen Shot 2013-10-31 at 4.54.36 AM

With all the Single Sign On use cases we discussed above – we still left with one more assumption – all the mobile applications will have a centralized authorization server. Let’s get rid of  that too.

One key requirement for any single sign on scenario is – we should be able to establish direct trust or brokered trust between applications and their users. In most of the cases this is established through IdPs. The first example we took was based on direct trust – while the second is on brokered trust. To accomplish this use case we need to build a trust relationship between all the authorization servers – taking part in – and also a middle man to mediate SSO. This use case is also highlighted in the Native SSO draft specification by OpenID Foundation – but no much details as of now.

Data in transit is another security concern. Forget about NSA and Angela Merkel. NSA has more than 5000 highly capable computer scientists – and they have control over security algorithm designs. So, lets take NSA out of the picture. In most of the scenarios mobile applications depend on TLS for data confidentiality, in transit. TLS has it’s own limitations as its based on transport and the confidentiality of the data terminates as it leaves the transport. Most of the data transport channels used within mobile applications use REST and JSON. We have JOSE working group under IETF,  working currently to produce a standard for doing message level encryption and signing for JSON payloads.

Let me take this discussion to another direction. Managed Cloud APIs. Amazon AWS, Google Cloud, Dropbox, Salesforce all expose APIs over REST and JSON. Even in this case, Twitter and Facebook. We develop mobile applications on top of these cloud APIs – to be used by our corporate employees. For the simplicity of explaining – I’ll take Twitter as the example. We have a corporate account with Twitter – which is used to tweet events related to the company – and mostly used by the marketing team. To tweet through the corporate account we need to share the official twitter password with them. Which is not ideal. Can’t we let them tweet through the same corporate account – but still authenticate with their corporate LDAP credentials ? And also – we need to enforce certain rules and policies. Any tweet mentioning client names should be blocked immediately. Also we need to collect statistics and do access controlling. In other words – to cater for all these requirements we need to turn the simple Twitter API – in to a managed API. Here we introduce an API Gateway – in between your mobile application and the Twitter API. Through API gateway we expose – our own API – which wraps the Twitter API. Now – the marketing team can authenticate to the Twitter Wrapper API using their corporate credentials and Tweet using the corporate Twitter account. The official Twitter credentials are never exposed – and kept just within the API Gateway. Twitter is a simple example – but the same applies to any cloud API – which you want to turn into a Managed Cloud API – to be consumed by your mobile applications.

Screen Shot 2013-10-31 at 4.55.53 AM
 

Reference: Landscapes in Mobile Application Security from our JCG partner Prabath Siriwardena at the Facile Login blog.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button