Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is it a bad idea to send username and password with every request between mobile app and backend api?

I've been looking at the traffic from what is supposed to be a secure iPhone app for a work related task recently, and I've noticed that the app does not use any form for session id / token when talking to the backend. Every request contains the username, password and the device id, and all traffic is sent over https. It's a restful api, so there is no state server side.

I really feel that this is a bad idea, but i cant come up with too many good arguments for why.

If you are the victim of a man in the middle attack, the attacker can in most cases find your password when you log in, as the username and password needs to be sent to the server to obtain the session id / token anyways.

A better approach might be to send username, a timestamp and hash of timestamp and password. This server then drops the request if the timestamp is x seconds old, and the cleartext password does not have to be sent over the wire.

However, most apps i've looked at (except those who use oath and so on) just send username and password in in cleartext (over https) to obtain a token. this happens every time you start the application (both username and password are stored within the app data).

As the topic says, why is it a bad idea to send username and password with every request from a mobile/web app to the backend api, if https is used?

like image 247
randoms Avatar asked Nov 25 '14 21:11

randoms


People also ask

Why you shouldn't send passwords in a GET request?

Description: Password submitted using GET method They may be disclosed to third parties via the Referer header when any off-site links are followed. Placing passwords into the URL increases the risk that they will be captured by an attacker.

Is it a good idea to pass username and password in get?

Yes, it is bad practice. Any security advantage available by having a secret field name could also be gained by prepending that secret on to the password.

Is it safe to give passwords over the phone?

Never give your password to someone over the phone. If someone calls you and asks for your password while saying they are from the Help Desk or Tech Support team, it is an attacker attempting to gain access to your account.

What is the reason why there is need to have a username and password in accessing the system?

Passwords provide the first line of defense against unauthorized access to your computer and personal information. The stronger your password, the more protected your computer will be from hackers and malicious software. You should maintain strong passwords for all accounts on your computer.

Which is the most secure method to transmit an API key?

OAuth. OAuth is popular security mechanism that is widely used for user authentication. Similar to how a logged in session works on a website, OAuth requires the client user to “login” to the Web API before allowing access to the rest of the service. This is achieved by exposing a single endpoint for the login process.

How do I pass a username and password in REST API?

The client must create a POST call and pass the user name, password, and authString in the Request headers using the /x-www-form-urlencoded content type. The AR System server then performs the normal authentication mechanisms to validate the credentials.


1 Answers

Well, you stated it yourself. You have to store the username and password on the device itself. How secure are those credentials stored? Would a rogue application installed on the device be able to retrieve the credentials? If the rogue application is running under the same account as the valid application, it probably can. Even if you store those credentials encrypted, you'd have to store the secret on the device itself.

Also, mobile devices have a much higher likelihood of being lost/stolen, giving an attacker access to the device itself.

Another reason is that sending the username and password every time, increases the attack surface. It will give an attacker more messages with constant data to try to decrypt.

Finally, verifying passwords, when implemented correctly should be relatively slow, making it less desirable for API authentication.

Protocols like OAuth 2.0 work with access tokens that are valid a limited time and you'd have to have access to the refresh token to get a new access token. Refresh tokens can be easily revoked in case the device is lost or stolen.

like image 71
MvdD Avatar answered Sep 17 '22 07:09

MvdD