efek.me/blog

Grok Web UI — Frontend HTML & CSS Injection Vulnerability

October 14, 2026•11 min read•Cybersecurity
Grok Web UI — Frontend HTML & CSS Injection Vulnerability

Overview

On June 12, 2026 (12.06.2026), during an interface security analysis of the Grok Web UI (grok.com), I discovered a Frontend Rendering Validation Failure when pasting raw HTML source code.

When pasting a raw HTML code block containing inline <style>, @keyframes, and <img> tags into the prompt box, the Grok web interface attempted to execute and render these HTML elements directly onto the chat UI instead of escaping them as plain text. This allowed arbitrary elements to break out of the chat message container, causing severe UI distortion and full-screen layout hijacking overlaying the entire chat application.

PropertyDetails
Target ApplicationGrok Web UI (grok.com by xAI)
ResearcherEfe Kırbaş
Vulnerability ClassFrontend Rendering Validation Failure / HTML & Inline CSS Injection
Discovery DateJune 12, 2026 (12.06.2026)
StatusResolved / Patched
SeverityMedium / High (UI Redirection, Phishing Overlays, Clickjacking & Chat Defacement)

The Original Bug Report

Below is the verbatim bug report submitted to the Grok development team on Discord:

Title: Bug Report: Grok Web UI HTML Rendering / Injection Issue
Issue: Frontend rendering validation failure when pasting raw HTML source code.
Details: When pasting a raw HTML code block containing inline <style>, @keyframes, and <img> tags into the prompt box, the Grok web interface (grok.com) attempts to execute and render these HTML elements directly onto the chat UI instead of escaping them as plain text. This causes severe UI distortion and layout corruption overlaying the chat screen.
Expected Behavior: The interface should safely escape all tags and display the input purely as plain text inside a standard markdown code block.
Actual Behavior: The browser executes the inline styles and loads the external image asset from the user prompt, breaking the entire layout of the chat interface.


Steps to Reproduce

  1. Navigate to grok.com and open a new chat session.
  2. Paste the raw HTML code snippet below into the prompt input box.
  3. Submit the prompt or send the message.
  4. Observe that the client browser executes the injected styles, rendering a full-screen fixed loader overlay that covers the chat interface and interferes with normal UI interaction.

Proof of Concept (PoC) Code

(Sanitized placeholder title and image URL used in the snippet below)

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Custom Loader Overlay</title>
  </head>
  <body>
    <div
      id="site-loader"
      style="position:fixed;inset:0;z-index:99999;background:#0a0a0f;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:22px;"
    >
      <style>
        @keyframes sl-spin {
          to {
            transform: rotate(360deg);
          }
        }
        @keyframes sl-pulse {
          0%, 100% {
            opacity: .55;
            transform: scale(1);
          }
          50% {
            opacity: 1;
            transform: scale(1.06);
          }
        }
      </style>
      <div style="position:relative;width:88px;height:88px">
        <div
          style="position:absolute;inset:-4px;border-radius:50%;border:2.5px solid rgba(116,71,127,0.18);border-top-color:#9d68aa;animation:sl-spin 0.9s linear infinite;"
        ></div>
        <img
          src="https://example.com/assets/loader.png"
          width="88"
          height="88"
          style="border-radius:50%;object-fit:cover;animation:sl-pulse 2.4s ease-in-out infinite;"
          draggable="false"
        />
      </div>
    </div>
  </body>
</html>

Technical Breakdown

1. Viewport Hijacking via position: fixed & inset: 0

In single-page applications (SPAs), message threads are nested inside specific DOM containers (such as scrollable divs with overflow management). However, by applying position: fixed; inset: 0;, the injected #site-loader element breaks completely free from its parent container boundaries, expanding across the entire client viewport (100vw × 100vh).

2. UI Overlay Dominance with z-index: 99999

The excessive z-index: 99999 value forces the browser to render the injected backdrop above all native Grok UI elements—including:

  • The sidebar navigation and chat history
  • The prompt input bar and model selectors
  • Settings, user account menus, and interactive buttons

3. Arbitrary Keyframe & CSS Execution

The frontend parser accepted <style> tags containing custom @keyframes definitions (sl-spin, sl-pulse). Injected animations continuously consume GPU/CPU rendering resources, creating layout thrashing or browser tab slowdowns.

4. Unrestricted External Asset Loading

The <img> tag fetched an external asset from an arbitrary third-party CDN (example.com). This introduces an out-of-band communication vector where external resource requests reveal the client's IP address, referer header, and browser user-agent to third-party endpoints.


Security Impact & Attack Scenarios

While direct JavaScript execution (<script> or event handlers like onload/onerror) was filtered out, raw HTML and inline CSS injection in an AI chat interface introduces several severe exploitation pathways:

  1. Phishing & Credential Harvester Modals:
    An attacker sharing a malicious Grok prompt link or manipulating an indirect prompt injection could overlay a pixel-perfect fake authentication dialog ("Your Grok session has expired — please re-enter your credentials to continue").
  2. Clickjacking & Interface Hijacking:
    Transparent or strategically positioned overlays can capture mouse clicks intended for native application controls, redirecting users or triggering unwanted actions.
  3. Denial of Service (UI Freeze):
    Full-screen opaque overlays prevent the user from reviewing conversation history, submitting new prompts, or navigating the platform without performing a hard page reload or wiping local storage.

Video Demonstration

The video demonstration below shows the step-by-step reproduction of the bug, the prompt submission, and the immediate takeover of the Grok Web UI layout:

Demonstration: PoC video showing the HTML/CSS injection and viewport lock on Grok Web UI


Vendor Communication & Developer Response

The bug was reported on June 12, 2026 at 06:20. Within 1 hour and 18 minutes, a developer from the Grok web team (grokwebdev) responded to the report:

"we currently allow this because we sanitize all dangerous code, but we may remove this to improve the quality of the product"
— grokwebdev, June 12, 2026, 07:38

Following this communication, the Grok development team took action to resolve the issue.


Remediation & Resolution

To effectively prevent layout-breaking HTML/CSS injection, markdown rendering pipelines should implement the following defenses:

  1. Strict Tag Escaping:
    Code snippets and unvetted inputs should always be escaped into safe HTML entities (&lt;div&gt; instead of raw <div>) inside markdown code fences.
  2. CSS Property Whitelisting / Sanitization:
    Markdown sanitizers (e.g., Rehype plugins or DOMPurify) should explicitly strip layout-altering properties like position: fixed, position: absolute, viewport units (vh, vw), and extreme z-index values from allowed inline styles.
  3. Disallow <style> and <link> Blocks:
    Arbitrary stylesheet injection should be removed from user-rendered content to prevent unwanted animation loops and CSS-based data exfiltration.

Current Status: Fixed

In subsequent frontend updates, Grok's web client was patched. The parser now properly escapes structural HTML containers and eliminates dangerous layout styles, ensuring the chat interface remains fully isolated and secure against UI injection attacks.


Timeline

Date & TimeEvent
12.06.2026 — 06:20Vulnerability discovered and reported to Grok development team with PoC code
12.06.2026 — 07:38Grok developer (grokwebdev) responded and acknowledged the behavior
Post-DisclosureFrontend update deployed; strict HTML tag escaping and layout style sanitization implemented
Current StatusSuccessfully Patched / Resolved