TRACE

Diagnosing how intermediaries modify requests along the path to a server is the purpose of the HTTP TRACE method. The final recipient reflects the received request back as the response body, revealing changes made by proxies and gateways.

Usage

A TRACE request is a diagnostic tool for inspecting the request chain between a client and the origin server. The server responds with 200 and includes the received request message in the response body. One recognized format is Content-Type message/http. The response body contains a copy of the request message as received, excluding fields the server considers sensitive, allowing comparison with the original request.

Properties

Property Value
Safe Yes
Idempotent Yes
Cacheable No

TRACE requests carry no body. Clients are responsible for not including sensitive fields such as credentials or Cookies in TRACE requests, since the echoed response exposes all received headers.

Microsoft IIS historically supported TRACK as a proprietary alias for TRACE. Both are subject to the same XST vulnerability and both need to be disabled in production.

Intermediary detection

When a request passes through proxies or gateways, each intermediary appends a Via header entry recording the protocol version of the upstream sender the message arrived from. Comparing the original request with the echoed copy reveals headers added, modified, or removed by each hop.

The Max-Forwards header limits how far a TRACE request travels. Setting this value to zero causes the first proxy to respond, which is useful for isolating a specific intermediary in a multi-hop chain. Decrementing the counter at each hop prevents infinite forwarding loops.

Security and XST

Cross-Site Tracing (XST) is an attack vector exploiting TRACE to capture HTTP headers, including Authentication tokens and cookie values. A malicious script sends a TRACE request to the target server, and the echoed response exposes headers not otherwise accessible to the script.

The technique dates from 2003, when Jeremiah Grossman showed TRACE reflecting a cookie marked HttpOnly back into a page, bypassing the attribute meant to keep cookies away from script. Browsers answered by refusing to send TRACE, and the method stayed on scanner checklists ever since. Many servers and CDNs answer TRACE with 405, so a 200 with the echoed request is uncommon in production yet still found on default Apache installs, as the next sections describe.

Example

A TRACE request to the root resource. The server echoes the original request in the response body and includes a Via header showing the request passed through two proxy servers.

Request

TRACE / HTTP/1.1
Host: www.example.re

Response

HTTP/1.1 200 OK
Content-Type: message/http
Content-Length: 87
Via: 1.1 proxy2.example.re, 1.1 proxy1.example.re

TRACE / HTTP/1.1
Host: www.example.re
Via: 1.1 proxy1.example.re, 1.1 proxy2.example.re

The Via header lists proxy1.example.re and proxy2.example.re as intermediaries. Both received the request over HTTP/1.1. The response's own Via runs in return-path order, proxy2 first, while the echoed body preserves the request-path order. Each intermediary must append a Via entry to forwarded requests, so the echoed body includes the accumulated Via field added by the two proxies.

Browser restrictions

TRACE is a forbidden method in the WHATWG Fetch Standard, alongside CONNECT and the legacy TRACK. Browsers block all attempts to send TRACE through browser APIs such as fetch() and XMLHttpRequest, for same-origin requests and cross-origin CORS requests alike.

Disabling TRACE

Apache ships with TRACE enabled and disables it with TraceEnable Off in the server configuration, after which TRACE requests draw 405 Method Not Allowed. TraceEnable is the documented control, since Apache exempts TRACE from <Limit> and <LimitExcept> blocks, the first place many administrators look. A mod_rewrite condition on the request method is the usual fallback where the server configuration is out of reach. A third mode, TraceEnable extended, accepts request bodies for diagnostic use, capped at 64K when Apache acts as the origin. nginx answers every TRACE with 405 and offers no switch to enable it, so no action is needed. IIS denies TRACE (and the legacy TRACK) through the verb list in Request Filtering.

OWASP's testing guide checks for TRACE exposure under cross-site tracing, and security scanners flag enabled TRACE as a finding even though browsers refuse to send TRACE. Apache documentation states enabling TRACE exposes no security vulnerability in httpd itself, so the hardening value lies in cutting off the XST attack path rather than patching a server flaw.

Disabling TRACE at the server level remains the primary defense against XST because non-browser HTTP clients and scripts are not bound by the Fetch Standard restrictions.

See also

Last updated: November 3, 2026