T09 · Insecure Skill Coding Practices
- Location
references/schema-examples.md:378- Finding
Unsafe JSON-LD Serialization May Enable Stored Cross-Site Scripting
- Content
View full analysis
``` can terminate the `application/ld+json` element at the HTML-parser level. The browser may then interpret the injected markup as executable JavaScript. The non-executable MIME type of the original JSON-LD element does not prevent this because the injection first closes that element and creates a separate executable script element. This flaw is especially relevant when product details originate from a CMS, marketplace seller account, imported catalog, API, or another source not fully trusted by the application. ### Attack Path 1. An attacker obtains the ability to supply or modify a product or CMS field used in the schema object. 2. The attacker places an HTML-breaking payload containing `` in that field. 3. The application copies the malicious value into `schema`. 4. `JSON.stringify(schema)` preserves the HTML closing ...[truncated 1143 chars]- Remediation
View remediation
/g, "\\u003e") .replace(/&/g, "\\u0026") .replace(/\u2028/g, "\\u2028") .replace(/\u2029/g, "\\u2029"); } `, `<`, `>`, `&`, U+2028, and U+2029. 6. Update the documented Next.js example so users do not copy the unsafe pattern into production applications. ]]>
