Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion editron-starters/json-server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fetch(url)
.then((r) => r.json())
.then(
(json) =>
(document.getElementById('output').innerHTML = JSON.stringify(
(document.getElementById('output').textContent = JSON.stringify(
json,
null,
2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function setupCounter(element) {

const setCounter = (count) => {
counter = count;
element.innerHTML = `count is ${counter}`;
element.textContent = `count is ${counter}`;
};

setCounter(0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export function setupCounter(element) {

const setCounter = (count) => {
counter = count;
element.innerHTML = `count is ${counter}`;
element.textContent = `count is ${counter}`;
};

element.addEventListener('click', () => setCounter(counter + 1));
Expand Down
2 changes: 1 addition & 1 deletion modules/playground/components/playground-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ const PlaygroundEditor = ({
`;
}
}
styleEl.innerHTML = css;
styleEl.textContent = css;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Validate awareness values before generating CSS.

textContent prevents HTML parsing, but it does not escape CSS. If a collaborator can control state.user.name or state.user.color, these values can break the generated CSS and inject additional rules. Validate color against an allowlist or hex format, and apply CSS-string escaping to name before interpolation.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@modules/playground/components/playground-editor.tsx` at line 391, Validate
state.user.color against an approved color allowlist or hex format before
generating css, and CSS-escape state.user.name before interpolating it into the
stylesheet. Update the CSS construction immediately before styleEl.textContent
in the playground editor, preserving the existing style injection flow while
preventing user-controlled values from adding CSS rules.

};

provider.awareness.on("update", handleAwarenessUpdate);
Expand Down