Every API and web service that returns 401 is choosing an authentication scheme, and the scheme decides whether a stolen header is a minor event or a full account and token compromise. HTTP defines one challenge and response framework, carried in the WWW-Authenticate and Authorization header fields, and many schemes plug into it. This reference covers the five schemes practitioners meet most often: Basic, Digest, Bearer, DPoP and Negotiate (Kerberos and NTLM). For each it gives the defining specification, what the credential is, whether it resists replay, how much it depends on TLS, and how to harden it. It is written for API, platform and identity developers who build or review services and the machine clients that call them.
Key takeaways
- The framework is shared, the security is not. RFC 9110 Section 11 defines challenges, credentials and realms; the scheme name in the challenge decides everything else about strength.
- Basic and Bearer are only as safe as TLS. Both send a reusable secret in every request, so anyone who sees the header can replay it until the password changes or the token expires.
- DPoP binds a token to a key. RFC 9449 requires a fresh signed proof per request, tied to the method, URI and token hash, so a leaked access token alone is not enough.
- Negotiate should mean Kerberos. Microsoft deprecated all NTLM versions in June 2024 and removed NTLMv1 from Windows 11 24H2 and Windows Server 2025; plan HTTP services so that Negotiate never needs to fall back.
- Error responses are part of the design. Use 401 with a challenge for missing or bad credentials, 403 for valid but insufficient credentials, and never put secrets in URLs.
How HTTP authentication challenges work
RFC 9110 (HTTP Semantics) Section 11 sets out the generic framework that every scheme uses.
- Challenge: a server that needs credentials responds with
401 Unauthorized. RFC 9110 says a server generating a 401 MUST send aWWW-Authenticatefield with at least one challenge. A proxy uses407 Proxy Authentication RequiredandProxy-Authenticate. - Credentials: the client retries with
Authorization(orProxy-Authorization) carrying the scheme name and its credentials. - Result: the server either accepts, returns 401 again, or returns
403 Forbiddenwhen the credentials are valid but not adequate for the resource. - Optional follow-up:
Authentication-Infocan carry scheme-specific data back, such as a next nonce in Digest.
Syntax rules worth knowing: the scheme name is case-insensitive. Parameters are name and value pairs, each parameter name may appear only once per challenge, and some schemes use a single token68 blob instead (Basic credentials and Negotiate tokens look like this). A response may carry several challenges, which lets a server offer, for example, both DPoP and Bearer.
Realm and protection space: the realm parameter names a protection space. RFC 9110 defines the protection space as the origin plus the realm, so a client may reuse credentials within it. Pick distinct realms for areas with different trust levels.
Proxies: a proxy must not modify WWW-Authenticate or Authentication-Info when forwarding; the proxy-specific fields apply only to the next hop. Make sure gateways and API management layers do not strip or rewrite challenges.
The IANA HTTP Authentication Scheme Registry lists every registered scheme. Besides the five in this guide it includes Concealed (RFC 9729), GNAP (RFC 9635), HOBA (RFC 7486), Mutual (RFC 8120), OAuth (the OAuth 1.0 scheme, RFC 5849), PrivateToken (RFC 9577), SCRAM-SHA-1 and SCRAM-SHA-256 (RFC 7804) and vapid (RFC 8292).
Scheme reference table
| Scheme | Defining specification | Credential sent | Replay resistance | TLS dependence |
|---|---|---|---|---|
| Basic | RFC 7617 (Standards Track, 2015) | Base64 of user-id:password | None: the same value works every time | Total: the password is effectively cleartext |
| Digest | RFC 7616 (Standards Track, 2015) | Hash response over nonce, cnonce, nonce count, method and URI | Partial: nonces and nonce counts limit replay | High: no confidentiality, downgrade and dictionary attacks possible |
| Bearer | RFC 6750 (Standards Track, 2012) | OAuth access token | None: any holder can use it until expiry | Total: RFC 6750 requires TLS |
| DPoP | RFC 9449 (Standards Track, 2023) | Key-bound access token plus a signed proof JWT in the DPoP header | Strong: proof bound to method, URI, time, token hash, optional server nonce | Still required: RFC 9449 says DPoP must always be used with HTTPS |
| Negotiate | RFC 4559 (Informational, 2006) | Base64 SPNEGO token (Kerberos or NTLM) | Kerberos: authenticator and ticket lifetime limit replay; NTLM: exposed to relay | High: protects neither headers nor body, TLS recommended |
The challenge parameters differ by scheme:
| Scheme | Common challenge parameters | Notes |
|---|---|---|
| Basic | realm, charset="UTF-8" | charset is advisory; password is NFC normalised and UTF-8 encoded when used |
| Digest | realm, nonce, opaque, qop, algorithm, stale, userhash, domain | qop is required; stale=true tells the client to retry with a new nonce |
| Bearer | realm, scope, error, error_description, error_uri | Errors: invalid_request (400), invalid_token (401), insufficient_scope (403) |
| DPoP | algs, plus Bearer-style error values | Errors include invalid_dpop_proof and use_dpop_nonce; nonce sent in DPoP-Nonce |
| Negotiate | None at first; later a token68 blob | Multi-round exchange; IANA notes it is connection-oriented, contrary to HTTP semantics |
Basic and Digest
Basic (RFC 7617): the client joins user-id and password with a colon and Base64-encodes the result, so a user-id cannot contain a colon. The RFC states that Basic is not considered a secure method of user authentication on its own: credentials travel in what is effectively cleartext, users reuse passwords across sites, and clients can be tricked by counterfeit servers. A client may reuse credentials for URIs under the same path prefix but must not reuse http credentials for https.
Basic still appears in three places: legacy APIs with static credentials, internal tooling behind a reverse proxy, and token endpoints that use Basic to carry an OAuth client ID and secret. In each case the secret is a long-lived non-human credential. Use TLS everywhere, store server-side passwords with a proper password hash, rotate the credential on a schedule, and prefer replacing it with OAuth client credentials, private key JWT or mTLS. See the mTLS Guide. Microsoft's retirement of Basic authentication for Exchange Online SMTP AUTH shows the direction of travel; see Exchange Online SMTP AUTH Basic Auth Retirement.
Digest (RFC 7616): RFC 7616 obsoleted RFC 2617, made SHA-256 mandatory to implement, kept SHA-512/256 as a backup and marked MD5 as NOT RECOMMENDED, retained only for backward compatibility. The server sends a nonce; the client answers with a hash over the nonce, its own cnonce, a nonce count (nc), the method and the URI. The server can rotate nonces with nextnonce in Authentication-Info and prove itself with rspauth.
The RFC's own security considerations are blunt: with human-memorable passwords Digest is open to dictionary attacks, it provides no confidentiality, qop=auth-int gives only limited integrity, a man-in-the-middle can inject weaker schemes to force a downgrade, and the server stores H(A1), which is password-equivalent and must be protected like plaintext passwords. Treat Digest as a compatibility scheme for devices and appliances, always over HTTPS, never as the design for a new API.
Bearer and DPoP
Bearer (RFC 6750): any party in possession of the token can use it. The preferred and mandatory-to-support transport is the Authorization: Bearer header. A form-encoded body is allowed only in narrow cases, and the URI query parameter is discouraged because URLs are logged; clients must not use more than one method in a single request. RFC 6750's security recommendations are TLS with certificate validation, short-lived tokens (one hour or less), no tokens in cookies that can be sent in cleartext, tokens restricted to the intended resource server and scopes, and no tokens in page URLs.
On errors, a request with no credentials should get a challenge with no error code. An expired or revoked token gets 401 with error="invalid_token"; a valid token without the right privileges gets 403 with error="insufficient_scope" and optionally the required scope. Keep error_description developer-facing and free of internal detail.
DPoP (RFC 9449): DPoP sender-constrains access and refresh tokens at the application layer. The client keeps a private key and sends Authorization: DPoP <token> plus a DPoP header containing a JWT with typ dpop+jwt, an asymmetric alg, its public jwk, and the claims below.
| Claim | Meaning | Resource server check |
|---|---|---|
jti | Unique proof identifier | Reject reused values within the acceptance window |
htm | HTTP method | Must match the request method |
htu | Target URI without query or fragment | Must match the request URI |
iat | Creation time | Within a short window |
ath | Base64url SHA-256 hash of the access token | Must match the presented token |
nonce | Server-supplied nonce, when required | Must equal the current DPoP-Nonce |
The authorisation server records the binding in the token's cnf claim as a jkt (JWK SHA-256 thumbprint), and the resource server checks that the proof key matches. A resource server must reject a DPoP-bound token presented under the Bearer scheme, which blocks downgrade. Nonces: a server can demand a fresh nonce through the DPoP-Nonce header; resource servers signal this with 401 and error="use_dpop_nonce", authorisation servers with 400. Nonces limit how long pre-generated proofs stay usable, and the RFC says authorisation server and resource server nonces should be kept separate.
Limits: DPoP does not protect bodies or most headers, and malicious code running in the client, for example through XSS, can still mint valid proofs while the client is online. Use non-extractable keys where the platform allows and keep standard XSS defences. See the DPoP Guide for deployment detail.
Negotiate (Kerberos and NTLM)
RFC 4559 is an Informational document describing Microsoft's SPNEGO-based scheme. The server answers with a bare WWW-Authenticate: Negotiate; the client returns a Base64 SPNEGO token in Authorization: Negotiate, and the exchange may take several rounds. With Kerberos the service principal is HTTP/hostname. Authentication is tied to the connection, so a proxy must never share an authenticated connection between clients, and the mechanism authenticates the user to the server only: it protects neither the headers nor the message body. TLS is recommended, and RFC 4559 notes that TLS certificate hashes can serve as channel bindings.
NTLM retirement direction: Microsoft's deprecated features list states that all versions of NTLM, including LANMAN, NTLMv1 and NTLMv2, are no longer under active feature development and are deprecated (announced June 2024), and that NTLMv1 is removed starting in Windows 11 version 24H2 and Windows Server 2025 (update dated November 2024). NTLM as a whole continues to work for now, with no full removal date published as of November 2026. Microsoft's guidance is to call Negotiate, which tries Kerberos and falls back to NTLM only when necessary. Timelines move, so check the current Microsoft page before planning.
Making Negotiate use Kerberos: register correct SPNs for each HTTP host name, avoid connecting by IP address or unregistered aliases (which forces fallback), enable Extended Protection for Authentication (channel binding) on IIS and similar servers, and audit NTLM use before blocking it. See the Kerberos vs NTLM, NTLM Deprecation and Elimination Guide and NTLM Relay Guide.
Choosing and hardening a scheme
| Situation | Recommended scheme | Why |
|---|---|---|
| Public or partner API, OAuth already in place | Bearer with short-lived, audience-restricted tokens; DPoP for high-value APIs | Standard tooling; DPoP removes the stolen-token replay risk |
| Single-page app or mobile client holding tokens | DPoP with non-extractable keys | Tokens exfiltrated from storage cannot be replayed without the key |
| Service-to-service inside one organisation | Bearer from workload identity, or mTLS-bound tokens | No static secrets; binding at the transport layer |
| Intranet web app on Active Directory | Negotiate, configured for Kerberos only | Single sign-on with no NTLM fallback |
| Legacy device or appliance | Digest with SHA-256 over HTTPS, otherwise Basic over HTTPS behind an authenticating proxy | Compatibility; contain and plan replacement |
Small versus large estates: a small team with a handful of APIs should standardise on one OAuth issuer, Bearer tokens of an hour or less and a gateway that enforces audience and scope, adding DPoP for the most sensitive endpoints. Large estates with many clients and machine identities gain more from DPoP or mTLS binding across the board, because token theft from logs, CI systems and developer machines is the common failure at scale. See the mTLS vs Signed Tokens for Service Authentication comparison and the API Security Guide.
Hardening steps that apply to every scheme:
- Inventory: list which schemes each endpoint accepts, from gateway configuration and from
WWW-Authenticateheaders observed in 401 responses. - Remove weak options first: disable Basic and Digest with MD5 where a stronger scheme exists; a server offering several challenges invites downgrade.
- Enforce TLS and HSTS: no scheme in this guide is safe over plain HTTP.
- Keep credentials out of logs: mask
Authorization,Proxy-AuthorizationandDPoPheaders in proxies, APM tools and error reports, and reject tokens in query strings. - Pilot and roll back safely: introduce DPoP or Kerberos-only in report or monitor mode, measure clients still using the old scheme, then enforce per client, keeping the previous configuration ready to restore.
Detection, measurement and framework mapping
- Scheme mix: share of authenticated requests by scheme per API; the target is zero Basic and zero MD5 Digest on internet-facing endpoints.
- NTLM fallback rate: NTLM authentications on HTTP services (Windows NTLM auditing, event 8001 to 8004 in the NTLM Operational log), trending to zero.
- Token replay signals: DPoP proofs rejected for reused
jti, mismatchedath, or Bearer use of a bound token. - 401 and 403 spikes: bursts of
invalid_tokenor failed Basic logins from one source, a sign of password spraying (ATT&CK T1110.003) or stolen tokens (T1550.001). - Secrets in URLs: count of requests with tokens in query strings found in access logs (should be zero).
| Framework | Reference | Relevance |
|---|---|---|
| NIST SP 800-53 Rev 5 | IA-2, IA-5 | Authenticating users and managing passwords, tokens and keys |
| NIST SP 800-53 Rev 5 | SC-8, SC-23 | TLS protection and session authenticity for credential-bearing requests |
| MITRE ATT&CK v20 | T1550.001 Application Access Token; T1557 Adversary-in-the-Middle; T1110.003 Password Spraying | Token replay, relay and credential guessing against HTTP endpoints |
| OWASP API Security Top 10 2023 | API2:2023 Broken Authentication | Scheme choice and token handling are core to this risk |
Practitioner checklist
- Return 401 with a
WWW-Authenticatechallenge for missing or invalid credentials and 403 for insufficient privileges. - Remove Basic and MD5 Digest from internet-facing endpoints; where Basic must stay, enforce TLS, hashed storage and rotation.
- Issue Bearer tokens of one hour or less, restricted by audience and scope, sent only in the
Authorizationheader. - Adopt DPoP for high-value APIs and public clients, validate every proof claim and use server nonces.
- Reject DPoP-bound tokens presented as Bearer.
- Configure Negotiate for Kerberos with correct SPNs and channel binding, audit NTLM, and block it once usage reaches zero.
- Mask authentication headers in every log and telemetry pipeline.
- Track scheme mix, NTLM fallback and token replay rejections as standing metrics.
Standards and references
- IETF: RFC 9110 HTTP Semantics (Section 11 HTTP Authentication)
- IETF: RFC 7617 The Basic HTTP Authentication Scheme
- IETF: RFC 7616 HTTP Digest Access Authentication
- IETF: RFC 6750 OAuth 2.0 Bearer Token Usage
- IETF: RFC 9449 OAuth 2.0 Demonstrating Proof of Possession (DPoP)
- IETF: RFC 4559 SPNEGO-based Kerberos and NTLM HTTP Authentication in Microsoft Windows
- IANA: HTTP Authentication Scheme Registry
- Microsoft Learn: Deprecated features for Windows client (NTLM)
Related NHI Mgmt Group resources: API Security Guide · DPoP Guide · mTLS Guide · Kerberos vs NTLM · NTLM Deprecation and Elimination Guide