PDF lure: credential harvesting via HTML and WebSocket
Attack Techniques & Methods2026-11-09, 10:17
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
- The HTML file is opened from an email attachment or via a link and appears as a page containing a PDF.
- 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 asfetch/XMLHttpRequest: the browser does not block establishing a connection to another origin. During the handshake, the server receives theOriginheader 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. - 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»
- The entered username and password are sent to the server in a JSON frame named
doc_auth. Each frame is tagged withclientId, allowing the server to associate the data with a specific session. - 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 serverws_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 tows_listener.py, which routes frames byclientIdand inserts the client's IP from theCF-Connecting-IPheader.
Vendors
Products
More