This is by DeepSeek:

The X-Forwarded-For (XFF) HTTP header is commonly used to identify the originating IP address of a client connecting to a web server through a proxy or load balancer. Below are 30 different ways it can be used or manipulated when generating HTTP messages for web access:


1. Basic Usage

  1. Single IP:
    X-Forwarded-For: 203.0.113.195
  2. Multiple Proxies:
    X-Forwarded-For: 203.0.113.195, 198.51.100.100, 192.0.2.1
  3. IPv6 Address:
    X-Forwarded-For: 2001:db8::1
  4. IPv4 and IPv6 Mix:
    X-Forwarded-For: 203.0.113.195, 2001:db8::1

2. Edge Cases

  1. Empty Header:
    X-Forwarded-For:
  2. Whitespace Only:
    X-Forwarded-For:
  3. Invalid IP Address:
    X-Forwarded-For: 256.256.256.256
  4. Malformed IP:
    X-Forwarded-For: 203.0.113.195.123
  5. Non-IP Data:
    X-Forwarded-For: example.com

3. Security Testing

  1. Spoofed IP:
    X-Forwarded-For: 192.168.1.1
  2. Private IP Range:
    X-Forwarded-For: 10.0.0.1
  3. Reserved IP Range:
    X-Forwarded-For: 127.0.0.1
  4. Localhost:
    X-Forwarded-For: ::1
  5. Overflow Attack:
    X-Forwarded-For: 203.0.113.195, 198.51.100.100, ... (repeated thousands of times)

4. Load Balancer and Proxy Scenarios

  1. Load Balancer IP:
    X-Forwarded-For: 203.0.113.195, 198.51.100.100
  2. Unknown Proxy:
    X-Forwarded-For: unknown
  3. Multiple Proxies with Unknown:
    X-Forwarded-For: 203.0.113.195, unknown, 198.51.100.100
  4. Proxied Through Cloudflare:
    X-Forwarded-For: 203.0.113.195, 198.51.100.100, 172.71.82.1
  5. Proxied Through AWS ELB:
    X-Forwarded-For: 203.0.113.195, 198.51.100.100, 10.0.0.1

5. Custom or Non-Standard Usage

  1. Port Included:
    X-Forwarded-For: 203.0.113.195:8080
  2. Hostname Instead of IP:
    X-Forwarded-For: client.example.com
  3. Multiple Headers:
    X-Forwarded-For: 203.0.113.195
    X-Forwarded-For: 198.51.100.100
    
  4. Mixed Data Types:
    X-Forwarded-For: 203.0.113.195, client.example.com, 2001:db8::1

6. Debugging and Logging

  1. Debugging Identifier:
    X-Forwarded-For: debug-12345
  2. Session ID:
    X-Forwarded-For: session-abc123
  3. User Agent Info:
    X-Forwarded-For: 203.0.113.195, Mozilla/5.0

7. Malicious or Anomalous Use

  1. SQL Injection Attempt:
    X-Forwarded-For: 203.0.113.195'; DROP TABLE users; --
  2. XSS Attempt:
    X-Forwarded-For: 203.0.113.195<script>alert('XSS')</script>
  3. Command Injection:
    X-Forwarded-For: 203.0.113.195; rm -rf /
  4. Overlong Header:
    X-Forwarded-For: 203.0.113.195, ... (extremely long string)

Notes

  • The X-Forwarded-For header is often used in conjunction with other headers like X-Real-IP or Forwarded.
  • Misconfigured servers may trust this header blindly, leading to security vulnerabilities like IP spoofing.
  • Always validate and sanitize the X-Forwarded-For header to prevent abuse.

And this is by OpenAI ChatGPT:

The X-Forwarded-For (XFF) header is used in HTTP requests to indicate the original client IP address when a request passes through a proxy or load balancer. Here are 30 different ways it can be used in HTTP requests, including variations, manipulations, and attack scenarios:


Basic Usage (Legitimate)

  1. Single Client IP (Standard Use Case)
    X-Forwarded-For: 192.168.1.1
    
  2. Multiple Proxy Hops (Comma-Separated List)
    X-Forwarded-For: 192.168.1.1, 10.0.0.1, 172.16.0.5
    
  3. With Private & Public IPs Mixed
    X-Forwarded-For: 203.0.113.5, 192.168.10.25, 10.1.1.1
    
  4. With IPv6 Address
    X-Forwarded-For: 2001:db8::1
    
  5. IPv6 and IPv4 Mixed
    X-Forwarded-For: 192.168.1.100, 2001:db8::2
    

Bypassing Security / Spoofing

  1. Forged External IP
    X-Forwarded-For: 8.8.8.8
    
  2. Injecting a Malicious IP to Evade Rate-Limiting
    X-Forwarded-For: 127.0.0.1, 8.8.8.8
    
  3. Empty Header for Anonymity
    X-Forwarded-For:
    
  4. Using localhost to Trick Backend Systems
    X-Forwarded-For: 127.0.0.1
    
  5. Fake Trusted Proxy Hop
    X-Forwarded-For: 10.0.0.1, 192.168.1.1, 8.8.8.8
    

Evading Detection / Load Balancer Tricks

  1. Long List of Fake Proxies
    X-Forwarded-For: 192.168.1.1, 192.168.1.2, 192.168.1.3, 192.168.1.4, 8.8.8.8
    
  2. Adding Non-IP Data for Log Confusion
    X-Forwarded-For: unknown
    
  3. Appending Extra Data for Splitting Issues
    X-Forwarded-For: 192.168.1.1, something-else
    
  4. Using Malformed IP Address
    X-Forwarded-For: 999.999.999.999
    
  5. Using 0.0.0.0 to Confuse Systems
    X-Forwarded-For: 0.0.0.0
    

Cross-Site Request Forgery (CSRF) / Exploits

  1. Injecting New Headers via Newline Characters (CRLF Injection)
    X-Forwarded-For: 192.168.1.1%0D%0AX-Forwarded-For: 8.8.8.8
    
  2. Splitting Headers via HTTP/1.1 Header Injection
    X-Forwarded-For: 192.168.1.1\r\nInjected-Header: value
    
  3. Using Encoded Characters (Obfuscation)
    X-Forwarded-For: %31%39%32%2E%31%36%38%2E%31%2E%31
    
  4. Trying to Break the Header Parsing Logic
    X-Forwarded-For: 192.168.1.1,
    
  5. Using Double Comma Trick to Confuse Parsing
    X-Forwarded-For: 192.168.1.1,,8.8.8.8
    

Bypassing IP-Based Authentication

  1. IP Address in CIDR Format
    X-Forwarded-For: 192.168.1.1/32
    
  2. Using Octal Representation of IP
    X-Forwarded-For: 0300.0250.0001.0001
    
  3. Using Hexadecimal Format
    X-Forwarded-For: 0xC0A80101
    
  4. Using Mixed Numeric Representations
    X-Forwarded-For: 3232235777
    
  5. Inserting a Fake Internal IP for Confusion
    X-Forwarded-For: 10.10.10.10, 192.168.1.1
    

Web Application Firewall (WAF) Evasion

  1. Using Domain Instead of IP
    X-Forwarded-For: example.com
    
  2. Mixing Uppercase & Lowercase to Bypass Case-Sensitive Filters
    X-ForWARDED-FOr: 192.168.1.1
    
  3. Adding Unusual Characters for Parsing Issues
    X-Forwarded-For: 192.168.1.1; DROP TABLE users;
    
  4. Using a Large String to Cause Buffer Overflow
    X-Forwarded-For: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    
  5. Stacking Multiple X-Forwarded-For Headers for Confusion
    X-Forwarded-For: 192.168.1.1
    X-Forwarded-For: 8.8.8.8
    

These variations demonstrate both legitimate and malicious uses of X-Forwarded-For. In security-sensitive applications, relying solely on this header for authentication or rate-limiting is risky, as it can be manipulated easily.

For pentester, you can clearly see which output is better.