LearnNewsExamplesConnect
Frontmatter
assigneesneo-fable-clio
createdAtNov 10, 2026, 1:17 PM
updatedAtNov 10, 2026, 4:51 PM
githubUrlhttps://github.com/neomjs/neo/issues/20714
authorneo-fable-clio
commentsCount2
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtNov 10, 2026, 4:51 PM

Blog post: JSON.stringify is not safe inside a script tag (JSON-LD XSS)

Closed v14.0.0/archive-v14-0-0-chunk-1 documentationenhancementai
neo-fable-clio
neo-fable-clio commented on Nov 10, 2026, 1:17 PM

Reopened Nov 10: it ships as written. The ticket was closed the same day on two objections from the operator, and both still hold: a reader learns nothing about Neo from it, and its problem is solved and well documented. He then offered to publish the finished piece anyway. It ships as drafted, with its cover, the public record of the case and the reviews that were pending, plus his one condition of the same day: a closing section that says what Neo.mjs is, with a call to action and the engine's link, because a read without them converts nobody. There is no re-cut: a review that asks for a restructure closes it for good. It is not the Neo post this seat owes; that one is the Fleet Manager's.

Source case: #20700 (the crawler half of #20671) · Authoring rules: .agents/skills/blog-post/references/blog-authoring-guide.md and outbound-post.md · Outbound gate: D#19500

Context

On Nov 10 a review of the builder that writes the crawler snapshots of neomjs.com (a private repository; its public companion ticket is #20700) ran one function with a heading that held an escaped closing script tag. The new per-route JSON-LD came out with a raw </script> inside its <script type="application/ld+json"> element. The element ends there, and what follows is parsed as HTML. The suite was green. The change was repaired before it merged on Nov 10: the escape and a spec with a hostile heading went in with it.

The pattern is not ours alone. JSON.stringify(data) into a script element is the usual way structured data is written on a server. The HTML standard names the sequences to escape (§4.12.1.3, "Restrictions for contents of script elements"), the Next.js JSON-LD guide carries the warning and the escape in its own snippet, and Rails ships json_escape for it. A developer who adds JSON-LD for search rarely meets any of the three.

  • Live latest-open + closed sweep: latest 20 open of 26 (orange band; no owning ticket or epic for posts exists) and closed search (JSON-LD script tag XSS blog post, JSON.stringify script XSS; 0 hits) at 2026-11-10T12:15:39Z; no equivalent or prior exclusion found.
  • A2A in-flight claim sweep: 30 newest messages, all read states, at 2026-11-10T12:15Z; no claim on this scope.
  • Memory Core & own-assignment sweep: query_raw_memories("blog post JSON-LD script tag XSS JSON.stringify escape closing script tag") (no prior art) and my open issues (#20498, #20682; no overlap).
  • Structure map: N/A (a post under learn/blog/).
  • Ownership: self-assigned. Not a good first issue: it is owned, and its source case sits in a private repository.

The Problem

A reader who renders JSON-LD holds one of three beliefs, and each is half true:

  1. The framework escapes for me. It does for text nodes. JSON-LD is written through the raw path (dangerouslySetInnerHTML, v-html, a template string), because an escaped &lt; inside a script element is not decoded and would change the data.
  2. A data block is inert. It is not executed. The parser still ends the element at the first </script, whatever the type says.
  3. My data is trusted. Product names, article titles, author names and review text are written by users or editors.

Nothing in a normal suite contradicts these beliefs: the specs assert the shape for friendly strings.

The Architectural Reality

  • A post is learn/blog/<slug>.md, registered by hand in apps/portal/resources/data/blog.json; it renders at #/news/blog/<id>. The sitemap and llms.txt are generated, never hand-edited.
  • Images live in neomjs/pages under resources_pub/website/blog/<slug>/ and merge before the post. A cover is 2400×1260, subject and text inside the centred 1890×1260.
  • Every post carries at least one diagram or image, render-verified before merge, and ships after two model reviews, one of them from another family, with one consolidated fact check at the final version by a seat that did not draft.
  • Outbound claims cite public receipts only. The source change lives in a private repository, so the public receipt for the case is a comment on #20700, written once the repair has merged.

The Fix

One post, written for a developer who has never heard of Neo.mjs.

  • Headline (candidate): JSON.stringify is not safe inside a script tag: the JSON-LD XSS and its one-line fix. The product name stays in the byline and the body.
  • Subtitle (candidate): One </script> in a title ends a structured-data block early, and the rest of it is parsed as HTML. Why the parser does that, the fix, and a test to paste.
  • Slug: json-ld-xss-json-stringify-in-a-script-tag
  • Search term: JSON-LD XSS, second JSON.stringify script tag. Demand: the Next.js guide documents the escape, Rails ships a helper, an npm package and a lint rule exist for it, and fixes landed in several ecosystems this year (searches of Nov 10).
  • Reader and hardest read: a frontend or full-stack developer who renders JSON-LD on a server. They skip because of the three beliefs above. The first screen therefore shows the line they have and the input that breaks it, with output they can reproduce in Node in a minute.
  • Arc: the one-liner → the input that breaks it, run → why: the tokenizer does not read type; the second failure, where <!--<script swallows the rest of the page → the fix (< as \u003c, valid JSON, the same data after parsing) and what not to do (entity-escaping) → a spec to paste: a hostile value in every string field, no raw < in the output → how it passed a green suite here and what the review did differently (it ran the function) → try it on your own builder.
  • Visuals: the cover, which shows the element as written against the nodes the parser builds from it. The draft's Mermaid flowchart showed the same picture a second time and stays removed. Since Nov 10 the section "Why the parser does this" carries one Mermaid diagram of its own: the three readers of the string in their order. The operator asked for the diagram image the Medium version needs.
  • Receipts: the HTML standard, the Next.js guide, the Rails helper and Google's structured-data documentation, each read in full; the case on #20700.
  • Outbound: the venue fills of outbound-post.md §0 are drafted in the same PR.

Decision Record impact

none.

Acceptance Criteria

  • learn/blog/json-ld-xss-json-stringify-in-a-script-tag.md exists, is registered in blog.json (the file parses) and renders at its route; the PR carries the render receipt for each visual and the cover's 3:2 crop.
  • The first screen holds the one-liner and the breaking input, and the snippet runs in plain Node without our stack.
  • Every external claim links a primary source read in full; every internal claim links a public receipt; the private repository is named as private.
  • The search term stands in the title, the subtitle and the first 150 words (grep -c in the PR).
  • The outbound fills are in the same PR.
  • Two model reviews, one from another family; one reviewer reads as a stranger; one consolidated fact check at the final version by a seat that did not draft.
  • The peer whose change is the case has agreed to how it is told.
  • Post-merge: the publish request with term, title, cover and hardest read goes to the operator, whose click it is.

Out of Scope

  • The repair itself (#20700 and its private companion).
  • A helper or lint rule in the Engine.
  • Statements about the current state of other products.

Avoided Traps

  • A second-person title ("Your JSON-LD is …"): the blog guide's flavor 4.
  • The case told as a peer's mistake. The line is the default snippet in every ecosystem; the case shows how a green suite passes it.
  • The private pull request as a receipt. A reader cannot open it.
  • A claim that some product is vulnerable. Only what its own documentation states, linked.

Related

Origin Session ID: 5763f5f2-2f05-4efd-ad24-89e66a416527 Retrieval Hint: "JSON-LD script tag XSS JSON.stringify blog post crawler snapshot review"

tobiu referenced in commit 6ec1e18 - "docs(blog): JSON.stringify is not safe inside a script tag, the JSON-LD XSS (#20714) (#20718) on Nov 10, 2026, 4:51 PM
tobiu closed this issue on Nov 10, 2026, 4:51 PM