How IP Leaks via WebRTC

Mutt

Professional
Messages
1,264
Reaction score
901
Points
113
WebRTC (Web Real-Time Communication) is a technology that allows browsers and applications to establish a direct connection to exchange data (e.g. video calls, chats, or file transfers). However, WebRTC can reveal the user's real IP address, even if a VPN (e.g. OpenVPN) or iCloud Private Relay is used, making it a privacy vulnerability. Since your request is related to cybersecurity, iPhone setup, and data protection (iCloud Private Relay, OpenVPN, iCloud management), I will explain how WebRTC can lead to IP leakage, how it is detected by anti-fraud systems, and how to protect yourself, with an emphasis on educational purposes. The answer will be technical but accessible, and will not support illegal activities such as carding.

1. What is WebRTC and why can it reveal IP?​

WebRTC is a set of APIs and protocols built into modern browsers (Safari, Chrome, Firefox) that allow you to:
  • Establish direct connections between devices (peer-to-peer) to transfer data.
  • Use protocols such as STUN (Session Traversal Utilities for NAT) and TURN to determine network paths through NAT and firewalls.

Why WebRTC reveals IP:
  • WebRTC uses STUN servers to discover the public IP address of a device, even if it is behind a NAT (such as a home router) or using a VPN.
  • When a browser (such as Safari on iPhone) sends requests to STUN servers, it receives the device's real IP address, which can be passed to a website or anti-fraud system via JavaScript.
  • VPN or iCloud Private Relay redirect HTTP/HTTPS traffic through their servers, but WebRTC traffic can bypass these tunnels, revealing the real IP.

Example scenario:
  • You use OpenVPN with an IP from the US to hide your real IP (for example, from Russia).
  • A site with WebRTC code requests a STUN connection via JavaScript.
  • Your iPhone responds to the STUN server, revealing the real Russian IP despite the VPN.

2. How WebRTC Reveals IP via JavaScript​

Anti-fraud systems and websites can use WebRTC to obtain the user's real IP address via JavaScript. Here's how it works:

a) Using RTCPeerConnection​

  • How it works:
    • JavaScript on the site creates an RTCPeerConnection object, which is used to establish peer-to-peer connections.
    • This object interacts with STUN servers to determine the public IP address of the device.
    • The STUN server returns an IP address that JavaScript can retrieve via the onicecandidate event.
  • Code example (simplified):
    JavaScript:
    const pc = new RTCPeerConnection({ iceServers: [{ urls: 'stun:stun.l.google.com:19302' }] });
    pc.onicecandidate = (event) => {
    if (event.candidate) {
    console.log('IP-адрес:', event.candidate.address); // Раскрывает реальный IP
    }
    };
    pc.createDataChannel('test');
    pc.createOffer().then(offer => pc.setLocalDescription(offer));
  • Result: The code extracts an IP address that may be real (e.g. your home IP), even if the HTTP requests are going through a VPN (where X-Forwarded-For shows the VPN IP).

b) Bypass VPN and iCloud Private Relay​

  • VPN: VPN redirects HTTP/HTTPS traffic through its servers, but WebRTC traffic (UDP protocols) is often not tunneled unless the VPN is configured to block WebRTC.
  • iCloud Private Relay: Works only with Safari and redirects HTTP/HTTPS traffic through Apple and partner servers (e.g. Cloudflare). WebRTC traffic bypasses Private Relay, revealing the real IP.
  • Example: If you use iCloud Private Relay, the site sees an anonymized IP (eg from your region), but WebRTC can reveal your real IP via STUN.

c) Antifraud application​

  • Anti-fraud systems (e.g. ThreatMetrix, Sift) use WebRTC to check whether an IP address matches other data:
    • Geolocation: Real IP (from WebRTC) is compared with the declared IP (from HTTP headers, e.g. X-Forwarded-For) and the map region.
    • Inconsistencies: If WebRTC shows a Russian IP, but HTTP requests go through an American VPN, this is an anomaly.
    • IP Reputation: Real IP is checked in databases (MaxMind, IPQualityScore) for connection with fraud.
  • Example: If WebRTC reveals an IP associated with previous rejected transactions, the anti-fraud system increases the risk rating.

3. How WebRTC leaks are detected by antifraud systems​

Anti-fraud systems integrate WebRTC data with other features to detect anomalies:
  1. IP comparison:
    • The real IP (from WebRTC) is compared with the IP from HTTP requests (e.g. X-Forwarded-For).
    • If the IPs are different, this indicates the use of a VPN or proxy, which increases the risk rating.
    • Example: WebRTC shows IP from Moscow, and HTTP requests from New York (VPN).
  2. Comparison with Device Fingerprinting:
    • WebRTC data is combined with the device fingerprint (UDID, User-Agent, Canvas API).
    • Example: If User-Agent specifies iPhone, but WebRTC-IP does not match the region of the card or account, this is flagged.
  3. Behavioural analysis:
    • Anti-fraud systems check how the user interacts with the site (for example, the speed of entering card data).
    • If WebRTC reveals a suspicious IP and the behavior (e.g. 2 second input) indicates a bot, the transaction is blocked.
  4. Machine learning:
    • ML models analyze WebRTC-IP along with other features (HTTP headers, behavior, transaction history) to assign a risk rating.
    • Example: A transaction with a VPN IP, a new Apple ID, and a blacklisted WebRTC IP receives a rating of 95/100 (high risk).
  5. Cross-platform databases:
    • WebRTC-IP is stored in databases (for example, ThreatMetrix) and compared with the device history.
    • If the IP is associated with fraud, the device is blocked everywhere.

4. How Scammers Try to Use or Bypass WebRTC (and Why It Doesn't Work)​

In the context of your interest in privacy and possible exploration of carding (although I do not support such actions):
  1. Using VPN to hide IP:
    • Method: Scammers use OpenVPN or other VPNs to spoof IPs in HTTP requests.
    • Countermeasures: WebRTC bypasses VPN unless UDP or WebRTC blocking is configured. STUN requests reveal real IP.
    • Example: OpenVPN shows US IP, but WebRTC reveals Russian IP, flagging the transaction.
  2. Disabling WebRTC:
    • Method: Scammers disable WebRTC in the browser or use plugins (such as uBlock Origin) to block it.
    • Countermeasures:
      • Anti-fraud systems notice the absence of WebRTC responses, which in itself can be an anomaly (since legitimate users rarely disable WebRTC).
      • Other features (Canvas, User-Agent, behavior) are still used for detection.
    • Example: Disabling WebRTC on iPhone via Safari (Settings → Safari → Advanced → Experimental Features) reduces leaks, but frequent data clearing or account switching is flagged.
  3. Using emulators:
    • Method: Emulators (eg Xcode) or virtual machines spoof the device to hide the real IP.
    • Countermeasures: Emulators do not support WebRTC the same way as physical devices, and the lack of sensors (gyroscope, accelerometer) gives them away.

Why it doesn't work:
  • Multi-feature analysis: Anti-fraud systems combine WebRTC-IP with other data (UDID, Canvas, behavior), making counterfeiting difficult.
  • Machine learning: ML models identify inconsistencies (e.g. VPN-IP vs. WebRTC-IP) and assign a high risk rating.
  • iPhone limitations: Safari and iOS restrict WebRTC modification without jailbreaking, which is itself flagged.
  • Logging: WebRTC-IP is stored in logs and can be passed on to law enforcement agencies.

5. Link to iPhone Setup and Privacy​

Your questions about iCloud Private Relay, OpenVPN, and iCloud management are related to privacy protection. Here's how WebRTC impacts that:
  1. iCloud Private Relay:
    • Impact: Private Relay hides IP for HTTP/HTTPS traffic in Safari, but does not affect WebRTC, which can reveal the real IP.
    • Protection: Disable WebRTC in Safari ( SettingsSafariAdvancedExperimental Features → disable WebRTC).
    • Anti-fraud detection: If WebRTC reveals an IP that does not match the region of the card or account, this is an anomaly.
  2. OpenVPN:
    • Impact: OpenVPN redirects HTTP/HTTPS traffic, but WebRTC can bypass the tunnel if UDP is not blocked.
    • Protection: Make sure your VPN provider blocks WebRTC (NordVPN has an option for this) or disable WebRTC in Safari.
    • Anti-fraud detection: WebRTC-IP different from VPN-IP is flagged as suspicious.
  3. Cleaning Safari:
    • Impact: Clearing cookies (SettingsSafariClear History and Website Data) does not affect WebRTC, as it works through JavaScript and STUN.
    • Anti-fraud detection: Frequent cookie clearing combined with WebRTC leak increases the risk rating.
  4. Change iCloud/region:
    • Impact: Changing Apple ID or region (SettingsGeneralLanguage & Region) does not affect WebRTC-IP, which remains tied to the real network.
    • Anti-fraud detection: A sudden change of region without changing WebRTC-IP signals an anomaly.

6. How to Protect Yourself from WebRTC Leaks on iPhone​

To protect privacy or study cybersecurity:
  1. Disabling WebRTC in Safari:
    • Go to SettingsSafariAdvancedExperimental Features.
    • Find the WebRTC option and disable it (for example, “Disable WebRTC”).
    • Effect: Prevents IP leaks via STUN requests in Safari.
    • Note: This only works in Safari. Other apps (such as banking apps) may use their own SDKs.
  2. Using a reliable VPN:
    • Set up OpenVPN via the OpenVPN Connect app with the configuration from a provider that blocks WebRTC (e.g. NordVPN, ExpressVPN).
    • Check your VPN settings to block UDP traffic or WebRTC.
    • Effect: Reduces the possibility of IP leaks, but requires proper configuration.
  3. Using iCloud Private Relay:
    • Включите Private Relay (Settings[Your Name]iCloudPrivate Relay).
    • Limitation: Only works in Safari and does not block WebRTC. Disable WebRTC separately.
  4. Checking for leaks:
    • Use sites like ipleak.net or browserleaks.com to check:
      • Open the website in Safari.
      • Check the “WebRTC” section - if your real IP is displayed, WebRTC is enabled.
    • Effect: Helps ensure that IP is not leaked.
  5. Additional measures:
    • Reset your IDFA regularly (SettingsPrivacyAdvertisingReset Advertising Identifier).
    • Use Hide My Email (iCloud+) for temporary emails when creating an Apple ID.
    • Avoid jailbreaking as it increases vulnerabilities and is flagged by anti-fraud systems.

7. Recommendations for legal study (cybersecurity)​

For educational purposes (cybersecurity, testing, development):
  1. WebRTC testing:
    • Use browserleaks.com or ipleak.net to analyze WebRTC leaks:
      • Connect via OpenVPN and check if the real IP is displayed.
      • Disable WebRTC in Safari and repeat the test.
    • Effect: Understand how WebRTC interacts with VPN and Private Relay.
  2. Analysis using proxy:
    • Set up Burp Suite or Charles Proxy (for legal purposes):
      • Intercept WebRTC traffic (UDP protocols) and HTTP requests.
      • Learn how STUN queries reveal IP.
    • Effect: See what data is sent to sites.
  3. Sandbox testing:
    • Create a test payment system (for example, Stripe Sandbox):
      • Try changing IP via OpenVPN and enabling/disabling WebRTC.
      • Observe how anti-fraud systems react to inconsistencies.
    • Use test cards (eg 4242 4242 4242 4242).
  4. Study of antifraud systems:
    • Read the documentation for ThreatMetrix, Sift, or FingerprintJS to understand how they use WebRTC.
    • Learn how JavaScript (e.g. RTCPeerConnection) integrates with ML models.
  5. Training:
    • Take cybersecurity courses (Coursera, Udemy) or certification (Certified Fraud Examiner).
    • Check out OWASP or articles about WebRTC vulnerabilities.

8. Why WebRTC Leaks Make Fraud Ineffective​

  • Multi-feature analysis: Anti-fraud systems combine WebRTC-IP with other data (UDID, Canvas, behavior), identifying inconsistencies.
  • Machine learning: ML models flag anomalies such as the difference between VPN-IP and WebRTC-IP.
  • Cross-platform: WebRTC-IP is stored in databases (ThreatMetrix, Sift) and shared between platforms.
  • iPhone limitations: Safari and iOS are difficult to modify to completely disable WebRTC without leaving noticeable traces.
  • Legal risks: WebRTC-IP logs may be transferred to law enforcement agencies, which entails consequences.

If you want to dive deeper into a specific aspect (like how to set up Burp Suite to analyze WebRTC or how to test leaks in a sandbox), let me know and I'll provide more details.
 
Top