Compare the device clock with the IP country, and check Tor exits, hosting ranges and your own blocklists.
What you will build: a check on the action you protect that allows normal users, asks doubtful ones to verify, and blocks the clear cases. See the vpn and proxy detection overview for the attack in pictures.
Before you start
Finish one Web quickstart (for example JavaScript or React) and one Server quickstart (for example Node.js). The decision code below is TypeScript; every server SDK returns the same event.
How the attack works
- Region hopping. Prices, content or offers from another country.
- Hidden origin. Fraud from high-risk regions through a VPN.
- Tor. Anonymous traffic on sensitive flows.
What to look at
| Field | Why it matters here |
|---|---|
vpn | Device offset that no zone of the IP country has. |
tor | Request IP in your Tor exit list. |
datacenterIp | Hosting and cloud ranges most VPNs exit from. |
- 1
Identify on the action
Call the browser SDK when the user performs the action, not on page load, and send the
eventIdwith the request.TypeScriptconst { eventId } = await trace.get({ tags: { action: 'vpn-detection' } }); - 2
Verify on your server
import { verifyEvent } from '@trace-id/sdk-node'; const event = await verifyEvent(eventId, { secretKey: process.env.TRACE_SECRET_KEY!, endpoint, timeoutMs: 1500 }).catch(() => null);try: event = client.get_event(event_id) except trace_device.VerifyError: event = None # fail opentry { $event = $client->getEvent($eventId); } catch (Trace\VerifyError $e) { $event = null; }Map<String, Object> event = null; try { event = trace.getEvent(eventId); } catch (Trace.VerifyException e) { /* fail open */ }const event = await trace.verify(eventId).catch(() => null);Events can be verified for 60 minutes. If verification fails, decide whether to fail open or closed; for most of this flow, fail open.
- 3
Decide
TypeScriptconst { signals, ip } = await trace.verify(eventId); if (signals.tor.detected) return block(); if (signals.vpn.detected) return priceFor(defaultRegion); return priceFor(ip.country);trace.verify()is the embedded call; with a server SDK, use theeventfrom step 2 instead. The thresholds are yours. Trace scores and explains;event.reasonslists which signals added how much, so log it with every decision.
Example decisions
Visitors to a regional offer, illustrative:
| IP country | Device clock | Decision | Why |
|---|---|---|---|
| Egypt | UTC+2 | Allow | Consistent |
| Germany | UTC+1 | Allow | Consistent |
| United States | UTC+2 | Verify | vpn: timezone mismatch |
| Tor exit | UTC | Block | tor |
Roll it out
- Ship steps 1 to 3 with logging only: record the decision, block nothing.
- After a week, look at who would have been blocked or asked to verify. Shared computers, offices and privacy tools are the usual false positives.
- Turn on Verify first, then Block for the clearest cases.