Hacking an Insecure Login Form - Lock Me Down
Quickly check your website for common security mistakes starting at your very important login page.
Join the DZone community and get the full member experience.Join For Free
setting up ssl/tls on sites has gotten easier and cheaper , but it has always been the achilles heel for a lot of web developers. one of the most common problems is not serving the login landing page over https.
developers need to understand why it is important to serve the login landing page over https and how posting the user’s credentials over https is not enough.
hacking an insecure login form
to demonstrate the vulnerabilities that can be exploited on an insecure login landing page, i stood up a microsoft azure site sslgotchas.com . on this site, the login landing page below is loaded insecurely over http.
there hasn’t been any sensitive data exchange in this simple get for the login form over http. therefore, as long as we post the users credentials over https we won’t be exposing the data in plan view/text of anyone listening (e.g. a packet sniffer https://www.wireshark.org or running a wireless adapter that supports promiscuous mode such as alpa awus036nh ).
our form will post to a secure endpoint https://sslgotchas.com as seen below:
finally, we can successfully, login after posting to the above secure route https://sslogotchas.com/account/login .
why is this a problem? by loading a page over http only to post to https, we lose one of the cornerstones of ssl/tls, integrity. ssl/tls provides integrity by ensuring that there has not been a compromise of the communication and the data in transit has not been tampered with. therefore, it leaves the communication completely open to man-in-the-middle attacks .
the man-in-the-middle can come in a number of flavors; someone sitting in your favorite starbucks with a wifi pineapple , or a malware infected computer which potentially has the ability to inject itself into the communication, again because it is unprotected over http.
we can see that indeed the script was injected by fiddler:
with the keylogger injected into the site, every 8 seconds it will capture any key presses and send the results to a completely independent site endpoint at http://stoleyourscribbles.azurewebsites.net/api/scribbles/stolen . now, don’t get hung up on the 8 seconds, that’s only what i set it to for easier display of the entries on the backend which we’ll look at next. it could be milliseconds or more often if we like.
the end result is entries in azure table storage, which in our example represent the user’s credentials (view of azure storage explorer 6 ):
i could have gotten a lot fancier and more human-consumable by rolling out the captured data to various sites and grouping it based on additional information. but the point i think is clear.
none of this would have been possible if the initial login landing page was loaded over https. in that case, the communications would be secure, and you would have preserved the integrity of the data in transit from someone manipulating the response.
don’t forget server validity
another cornerstone of ssl/tls is server validity. we’re making the assumption that the underlying endpoint where these credentials will be posted to is not only a legit server but the server that we expect. part of the handshake setting up a secure communication between the browser and the server is validating the server. that hasn’t happened, and there is no verification before these credentials are sent off to the ether.
we can put additional validations in place (such as asp.net’s [requirehttps] attribute) to ensure that resources that should be served over https can only be requested over https. or through policies such as http strict transport security (hsts) as examples of proactive measures. but, the bottom line is that even the login landing page must be served over https.
in the end, it is up to us developers to understand why serving even the login landing page over https is so important. apparently, mozilla agrees because, while i was writing this post, firefox decided to explicitly warn in their developer build ( starting in devedition 46) if you attempt to load a login page insecurely. when it comes to undermining the security of an application, it only takes finding the weakest link. in the case of circumventing the security provided by ssl, if an attacker can gain access before ssl is in place, then the damage is already done.
Published at DZone with permission of Max McCarty, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.