Tips for Ensuring Secure Web Login

Tips for Ensuring Secure Web Login

User authentication is employed by a large number of websites. However, the security of that authentication is often not properly implemented, making the websites an easier target for malicious hackers. This resulted in a thirty-percent increase in web-based attacks in 2013 (according to the Symantec Internet Security Threat Report 2013), compromising more than 93 million identities during the same year.

Having that in mind, it is a good idea to pay more attention to properly securing your website. This article shows you some tips and techniques that will reduce the risk of your website being compromised and make your site a much harder target for attackers.

Eavesdropping and tampering

Eavesdropping can be prevented by using Hypertext Transfer Protocol Secure (HTTPS). HTTPS is a protocol that uses HTTP on top of SSL in order to provide secure communication over a computer network. Unlike HTTP, which sends all the information in plaintext, HTTPS encrypts all the data that is being transmitted. The attacker could only see encrypted text, which is computationally impossible to decrypt even with the strongest available computer today.

SQL injection

SQL injection is a type of attack which occurs when the login form input is not properly filtered, allowing the attacker to alter the SQL query and authenticate himself without knowing the password. Let’s assume that you use the following query without escaping or filtering the input:

SELECT USER from database WHERE username='$username' AND password='$password'

Now, let’s say the attacker comes to your website and enters the following information in the login form:

username: 'a or 1=1--password: anything

The SQL query then becomes:

SELECT USER from database WHERE username='a' or 1=1-- AND password=''

The following query would always evaluate true, because “OR” operator returns true when at least one of the conditions is true, and 1=1 is always true. The command “–” is used for comments, meaning that the rest of the query would be ignored. In this scenario, the attacker would be authenticated and would access restricted areas and data without knowing the correct username/password combination.

This is just one example of SQL injection. Some weaknesses of this type may allow attacker to retrieve a whole SQL table.

SQL injection can be prevented using mysqli prepared statements. Here is a sample code in PHP:

$stmt = $mysqli->prepare("INSERT INTO users (name, age) VALUES (?,?)");// bind parameters. I'm guessing 'string' & 'integer', but read documentation.$stmt->bind_param('si','one',1);// *now* we can execute$stmt->execute();

Note that SQL injection prevention should not be done only on the login form, but site-wide.

Data breach

Although you have implemented HTTPS and secured the login from SQL injection, there are other ways that can lead to your data being available to the attackers ? attacks on your hosting provider, someone from your company working for the attackers, etc. Whatever the reason, the security risk must be minimized in this worst-case scenario.

The first and the most important thing is not to store passwords as plain text, as all accounts would be compromised in that case. Store them using a one-way hash function. Hash functions are not reversible, meaning that the attacker would have to hash all possible passwords and then if the two hashes match, he would have found the password. Using Bcrypt for storing passwords is recommended for several reasons. First, salt (a fixed number of random characters) is added to the password, making the attack using rainbow tables (hash lookup tables which increase the speed and effectiveness of a brute-force attack) impossible. Second, Bcrypt is an iterative function ? after the password has been hashed, the same process is repeated for a fixed number of times before storing the hash into the database. When a user is logging in, there is a delay that lasts a fraction of a second, but that same delay can significantly slow down a brute-force attack. For example, with 0.008 second delay, the attacker could only test 125 passwords per second, which is 10800000 passwords per day. This is a great result compared to other hash algorithms, which can be tested for hundreds of millions of passwords per second (oclHashcat – advanced password recovery). The number of iterations that you should use depends on your server’s CPU strength, sensitivity of your data, etc. This page can help you calculate it.

Brute-force attack

This type of attack is very simple ? it involves trying all possible username/password combinations until the right one is found. Unlike the movies, where the passwords are guessed manually, brute-force attack usually relies on software to make the guessing process faster.

To decrease the risk of a brute-force attack on web login forms, it is recommended to use a strict password policy ? users can be required to use a password that is minimum 6 characters, that needs to have mixed case and both letters and numbers, and that they need to change the password after a certain time has passed. Also, some (common and easy passwords should be blocked. Users should be asked a security question upon registration, and if there are three unsuccessful login attempts, block further login attempts until the question has been answered. Also, IP addresses can be blocked after a number of unsuccessful attempts, but be careful with this, as you could accidentally block ISPs or company’s proxy server.

Since the attackers usually use software for brute-force attack, there are some techniques that can confuse their computer. A good solution is not to use predictable behavior for failed passwords. For example, most Web sites return an “HTTP 401 error” code with a password failure, although some web sites instead return an “HTTP 200 SUCCESS” code but direct the user to a page explaining the failed password attempt. This fools some automated systems, but it is also easy to circumvent. A better solution might be to vary the behavior enough to eventually discourage all but the most dedicated hacker. You could, for example, use different error messages each time or sometimes let a user through to a page and then prompt him again for a password.

Session hijacking

Session keys and session cookies are used to pass authentication information between the pages of a website and remember users’ login information. Session hijacking refers to stealing this key and obtaining unauthorized access to the restricted area without knowing the username/password combination. There are several types of session hijacking attacks.

A user’s session can be stolen by intercepting the communication between the user and the website’s server and extracting session key from it. This is called session sniffing and can be prevented by using encryption, i.e. using HTTPS.

If the session key is not long enough, an attacker could guess the session key by trying all possible combinations. Use a long random number or string as the session key.

Session keys can be compromised by cross-site scripting (XSS) vulnerabilities. XSS is possible when input is not properly filtered, so it is possible to execute JavaScript code that is entered into an input field. If an attacker sends a crafted link to the victim with the malicious JavaScript, when the victim clicks on the link, the JavaScript will run and complete the instructions made by the attacker.

Other good practices to prevent session hijacking include: regenerating session key after successful login, secondary user identity checks (does the current IP address and browser match the ones used during the last session), and regenerating session keys with each request or every 15 minutes.

Cross-site request forgery (CSRF)

CSRF is an attack which forces an end user to execute unwanted actions on a web application in which he/she is currently authenticated. With a little help of social engineering (like sending a link via email/chat), an attacker may trick the users of a web application into executing actions of the attacker’s choosing. A successful CSRF exploit can compromise end user data and operation in the case of a normal user. If the targeted end user is the administrator account, this can compromise the entire web application.

The most effective CSRF counter-measure is to use a random token that is associated with the user’s current session whenever the user wants to execute an operation on the site. The token would be included in the HTML form:

Whenever a request to transfer.php is submitted, the first thing to be checked is if there is a CSRFToken and if that token is valid.

Websites that need strict security should avoid the “remember me” option and should automatically log users out after a certain time of inactivity (usually 15 minutes). Also, they should ask a user to re-enter a password when a sensitive operation is invoked (e.g. money transfer, settings change, etc.).

Secure web login cheat sheet

? Use HTTPS with an up-to-date version of SSL
? Prevent MySQL injection on whole website by using mysqli prepared statements and binding
? Store passwords as one-way hash function. Use bcrypt for this
? Use both dynamic (different for each user) and static salt values when generating a password hash
? Enforce minimum password length ? 6 or 8 characters
? Enforce using mixed case letters and numbers in passwords
? Require password change every 6 months
? Disallow using most common passwords as a password
? After 3 unsuccessful login attempts, ask the secret question (which user choose upon registration) and disallow further login attempts until the question is answered
? Consider blocking IP addresses after a certain number of unsuccessful login attempts
? Use unpredictable behavior for failed passwords to fool automated brute-force tools ? Use long random number or string as the session key
? Filter input properly in order to prevent XSS (cross-site scripting) vulnerabilities
? Regenerate session key after the user has logged in
? Use a random token that is associated with user’s current session whenever a user wants to execute an operation on the site

?

devx-admin

devx-admin

Share the Post:
Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023,

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed

Poland Energy Future

Westinghouse Builds Polish Power Plant

Westinghouse Electric Company and Bechtel have come together to establish a formal partnership in order to design and construct Poland’s inaugural nuclear power plant at the Lubiatowo-Kopalino site in Pomerania.

EV Labor Market

EV Industry Hurting For Skilled Labor

The United Auto Workers strike has highlighted the anticipated change towards a future dominated by electric vehicles (EVs), a shift which numerous people think will result in job losses. However,

Soaring EV Quotas

Soaring EV Quotas Spark Battle Against Time

Automakers are still expected to meet stringent electric vehicle (EV) sales quotas, despite the delayed ban on new petrol and diesel cars. Starting January 2023, more than one-fifth of automobiles

Affordable Electric Revolution

Tesla Rivals Make Bold Moves

Tesla, a name synonymous with EVs, has consistently been at the forefront of the automotive industry’s electric revolution. The products that Elon Musk has developed are at the forefront because

Sunsets' Technique

Inside the Climate Battle: Make Sunsets’ Technique

On February 12, 2023, Luke Iseman and Andrew Song from the solar geoengineering firm Make Sunsets showcased their technique for injecting sulfur dioxide (SO₂) into the stratosphere as a means

AI Adherence Prediction

AI Algorithm Predicts Treatment Adherence

Swoop, a prominent consumer health data company, has unveiled a cutting-edge algorithm capable of predicting adherence to treatment in people with Multiple Sclerosis (MS) and other health conditions. Utilizing artificial

Personalized UX

Here’s Why You Need to Use JavaScript and Cookies

In today’s increasingly digital world, websites often rely on JavaScript and cookies to provide users with a more seamless and personalized browsing experience. These key components allow websites to display

Geoengineering Methods

Scientists Dimming the Sun: It’s a Good Thing

Scientists at the University of Bern have been exploring geoengineering methods that could potentially slow down the melting of the West Antarctic ice sheet by reducing sunlight exposure. Among these

why startups succeed

The Top Reasons Why Startups Succeed

Everyone hears the stories. Apple was started in a garage. Musk slept in a rented office space while he was creating PayPal with his brother. Facebook was coded by a

Bold Evolution

Intel’s Bold Comeback

Intel, a leading figure in the semiconductor industry, has underperformed in the stock market over the past five years, with shares dropping by 4% as opposed to the 176% return

Semiconductor market

Semiconductor Slump: Rebound on the Horizon

In recent years, the semiconductor sector has faced a slump due to decreasing PC and smartphone sales, especially in 2022 and 2023. Nonetheless, as 2024 approaches, the industry seems to

Elevated Content Deals

Elevate Your Content Creation with Amazing Deals

The latest Tech Deals cater to creators of different levels and budgets, featuring a variety of computer accessories and tools designed specifically for content creation. Enhance your technological setup with

Learn Web Security

An Easy Way to Learn Web Security

The Web Security Academy has recently introduced new educational courses designed to offer a comprehensible and straightforward journey through the intricate realm of web security. These carefully designed learning courses

Military Drones Revolution

Military Drones: New Mobile Command Centers

The Air Force Special Operations Command (AFSOC) is currently working on a pioneering project that aims to transform MQ-9 Reaper drones into mobile command centers to better manage smaller unmanned

Tech Partnership

US and Vietnam: The Next Tech Leaders?

The US and Vietnam have entered into a series of multi-billion-dollar business deals, marking a significant leap forward in their cooperation in vital sectors like artificial intelligence (AI), semiconductors, and

Huge Savings

Score Massive Savings on Portable Gaming

This week in tech bargains, a well-known firm has considerably reduced the price of its portable gaming device, cutting costs by as much as 20 percent, which matches the lowest

Cloudfare Protection

Unbreakable: Cloudflare One Data Protection Suite

Recently, Cloudflare introduced its One Data Protection Suite, an extensive collection of sophisticated security tools designed to protect data in various environments, including web, private, and SaaS applications. The suite

Drone Revolution

Cool Drone Tech Unveiled at London Event

At the DSEI defense event in London, Israeli defense firms exhibited cutting-edge drone technology featuring vertical-takeoff-and-landing (VTOL) abilities while launching two innovative systems that have already been acquired by clients.

2D Semiconductor Revolution

Disrupting Electronics with 2D Semiconductors

The rapid development in electronic devices has created an increasing demand for advanced semiconductors. While silicon has traditionally been the go-to material for such applications, it suffers from certain limitations.

Cisco Growth

Cisco Cuts Jobs To Optimize Growth

Tech giant Cisco Systems Inc. recently unveiled plans to reduce its workforce in two Californian cities, with the goal of optimizing the company’s cost structure. The company has decided to

FAA Authorization

FAA Approves Drone Deliveries

In a significant development for the US drone industry, drone delivery company Zipline has gained Federal Aviation Administration (FAA) authorization, permitting them to operate drones beyond the visual line of

Mortgage Rate Challenges

Prop-Tech Firms Face Mortgage Rate Challenges

The surge in mortgage rates and a subsequent decrease in home buying have presented challenges for prop-tech firms like Divvy Homes, a rent-to-own start-up company. With a previous valuation of

Lighthouse Updates

Microsoft 365 Lighthouse: Powerful Updates

Microsoft has introduced a new update to Microsoft 365 Lighthouse, which includes support for alerts and notifications. This update is designed to give Managed Service Providers (MSPs) increased control and

Website Lock

Mysterious Website Blockage Sparks Concern

Recently, visitors of a well-known resource website encountered a message blocking their access, resulting in disappointment and frustration among its users. While the reason for this limitation remains uncertain, specialists