OpenAI Forwarded Header Parser
When ChatGPT Wallet checks out from an OpenAI cloud browser, the TCP connection originates
from a datacenter IP. OpenAI relays the shopper’s real network and device context in the
Forwarded header so Stripe Radar,
Adyen RevenueProtect, and your risk engine don’t false-decline legitimate tokenized orders.
Decoded OpenAI ChatGPT Wallet Fraud Signals
7 of 7 documented OpenAI signals present
| Signal Key | Parsed Value | Status | Role in Fraud & Risk Scoring |
|---|---|---|---|
| asn | 7922 | VALID | Distinguishes consumer residential ISPs from hosting/datacenter ASNs. |
| for | 198.51.100.42 | VALID | Feeds velocity checks and billing-to-IP geolocation consistency. |
| ip-country | US | VALID | Matches card BIN / billing country to avoid false cross-border declines. |
| ip-prefix | 198.51.100.0/24 | VALID | Provides subnet-level reputation and geo signals without storing exact PII. |
| locale | en-US | VALID | Aligns storefront currency/language and corroborates customer location. |
| tz | America/Los_Angeles | VALID | Helps Stripe Radar / Adyen detect timezone mismatches vs shipping address. |
| user-agent | Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 | VALID | Supplies device context when the TCP connection comes from a cloud browser. |
// Cloudflare Worker: Relay verified OpenAI ChatGPT Wallet Forwarded signals to your origin
// IMPORTANT: Only trust the Forwarded header after verifying Web Bot Auth (Signature-Agent)
// or checking Cloudflare's verified-bot / Personal Agents signal.
export default {
async fetch(request: Request): Promise<Response> {
const sigAgent = request.headers.get('signature-agent');
const isVerifiedOpenAiAgent =
sigAgent?.includes('https://chatgpt.com') &&
Boolean(request.headers.get('signature')) &&
Boolean(request.headers.get('signature-input'));
const forwarded = request.headers.get('forwarded');
const upstreamHeaders = new Headers(request.headers);
if (isVerifiedOpenAiAgent && forwarded) {
const signals = parseOpenAiForwarded(forwarded);
if (signals['ip-country']) upstreamHeaders.set('x-agent-shopper-country', signals['ip-country']);
if (signals.asn) upstreamHeaders.set('x-agent-shopper-asn', signals.asn);
if (signals.locale) upstreamHeaders.set('x-agent-shopper-locale', signals.locale);
if (signals.tz) upstreamHeaders.set('x-agent-shopper-tz', signals.tz);
if (signals['ip-prefix']) upstreamHeaders.set('x-agent-shopper-prefix', signals['ip-prefix']);
upstreamHeaders.set('x-agent-verified', 'openai-chatgpt-wallet');
} else {
// Strip untrusted internal headers if request is not authenticated
upstreamHeaders.delete('x-agent-verified');
}
return fetch(new Request(request, { headers: upstreamHeaders }));
},
};
function parseOpenAiForwarded(header: string): Record<string, string> {
const out: Record<string, string> = {};
const firstHop = header.split(',')[0] ?? '';
for (const part of firstHop.split(';')) {
const idx = part.indexOf('=');
if (idx === -1) continue;
const key = part.slice(0, idx).trim().toLowerCase();
const val = part.slice(idx + 1).trim().replace(/^"|"$/g, '').replace(/\\"/g, '"');
if (key) out[key] = val;
}
return out;
}Security Trust Boundary (Mandatory)
Never trust an incoming Forwarded header from arbitrary HTTP clients.
Any attacker can forge Forwarded: ip-country=US;asn=7922.
Only parse and relay these signals to your payment fraud engine after verifying the
request’s RFC 9421 Web Bot Auth signature against OpenAI’s published key directory
(https://chatgpt.com/.well-known/http-message-signatures-directory)
or via Cloudflare’s verified Personal Agents signal.