<!-- Copyright (c) 2026 defconxt. All rights reserved. -->
<!-- Licensed under AGPL-3.0 — see LICENSE file for details. -->
<!-- NERF is a trademark of defconxt. -->
---
name: implementing-fetch-metadata-headers
description: >-
  Implement Fetch Metadata request headers (Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest) for server-side resource isolation policies against CSRF, XSSI, and cross-origin attacks.
domain: cybersecurity
subdomain: browser-security
tags:
  - fetch-metadata
  - sec-fetch
  - resource-isolation
  - csrf-prevention
version: "1.0"
author: defconxt
license: AGPL-3.0
metadata:
  mitre-attack: ["T1189"]
  frameworks: ["OWASP", "W3C"]
  tools: ["nginx", "express", "django"]
---

# Implementing Fetch Metadata Headers

## Overview

Implement Fetch Metadata request headers (Sec-Fetch-Site, Sec-Fetch-Mode, Sec-Fetch-Dest) for server-side resource isolation policies against CSRF, XSSI, and cross-origin attacks.

## Prerequisites

| Tool / Requirement | Details |
|---|---|
| `nginx` | Security tooling |
| `express` | Security tooling |
| `django` | Security tooling |
| Web server/framework configuration access, understanding of Fetch Metadata spec | Environment requirement |

## Quick Reference

```bash
# Quick start commands
node scripts/agent.js --help
curl -sI https://target.com | grep -i sec-fetch
```

## Workflow

### Step 1: Audit Current Headers

```bash
curl -sI https://target.com | grep -i sec-fetch
```

### Step 2: Generate Isolation Policy

```bash
node scripts/agent.js generate --framework express --policy strict
```

### Step 3: Deploy Middleware

```bash
node scripts/agent.js deploy --framework express --config policy.json
```

## Detection

```yaml
title: Fetch Metadata Headers Detection
id: fc597346-a809-44f0-bad6-0a9b549c58c3
status: experimental
description: Detects suspicious activity related to implementing fetch metadata headers techniques in browser security context
logsource:
  category: proxy
  product: windows
detection:
  selection:
    cs_uri_query: "*script*"
  condition: selection
level: medium
tags:
  - attack.t1189
  - attack.initial_access
falsepositives:
  - Browser security extensions performing routine URL reputation checks
```


**Detection Opportunities**

| Indicator | Source | Detection Logic |
|---|---|---|
| Fetch Metadata Headers Detection | windows/proxy | Sigma rule (medium) |
| ATT&CK Coverage | MITRE ATT&CK | T1189 |

## Verification

- **Verify header enforcement**: `node scripts/agent.js verify --url https://target.com`
- **Test isolation policy**: `node scripts/agent.js test --url https://target.com`

## References

- MITRE ATT&CK: T1189
- Frameworks: OWASP, W3C
- Tools: nginx, express, django
