Skip to main content
Back to Community & Earn Hub
Q&A Questionsecurity +150 pt Bounty

Blocking WebRTC DataChannel & STUN Exfiltration in AI Webviews and Checkout Frontends: CSP Directives vs Browser-Level Controls

@chloe_martinez3 days ago 1802 views

With WebRTC-based client-side skimming making headlines, our security team audited both our React checkout pages and the sandboxed Playwright/webview browser our AI agents use to interact with third-party SaaS apps.

Here is the surprise we hit: Most teams assume setting Content-Security-Policy: connect-src 'self' https://api.ourdomain.com stops unauthorized data exfiltration.

However:

  1. WebRTC RTCPeerConnection ICE/STUN/TURN traffic operates over UDP/TCP outside standard fetch/XHR interception hooks.
  2. Even if DataChannels are blocked at a firewall, encoding short secrets into STUN/ICE subdomain lookups can still leak data if DNS isn't locked down.

What is the cleanest combination of CSP, Permissions-Policy, and Chromium/Playwright flags to kill unauthorized WebRTC egress without breaking legitimate app features?

1 Answers

Community Answers

@elena_rostova Accepted Answer2 days ago

You have to lock this down at both the HTTP policy layer and the browser runtime layer—connect-src alone is not enough for ICE/STUN leaks.


1. Harden Web Frontends (Checkout / Sensitive Pages)

  • Use strict script-src with nonces + Subresource Integrity (integrity="sha384-...") on every third-party tag so rogue skimmers cannot execute in the first place.
  • Add webrtc / Permissions-Policy & connect-src discipline: Note that connect-src does not cover STUN/TURN in all browsers, so on sensitive checkout routes, monkey-patch/freeze window.RTCPeerConnection early in an inline CSP-nonced <head> script if your checkout doesn't use WebRTC:
html
<script nonce="{{CSP_NONCE}}">
  Object.defineProperty(window, "RTCPeerConnection", { value: undefined, writable: false, configurable: false });
  Object.defineProperty(window, "webkitRTCPeerConnection", { value: undefined, writable: false, configurable: false });
</script>

2. Harden Sandboxed AI Browser Agents (Chromium / Playwright)

Launch Chromium with WebRTC IP/UDP leak prevention and proxy enforcement:

  • --force-webrtc-ip-handling-policy=disable_non_proxied_udp
  • --enforce-webrtc-ip-permission-check
  • Route all browser traffic through your egress allowlist proxy and block UDP ports 3478 / 5349 (STUN/TURN) at the container/microVM firewall.

Have a solution or working configuration?

Sign in or create a free account to answer this question (+10 pts, +25 pts if accepted) and tag helpful AIStoreHub repositories.