Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
This PR successfully addresses a Cross-Site Scripting (XSS) vulnerability in the llm-chat-app-template by replacing unsafe .innerHTML usage with safer alternatives like .textContent and DOM methods. The changes also include dependency updates, configuration formatting improvements, and backend modifications to switch from streaming to non-streaming responses.
Changes:
- Fixed XSS vulnerability in frontend by replacing
.innerHTMLwith.textContentfor user-generated content - Updated backend to use non-streaming API responses with
returnRawResponse: true - Updated dependencies and improved TypeScript/JSON formatting
- Added a new setup script for workers-for-platforms-template
Reviewed changes
Copilot reviewed 6 out of 11 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| llm-chat-app-template/public/chat.js | Replaced .innerHTML with .textContent to prevent XSS attacks |
| llm-chat-app-template/src/index.ts | Modified to return raw streaming response from Workers AI |
| llm-chat-app-template/package.json | Updated dependency versions and improved formatting |
| llm-chat-app-template/wrangler.jsonc | Updated compatibility date and improved formatting |
| llm-chat-app-template/worker-configuration.d.ts | Updated TypeScript type definitions |
| llm-chat-app-template/tsconfig.json | Improved JSON formatting consistency |
| llm-chat-app-template/src/types.ts | Improved TypeScript formatting consistency |
| llm-chat-app-template/public/index.html | Minor CSS formatting improvements |
| workers-for-platforms-template/scripts/setup.js | Added new setup script (not related to XSS fix) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Resolve the merge conflict with cloudflare/templates main (33 new commits) so PR cloudflare#913 becomes mergeable. llm-chat-app-template resolution (preserve the XSS fix, sync config to main): - public/chat.js, public/index.html: keep the PR's XSS fix (textContent instead of innerHTML); reformat to the repo tab standard - src/index.ts: keep the PR's Workers AI change (model upgrade + returnRawResponse), which pairs with the PR's chat.js response reader - src/types.ts, tsconfig.json: no real content change from the PR; follow main - package.json, package-lock.json, wrangler.jsonc, .gitignore, worker-configuration.d.ts: follow main (current deps, compatibility_date 2025-10-08, preview_icon_url metadata, regenerated types) so templates lint / syncpack / lockfile checks pass - All files normalized to LF; prettier --check passes for the template Verified: tsc --noEmit, wrangler deploy --dry-run, templates lint, syncpack lint.
|
Thanks for this, and sorry it sat so long. Since you opened it, |
Description
This PR fixes a Cross-Site Scripting (XSS) vulnerability in the
llm-chat-app-templatewhere user-generated content from the AI chat responses was not properly sanitized before being inserted into the DOM.What was fixed:
.innerHTMLwithout sanitization, allowing potential execution of malicious scripts.innerHTMLwith.textContentfor user-generated content and implemented proper HTML escapingChanges:
public/chat.jsto use safe DOM manipulation methodssrc/index.tspackage.jsonandpackage-lock.jsonChecklist
-templatepackage.jsonis populated<!-- dash-content-start -->and<!-- dash-content-end -->to designate the Dash readme preview.gitignorefile existspackage.jsoncontains adeploycommandpackage.jsoncontainsprivate: trueand noversionfieldNote: This PR is a security fix for an existing template. All template metadata requirements were already satisfied. The changes focus solely on remediating the XSS vulnerability.