PDF lure: credential harvesting via HTML and WebSocket

A researcher using the handle g3tsyst3m published an analysis of a technique that embeds a PDF in an HTML page through iframe, bypassing restrictions on JavaScript execution in PDF readers. The approach harvests credentials through a fake modal window, using WebSocket as the communication channel.
How the technique works Modern browsers isolate the PDF renderer in a separate process, preventing access to the DOM and cookies. Instead of looking for ways around this sandbox, the researcher proposes loading the PDF in an iframe on a regular HTML page. All JavaScript runs in the context of the page, which is not restricted by the PDF reader's rules.
How the chain works
  1. The HTML file is opened from an email attachment or via a link and appears as a page containing a PDF.
  2. The page opens a WebSocket connection to the attacker's server (wss:// on port 443). WebSocket is not subject to CORS policy in the same way as fetch/XMLHttpRequest: the browser does not block establishing a connection to another origin. During the handshake, the server receives the Origin header and may reject the connection if the origin is not allowed. However, this is a server-side check: the browser itself does not block WebSocket connections to another origin.
  3. Instead of the document contents, a Windows 11-style modal window appears with the message «This PDF is encrypted. Enter your username and password to open it»
  4. The entered username and password are sent to the server in a JSON frame named doc_auth. Each frame is tagged with clientId, allowing the server to associate the data with a specific session.
  5. After the credentials are entered, the PDF becomes visible, and the server can send the user new modal windows or files over the same WebSocket. Network architecture. The setup includes three components: a local console, ws_server.py, a VPS running the relay server ws_listener.py, and Cloudflare Tunnel. The relay server forwards WebSocket frames between the console and the connected page. Neither accepts incoming connections from the internet — all connections are outbound. The user connects to the Cloudflare domain, and the traffic travels through the tunnel to ws_listener.py, which routes frames by clientId and inserts the client's IP from the CF-Connecting-IP header.
Vendors
Products
More