repositories

daemon-sec-cheatsheet

The cheatsheet vault for operators: AD, enumeration, exploitation, priv-esc, web, DFIR

clonegit clone https://git.daemon-sec.xyz/daemon-sec-cheatsheet.git
special-http-headers.mdMarkdown359 lines19.5 KiBsource raw download

title: "Special HTTP headers" section: "Network Services" sectionSlug: "network-services-pentesting" sourcePath: "src/network-services-pentesting/pentesting-web/special-http-headers.md" sourceUrl: "https://github.com/HackTricks-wiki/hacktricks/blob/188de82beb54e70956b2952367a0af91d26758b8/src/network-services-pentesting/pentesting-web/special-http-headers.md" sha: "188de82beb54e70956b2952367a0af91d26758b8" isIndex: false modified: true license: "CC-BY-NC-4.0"#

Special HTTP headers#

Wordlists & Tools#

Headers that influence source or routing#

Rewrite IP source:

Rewrite location:

Hop-by-Hop headers#

A hop-by-hop header is a header which is designed to be processed and consumed by the proxy currently handling the request, as opposed to an end-to-end header.

Abusing Hop By Hop Headers

HTTP Request Smuggling#

Http Request Smuggling

The Expect header#

An HTTP/1.1 client can send Expect: 100-continue; the server may answer with HTTP/1.1 100 Continue before the client sends the request body. Differences in how frontends and backends handle the expectation and body can expose desynchronization bugs.[8][10]

Interesting observed results of Expect: 100-continue testing include:[10]

For more info about HTTP Request Smuggling check:

Http Request Smuggling

Cache Headers#

Server Cache Headers:

Cache Deception

Browser and legacy cache headers:[9]

Conditionals#

Range requests#

Message body information#

These fields are often routine, but differences on a resource protected by 401 or 403 can become an oracle for hidden content.
For example a combination of Range and Etag in a HEAD request can leak the content of the page via HEAD requests:

Request-body Content-Encoding abuse#

If the server accepts request bodies with a Content-Encoding header, test whether unsupported encodings are rejected before the body reaches any decompressor/parser. A common bug class is tying the rejection logic to an unrelated feature flag (for example, "HTTP compression enabled"). If that gate is wrong, an attacker may be able to reach a code path developers believed was unreachable.[6]

Generic checks:

Example probe:

POST / HTTP/1.1
Host: target
Content-Encoding: deflate
Content-Length: 4

AAAA

If the target should not support compressed request bodies, the safest behavior is an early 415 Unsupported Media Type (or similar explicit rejection) before any decompression attempt.

Safe patch-oracle detection with Content-Encoding: identity#

When the dangerous value is known to crash the service, look for a patch behavior oracle instead of replaying the destructive request. A useful pattern is to send a benign body with Content-Encoding: identity:

POST / HTTP/1.1
Host: target
Content-Encoding: identity
Content-Length: 10

AAAAAAAAAA

Why this is useful:

This pattern was useful in SolarWinds Serv-U (<= 15.5.4.108), where POST + body + Content-Encoding: deflate reached an unsafe in-memory deflate decompressor and reliably crashed the process, while the hotfix added a generic 415 gate for requests carrying a body plus any non-empty Content-Encoding header.[6][7]

Server Info#

Controls#

Downloads#

Content-Disposition: attachment; filename="filename.jpg"

This means the file named "filename.jpg" is intended to be downloaded and saved.[2]

Security Headers#

Content Security Policy (CSP) #

Content Security Policy Csp Bypass

Trusted Types#

By enforcing Trusted Types through CSP, applications can be protected against DOM XSS attacks. Trusted Types ensure that only specifically crafted objects, compliant with established security policies, can be used in dangerous web API calls, thereby securing JavaScript code by default.

// Feature detection
if (window.trustedTypes && trustedTypes.createPolicy) {
  // Name and create a policy
  const policy = trustedTypes.createPolicy('escapePolicy', {
    createHTML: str => str.replace(/\</g, '&lt;').replace(/>/g, '&gt;');
  });
}
// Assignment of raw strings is blocked, ensuring safety.
el.innerHTML = "some string" // Throws an exception.
const escaped = policy.createHTML("<img src=x onerror=alert(1)>")
el.innerHTML = escaped // Results in safe assignment.

X-Content-Type-Options#

This header prevents MIME type sniffing, a practice that could lead to XSS vulnerabilities. It ensures that browsers respect the MIME types specified by the server.[3]

X-Content-Type-Options: nosniff

X-Frame-Options#

To combat clickjacking, this header restricts how documents can be embedded in <frame>, <iframe>, <embed>, or <object> tags, recommending all documents to specify their embedding permissions explicitly.[3]

X-Frame-Options: DENY

Cross-Origin Resource Policy (CORP) and Cross-Origin Resource Sharing (CORS)#

CORP is crucial for specifying which resources can be loaded by websites, mitigating cross-site leaks. CORS, on the other hand, allows for a more flexible cross-origin resource sharing mechanism, relaxing the same-origin policy under certain conditions.[3]

Cross-Origin-Resource-Policy: same-origin
Access-Control-Allow-Origin: https://example.com
Access-Control-Allow-Credentials: true

Cross-Origin Embedder Policy (COEP) and Cross-Origin Opener Policy (COOP)#

COEP and COOP are essential for enabling cross-origin isolation, significantly reducing the risk of Spectre-like attacks. They control the loading of cross-origin resources and the interaction with cross-origin windows, respectively.[3]

Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Opener-Policy: same-origin-allow-popups

HTTP Strict Transport Security (HSTS)#

Lastly, HSTS is a security feature that forces browsers to communicate with servers only over secure HTTPS connections, thereby enhancing privacy and security.[3]

Strict-Transport-Security: max-age=3153600

Permissions-Policy (formerly Feature-Policy)#

Permissions-Policy allows web developers to selectively enable, disable, or modify the behaviour of certain browser features and APIs within a document. It is the successor to the now-deprecated Feature-Policy header. This header helps reduce the attack surface by restricting access to powerful features that could be abused.[4][5]

Permissions-Policy: geolocation=(), camera=(), microphone=()

Common directives:

Directive Description
accelerometer Controls access to the Accelerometer sensor
camera Controls access to video input devices (webcam)
geolocation Controls access to the Geolocation API
gyroscope Controls access to the Gyroscope sensor
magnetometer Controls access to the Magnetometer sensor
microphone Controls access to audio input devices
payment Controls access to the Payment Request API
usb Controls access to the WebUSB API
fullscreen Controls access to the Fullscreen API
autoplay Controls whether media can autoplay
clipboard-read Controls access to read clipboard content
clipboard-write Controls access to write to the clipboard

Syntax values:

Example configurations:

# Restrictive policy - disable most features
Permissions-Policy: geolocation=(), camera=(), microphone=(), payment=(), usb=()

# Allow camera only from same origin
Permissions-Policy: camera=(self)

# Allow geolocation for same origin and a trusted partner
Permissions-Policy: geolocation=(self "https://maps.example.com")

From a security perspective, missing or overly permissive Permissions-Policy headers may allow attackers (e.g., through XSS or embedded iframes) to abuse powerful browser features. Always restrict features to the minimum necessary for your application.

Header Name Casing Bypass#

HTTP field names are case-insensitive (RFC 9110 §5.1). Nevertheless, custom middleware, security filters, or business logic sometimes compare the literal header name without normalizing its case. If a filter is case-sensitive but the downstream consumer is compliant and case-insensitive, an attacker may bypass the filter with different capitalization.[1][8]

Typical situations where this mistake appears:

Abusing the bypass#

  1. Identify a header that is filtered or validated server-side (for example, by reading source code, documentation, or error messages).
  2. Send the same header with different casing. Whether the spelling survives to vulnerable user code depends on the server and framework, so test the complete proxy-to-application chain.
  3. If the downstream component treats headers in a case-insensitive way (most do), it will accept the attacker-controlled value.

Example: Apache Camel exec RCE (CVE-2025-27636)#

In vulnerable versions of Apache Camel the Command Center routes try to block untrusted requests by stripping the headers CamelExecCommandExecutable and CamelExecCommandArgs. The comparison was done with equals() so only the exact lowercase names were removed.

# Bypass the filter by using mixed-case header names and execute `ls /` on the host
curl "http://<IP>/command-center" \
  -H "CAmelExecCommandExecutable: ls" \
  -H "CAmelExecCommandArgs: /"

The headers reach the exec component unfiltered, resulting in remote command execution with the privileges of the Camel process.

Detection & Mitigation#

References#