I know that security either does not exist or is very complex in client-side JavaScript. I know that my server code should ultimately decide to whom it sends data or receives data.
However, this is normal. By โokayโ I mean if it were a method used in some new popular trendy cool web application. Can I sleep at night knowing that I won't see the โSuper Cool Web App Hacked, Change Your Passwords!โ throughout HN and Reddit (or any other sources of information that people care about) as a result of this implementation.
If it is not safe. What for? How to get this information (username and password)?
If it is safe? How are you sure? Why is it safe? What is stopping me from getting this information beyond my apparent inability right now.
Partial responses are welcome. Just look for a better understanding.
EDIT
I think that some are trying to steal user credentials. My understanding is that cookies are unsafe because 1.) other javascripts (via XSS or something else) can access them, but because 2.) they are transmitted in clearness. I believe that SSL will take care of the second problem and suggests that I can prevent XSS. Now it would seem that cookies are now safe, right?
I am aware of some of the alleged browser vulnerabilities that help make cookies insecure. It made me ask this question. Given everything that makes cookies insecure, is this better (code below)?
http://jsfiddle.net/KTastrophy/vXEjm/1/ OR see code below (Checked only in Chrome)
<!DOCTYPE html> <html> <head> </head> <body> <form id="login"> <div> <label for="username">Username</label> <input id="username" name="username" type="text" /> </div> <div> <label for="password">Password</label> <input id="password" name="password" type="password" /> </div> <div> <input id="submit" name="submit" type="submit" value="Login" /> </div> </form> </body> <script type="text/javascript"> ;(function () { "use strict"; var login, user = {}; login = document.getElementById("login"); login.onsubmit = function (event) { event.preventDefault(); user.username = document.getElementById("username").value; user.password = document.getElementById("password").value; } }()); </script> </html>
source share