Maybe the title is badly phrased but couldn't think of a better way of saying it.
I am working on a login system at the moment (nothing formal, just experimenting) and was planning on using PHPLiveX (an AJAX library) for some features. Basically you create some PHP functions which are then called via JavaScript. You can add parameters (getElementById) to the JavaScript that are transfered to the PHP function.
What I really wanted to know is whether it is safe to just call the function from JavaScript without encrypting the password first, then letting the PHP function encrypt it (SHA256 in this case). Can the data transfered via AJAX be intercepted? If so how likely is this?
Ajax is not inherently secure or insecure. It does however open up 'opportunities' for insecure code. A mistake I commonly see is as follows: The user is authenticated in code-behind when the page is loaded.
A plain text password (or Plaintext, or Plain-text) is a way of writing (and sending) a password in a clear, readable format. Such password is not encrypted and can be easily read by other humans and machines.
Quick Answer:It is a standard practice to send "plain text" passwords over HTTPS via POST method. As we all know the communication between client-server is encrypted as per TLS, so HTTPS secures the password.
The passwords are ultimately not plaintext, since the client-server communication is encrypted as per TLS.
No more-or-less safe than a normal HTTP POST request issued by a browser (as in from a <form>
)
The "fix" for this is the same "fix" for non-AJAX requests - use SSL.
As others have mentioned, it's no more dangerous than sending an HTTP post from a form. In fact, it's the very same thing.
But if HTTPS isn't an option you can always use a challenge/response scheme over an unencrypted connection. Basically it works like this:
It's actually pretty simple to set up once you get the idea. Wikipedia has some additional information on it.
EDIT: I noticed I forgot to mention, whether or not the authentication is successful you must delete the challenge, regardless. Giving the client multiple attempts on one challenge could lead to security issues.
Whether you are sending the password via AJAX or via a normal form, it is still sent via a HTTP POST
(hopefully) request. So you are not adding or removing anything security wise.
The only way to prevent someone from intercepting your password is by using SSL (via AJAX or not).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With