Web Proxy / Caching Fundamentals Series

🔐 Understanding the Difference Between Proxy Authentication Methods (Basic/NTLM/Kerberos) From a Top 1% Perspective — Why Does a Status Code 407 Even Exist?

Introduction

This article is part of the Top 1% Series Complete Article Guide, and the fifth article in the Web Proxy/Caching Fundamentals Series.

Prerequisite Knowledge

Getting the Big Picture

Why Does Status Code 407 Exist, Instead of Just 401?

When the web server itself requires authentication, it returns 401 Unauthorized. But when a proxy sits between the client and the web server, the client needs to be able to distinguish whether the authentication request is coming from “the ultimate destination web server” or from “the proxy itself, somewhere along the path.” For exactly this distinction, when the proxy itself demands authentication, it uses a separate status code from 401: 407 Proxy Authentication Required.

sequenceDiagram
    participant Client as Client
    participant Proxy as Proxy
    participant Server as Web Server

    Client->>Proxy: Request (no credentials)
    Proxy-->>Client: 407 Proxy Authentication Required
    Client->>Proxy: Request (with credentials attached)
    Proxy->>Server: Forwards the request
    Server-->>Client: 200 OK (relayed via the proxy)

Deep Dive Into the Fundamentals

Basic Authentication: the Simplest, but Never Encrypted

Basic authentication is the simplest method: it joins a username and password with a colon, Base64-encodes the result, and sends it in a Proxy-Authorization header. Base64 is encoding, not encryption, so unless the communication path itself is encrypted, the username and password are, for all practical purposes, traveling in plaintext. It’s only safe to use when the connection to the proxy itself is encrypted via HTTPS.

NTLM Authentication: Challenge-Response, With Authentication Maintained Per TCP Connection

NTLM authentication never sends the password itself. Instead, it uses a challenge-response scheme: the proxy sends a challenge (a random value), and the client responds with a value it derives from the password. This keeps the password itself from ever traveling over the network.

NTLM authentication’s major distinguishing trait is that authentication state is maintained per “TCP connection,” not per “HTTP request.” Once the challenge-response exchange completes on the very first request within one TCP connection, every subsequent request on that same connection never needs to repeat the authentication exchange.

What Real-World Problem Does This "Per-Connection" Authentication Cause?

This mechanism breaks down if yet another load balancer sits between the client and the proxy, routing each request to a different backend proxy server. The ordinary load-balancing idea covered in load balancing algorithms — that any request can be processed by any server — collides head-on with NTLM authentication’s premise of maintaining state per connection. Fixing this requires the mechanism of session persistence (sticky sessions), pinning connections from the same client to always route to the same backend proxy. This mirrors the structure of session persistence, needed whenever the backend side holds session information in its own memory.

Kerberos Authentication: Never Sending the Password Itself Over the Network at All

Kerberos authentication is a ticket-based method, commonly used in Active Directory environments. A client obtains a ticket from an authentication server (the KDC) ahead of time, and presents that ticket, instead of the password itself, when accessing the proxy. Kerberos’s major distinguishing trait is that it never sends even a value derived from the password over the network, across the entire challenge-response exchange.

Authentication MethodHandling of the PasswordAuthentication Granularity
BasicJust Base64-encoded — for all practical purposes, plaintextPer request
NTLMOnly a value derived from the password (challenge-response)Per TCP connection
KerberosOnly a ticket (neither the password nor a derived value ever travels)Per ticket lifetime

What a Pro Sees Here (Top 1% Understanding)

Choosing an Authentication Method Is a Design Decision About How Much You’re Willing to Expose on the Network

The difference between Basic, NTLM, and Kerberos becomes clear once you understand it as a staged design decision: how much of the password, a piece of sensitive information, are you willing to let appear on the network at all. Basic exposes it effectively in plaintext; NTLM exposes a value derived from it; Kerberos exposes nothing about the password at all — a clear progression. This shares the exact same underlying idea as never letting a card number touch the merchant’s own server at all, in a payment API’s design. The idea of replacing sensitive information itself with a different (safer) representation — a token, a ticket, a hash value — as early as possible, recurs again and again across entirely different domains.

Common Misconceptions and Pitfalls

Troubleshooting Perspective

  1. You’re getting a 407 error even though you’re sending what should be the correct credentials: Check whether the authentication method in use (Basic/NTLM/Kerberos) matches between the client and the proxy.
  2. In an NTLM setup, authentication errors keep recurring on a proxy sitting behind a load balancer: Check whether the load balancer is configured to pin a given client’s connections to the same backend proxy (session persistence).
  3. Kerberos authentication only fails for access coming from outside the company: Kerberos assumes reachability to the KDC (typically a domain controller), so check whether external clients can even reach the KDC at all.

Summary

Takeaways to Apply Today

  1. When you run into a proxy authentication problem, first check whether you’re seeing 407 or 401, isolating which layer is actually demanding authentication.
  2. When designing an environment that uses NTLM authentication behind a load balancer, never forget to configure session persistence.

References

Comments

Feel free to leave thoughts, questions, or corrections below (sign in with a GitHub account to comment or react).