Skip to main content
Vulnerability Database/CVE-2024-24556

CVE-2024-24556: Nearform Urql GraphQL Client XSS Vulnerability

CVE-2024-24556 is a cross-site scripting flaw in Nearform Urql GraphQL client that allows attackers to inject malicious scripts through improper HTML escaping in streamed responses. This post covers technical details, affected versions, impact analysis, and mitigation strategies.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2024-24556 Overview

CVE-2024-24556 is a Cross-Site Scripting (XSS) vulnerability [CWE-79] in the @urql/next package, part of the urql GraphQL client ecosystem maintained by nearform. The flaw results from improper escaping of HTML-like characters within streamed server responses. When a web application uses @urql/next with streamed responses (non-RSC) and a GraphQL response contains attacker-influenced html tags, those characters can break out of the serialized data context and execute in the browser. Maintainers resolved the issue in version 1.1.1 by introducing an htmlEscapeJsonString utility that neutralizes <, >, &, and line separators before the payload reaches the client.

Critical Impact

Attackers can inject arbitrary script into pages rendered by @urql/next streamed responses, leading to session theft, credential harvesting, and client-side account takeover.

Affected Products

  • nearform urql — @urql/next package versions prior to 1.1.1
  • Next.js applications using @urql/next with streamed (non-RSC) responses
  • Deployments where GraphQL responses can contain user-controlled HTML-like content

Discovery Timeline

  • 2024-01-30 - CVE-2024-24556 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2024-24556

Vulnerability Analysis

The @urql/next package hydrates GraphQL results into the server-rendered HTML stream so that the client can reuse data without an additional network round trip. During this hydration, result payloads were serialized into inline <script> content without escaping HTML-sensitive characters. An attacker who can influence a GraphQL field value — for example, a user-supplied name, bio, or comment field — can inject a sequence containing </script> followed by arbitrary markup. The browser terminates the inline script tag early and parses the attacker payload as HTML, triggering script execution in the victim's origin.

Exploitation requires the application to use streamed responses rather than React Server Components (RSC), and user interaction to visit the affected route.

Root Cause

The serializer in packages/next-urql/src/DataHydrationContext.ts emitted JSON directly into the HTML stream without escaping characters that have special meaning to the HTML parser. Specifically, <, >, &, \\u2028, and \\u2029 were passed through verbatim, allowing JSON string values to terminate the surrounding <script> element.

Attack Vector

An attacker stores a crafted GraphQL field value containing HTML terminators and script payloads. When a victim loads a page that streams this value through @urql/next, the payload executes in their browser session. No authentication is required to deliver the payload if the target field is reachable by unauthenticated writes.

typescript
// Patch introducing the escape utility
// Source: https://github.com/urql-graphql/urql/commit/4b7011b70d5718728ff912d02a4dbdc7f703540d
 import * as React from 'react';
 import { ServerInsertedHTMLContext } from 'next/navigation';
 import type { UrqlResult } from './useUrqlValue';
+import { htmlEscapeJsonString } from './htmlescape';

 interface DataHydrationValue {
   isInjecting: boolean;
typescript
// New escape helper added in packages/next-urql/src/htmlescape.ts
// Source: https://github.com/urql-graphql/urql/commit/4b7011b70d5718728ff912d02a4dbdc7f703540d
const ESCAPE_LOOKUP: { [match: string]: string } = {
  "&": "\\\u0026",
  ">": "\\\u003e",
  "<": "\\\u003c",
  "\\u2028": "\\\u2028",
  "\\u2029": "\\\u2029",
};

export const ESCAPE_REGEX = /[&><\\u2028\\u2029]/g;

export function htmlEscapeJsonString(str: string): string {
  return str.replace(ESCAPE_REGEX, (match) => ESCAPE_LOOKUP[match]);
}

Detection Methods for CVE-2024-24556

Indicators of Compromise

  • GraphQL responses or persisted field values containing </script> sequences, <svg onload=, or javascript: URIs
  • Browser Content Security Policy (CSP) violation reports originating from inline script execution on pages rendered by @urql/next
  • Unexpected outbound requests from user browsers to attacker-controlled domains shortly after loading streamed pages

Detection Strategies

  • Audit package.json and lockfiles for @urql/next versions earlier than 1.1.1 across all Next.js projects.
  • Review GraphQL field values in storage for suspicious HTML or script fragments, focusing on free-text fields exposed to streamed server rendering.
  • Enable CSP in report-only mode to surface inline script execution attempts tied to hydrated urql payloads.

Monitoring Recommendations

  • Instrument server-rendered routes to log GraphQL response sizes and field entropy, flagging anomalies that correlate with injection attempts.
  • Monitor web application firewall (WAF) telemetry for GraphQL mutations containing encoded script payloads or Unicode line separators.
  • Track client-side JavaScript errors from streamed pages, since broken-out script contexts frequently generate parse errors before executing.

How to Mitigate CVE-2024-24556

Immediate Actions Required

  • Upgrade @urql/next to version 1.1.1 or later in every affected project and redeploy.
  • Inventory GraphQL schemas and identify fields that accept user-generated content rendered through streamed responses.
  • Rotate session tokens and credentials for users who may have visited vulnerable pages during the exposure window.

Patch Information

The fix was delivered in commit 4b7011b70d5718728ff912d02a4dbdc7f703540d and released in @urql/next version 1.1.1. Review the GitHub Security Advisory GHSA-qhjf-hm5j-335w and the upstream commit for implementation details.

Workarounds

  • Switch affected routes to React Server Components (RSC) rendering, which does not use the vulnerable streamed hydration path.
  • Enforce a strict Content Security Policy that disallows inline scripts and uses nonces or hashes for required scripts.
  • Sanitize or reject HTML-sensitive characters in GraphQL inputs at the resolver layer until the patched version is deployed.
bash
# Upgrade @urql/next to the fixed release
npm install @urql/next@^1.1.1

# Verify the installed version
npm ls @urql/next

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.