Back to Blog
Cybersecurity

Building a Strong Foundation for Website Login Security

Learning the standards and basics of security in web application authentication processes. Discussing password hashing, HttpOnly cookies, brute force prevention, and session management best practices based on OWASP standards.

Bcrypt HashingJWTHttpOnly CookiesRate LimitingMFA / 2FA
Ilustrasi gembok digital dan kode biner menyala hijau
Sistem autentikasi yang tangguh merupakan gerbang utama pelindung data perusahaan. · © Dan Nelson

Cryptography: Hash Passwords, Not Plain Text

The first and most non-negotiable rule in application development is never to store passwords in plain text. If the database leaks, attackers wouldn't need to perform any decryption to immediately hijack millions of user accounts.

Utilize one-way hashing algorithms such as Bcrypt or Argon2. These algorithms are designed with unique 'salt' mechanisms for each password and feature adjustable slow computation times (work factor). This makes dictionary attacks or brute-force cracking attempts incredibly slow and computationally inefficient.

Storing Tokens in HttpOnly Cookies

A common practice when using JSON Web Tokens (JWT) in modern frameworks is storing them in the browser's Local Storage. Unfortunately, Local Storage can be directly accessed via JavaScript, rendering it a prime target if the application suffers from Cross-Site Scripting (XSS) vulnerabilities.

According to OWASP security standards, authentication tokens should be transmitted and stored in cookies configured with strict flags: HttpOnly, Secure (HTTPS only), and SameSite. This way, no client-side JavaScript can read the token, drastically reducing the risk of session hijacking.

Rate Limiting Against Brute Force

A secure login system must detect and restrict repeated login attempts (Rate Limiting). Without rate limiting, automated bots could test thousands of password combinations per second (Brute Force) or use stolen databases from other breaches (Credential Stuffing).

  • Implement temporary account lockouts after 5 consecutive failed attempts.
  • Use exponential backoff mechanisms: the more failures, the longer the mandatory waiting period.
  • Add security layers like invisible CAPTCHA challenges or OTP email verification if the system detects anomalous IPs or behavior.

Error Messages and Additional Layers

When a login fails, a crucial yet often forgotten principle is: never inform the attacker which part of the credential was incorrect. Avoid overly specific error messages like 'Email not found' or 'Your password is wrong'.

Specific error messages inadvertently assist attackers in performing User Enumeration (automatically filtering which emails are registered in your system and which are not).

Use polite yet generic messages such as 'The email or password credentials provided are invalid'.

Finally, strongly consider implementing Multi-Factor Authentication (MFA/2FA) and comprehensive activity tracking (Audit Logs). Audit logs are vital for post-incident security investigations, meticulously recording who accessed the system, from which IP, using what device, and at what time.

Khawatir dengan Keamanan Aplikasi Anda?

Saya menyediakan layanan konsultasi keamanan dan audit sistem untuk melindungi data pengguna Anda.

Konsultasi Keamanan
© 2026 Fajar Geran Arifin. All rights reserved.