0Pricing
Cloud & IT Cert Prep · Lesson

Broken Authentication and Insecure Deserialization

Explore how weak session management, credential stuffing, and insecure deserialization vulnerabilities allow attackers to hijack accounts and execute code.

Broken Authentication and Insecure Deserialization is a free Cloud & IT Cert Prep lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Cloud & IT Cert Prep learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

What Is Broken Authentication?

Broken authentication refers to weaknesses in how an application verifies user identity and manages sessions. When authentication is broken, attackers can compromise passwords, keys, or session tokens to assume other users' identities. This OWASP Top 10 category covers a wide range of flaws: weak credentials, poor session management, missing MFA, and insecure credential storage.

Credential Stuffing and Password Spraying

Credential stuffing uses large lists of breached username/password pairs from prior data breaches and tries them against other sites, exploiting password reuse. Password spraying takes the opposite approach: try a small set of common passwords (e.g., Password1!) against many accounts to avoid account lockout thresholds. Both attacks succeed because of weak password policies and lack of MFA.

# Password spraying concept (defensive awareness)
# Attacker tries 'Password1!' against 10,000 accounts
# rather than trying 10,000 passwords against 1 account
# This avoids triggering lockout policies (e.g., 5 attempts/account)

# Defense: MFA + adaptive authentication + rate limiting

Weak Session Management

Sessions connect authenticated users to their application state. Weak session management flaws include: predictable session token values (sequential IDs that attackers can guess), tokens that never expire, tokens transmitted over HTTP instead of HTTPS, and failure to invalidate tokens on logout. An attacker who obtains a valid session token can impersonate the user without knowing their password.

# Signs of weak session management:
# /login response sets:
# Set-Cookie: session=1042  (predictable, sequential)
# Missing: Secure; HttpOnly; SameSite flags
# Missing: session expiry / Max-Age
# Logout does NOT invalidate server-side session

Session Fixation and Hijacking

Session fixation forces a victim to use a session ID chosen by the attacker. For example, an attacker sends a link with a pre-set session cookie; after the victim authenticates, the attacker uses that same session ID to access the account. Session hijacking steals an existing session token via XSS, network sniffing (on unencrypted connections), or stolen cookies. The fix: regenerate session IDs after login and use HTTPS everywhere.

Insecure Password Storage

Storing passwords in plaintext or with weak hashing (MD5, SHA-1) is a critical authentication failure. When a database is breached, plaintext passwords and weak hashes are immediately usable. Secure password storage requires an adaptive hashing algorithm designed for passwords: bcrypt, Argon2, or PBKDF2 with a random per-user salt. These algorithms are intentionally slow, making offline cracking computationally expensive.

# Python example — secure password hashing with bcrypt
import bcrypt

# Hash a password (includes random salt automatically)
password = b'UserSuperSecret123'
hashed = bcrypt.hashpw(password, bcrypt.gensalt(rounds=12))

# Verify
bcrypt.checkpw(password, hashed)  # returns True

What Is Insecure Deserialization?

Serialization converts an object's state to a format (JSON, XML, binary) for storage or transmission. Deserialization reconstructs the object from that format. Insecure deserialization occurs when an application deserializes attacker-controlled data without validation — allowing attackers to modify serialized objects to manipulate application logic, escalate privileges, or execute arbitrary code on the server.

Deserialization Attack Example

A common attack pattern involves serialized objects passed in cookies or API parameters. For example, a Java application using ObjectInputStream.readObject() on untrusted data can trigger Remote Code Execution (RCE) through gadget chains in popular libraries (Apache Commons Collections). The attacker crafts a malicious serialized payload, sends it to the application, and code executes during deserialization — often before any authentication check runs.

# Insecure deserializing pattern (Python pickle — dangerous)
import pickle

# Attacker-controlled payload
class Exploit:
    def __reduce__(self):
        import os
        return (os.system, ('id',))  # executes 'id' on server

payload = pickle.dumps(Exploit())
pickle.loads(payload)  # RCE! Never deserialize untrusted data with pickle

Preventing Insecure Deserialization

Defenses against insecure deserialization include: never deserializing untrusted data with dangerous formats like Java native serialization or Python pickle. Prefer data-only formats (JSON, XML) over binary serialization. If deserialization is required, implement integrity checks (signing the serialized object with HMAC), use allow-lists to restrict which classes may be deserialized, and run deserialization code in isolated, low-privilege environments.

# Safe approach: sign serialized data before transmitting
import hmac, hashlib, json

def serialize_safe(data, secret):
    payload = json.dumps(data)  # use JSON, not pickle
    sig = hmac.new(secret.encode(), payload.encode(), hashlib.sha256).hexdigest()
    return payload + '.' + sig

Multi-Factor Authentication as a Control

Multi-Factor Authentication (MFA) is the most impactful single control against broken authentication. Even if credentials are compromised through phishing, credential stuffing, or a database breach, an attacker without the second factor cannot authenticate. Microsoft reports that MFA blocks over 99.9% of automated account compromise attacks. MFA should be mandatory for privileged accounts and encouraged for all users.

Account Lockout and Rate Limiting

Account lockout policies temporarily disable an account after a defined number of failed login attempts, slowing brute-force attacks. However, lockouts can enable denial of service against legitimate users — attackers intentionally trigger lockouts to prevent access. Rate limiting (slowing responses after repeated failures using exponential backoff) and CAPTCHA challenges mitigate brute force with less DoS risk.

Broken Auth in the OWASP Top 10

OWASP lists Broken Authentication as a critical risk because authentication flaws are both common and high-impact. Key indicators of broken authentication include: permitting automated attacks such as credential stuffing, permitting brute force or other automated attacks, permitting default, weak, or well-known passwords, using weak credential recovery processes, using plain text or weakly hashed passwords, and missing or ineffective multi-factor authentication.

Quick Check

Test your understanding of CompTIA Security+ (SY0-701) concepts from this lesson.

Lesson Recap

In this lesson you learned: broken authentication includes weak sessions, credential stuffing, and insecure password storage, insecure deserialization can lead to Remote Code Execution via malicious serialized objects, and MFA, bcrypt password hashing, session regeneration after login, and signed serialized data are key defenses. Next up we explore secure SDLC, SAST, and DAST tools.

Frequently asked questions

Is the “Broken Authentication and Insecure Deserialization” lesson free?

Yes — the full text of “Broken Authentication and Insecure Deserialization” is free to read here on the web, and the Cloud & IT Cert Prep course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Cloud & IT Cert Prep course, upgrade to CoddyKit PRO.

What will I learn in “Broken Authentication and Insecure Deserialization”?

Explore how weak session management, credential stuffing, and insecure deserialization vulnerabilities allow attackers to hijack accounts and execute code. You practise Cloud & IT Cert Prep with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Cloud & IT Cert Prep?

No prior experience is required. Cloud & IT Cert Prep on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Broken Authentication and Insecure Deserialization” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Cloud & IT Cert Prep lesson?

Yes. Every Cloud & IT Cert Prep lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. SQL Injection and Command Injection
  2. Cross-Site Scripting (XSS) and CSRF
  3. Broken Authentication and Insecure Deserialization
  4. Secure SDLC, SAST, and DAST Tools
← Back to Cloud & IT Cert Prep