Conversation
|
| <span id="e2ee-${identity}" class="e2ee-on"></span> | ||
| </div> | ||
| </div> | ||
| <div id="user-ts-${identity}" class="user-ts-overlay"> |
Check warning
Code scanning / CodeQL
Unsafe HTML constructed from library input Medium
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 13 days ago
General approach: Avoid constructing HTML with untrusted values via innerHTML and instead either (1) construct the DOM tree with document.createElement/appendChild while assigning IDs directly as properties, or (2) sanitize/escape untrusted data before inserting into HTML. Since the only dynamic piece here is identity used for element IDs, the safest, least invasive fix is to build the elements programmatically and assign id/className via DOM properties, which do not interpret the string as HTML.
Best way to fix this case without changing functionality:
- Replace the block that sets
div.innerHTML = \...`` with code that:- Creates
video,audio,div,span,progress/inputelements viadocument.createElement. - Sets
id,className, inlinestyle, and other attributes using properties orsetAttribute. - Uses the existing
isLocalParticipant(participant)check to decide whether to append avolume-control<div>with an<input>range or a<progress>element.
- Creates
- This preserves all existing element IDs and classes, so the rest of the code that looks them up by ID (
#video-${identity},#user-ts-${identity}, etc.) continues to work. - No changes are required in
Room.ts,Participant.ts,RemoteParticipant.ts, orLocalParticipant.ts; CodeQL’s taint traces into those files will be cut once theinnerHTMLsink is removed.
Concretely:
- In
examples/demo/demo.ts, insiderenderParticipant, replace lines 833–863 (the template literal assigned todiv.innerHTML) with imperative DOM creation code as described above.
No new helper methods or imports are required; we can use the standard DOM API already available.
…-sdk-js into dc/feature/user_timestamp
size-limit report 📦
|
No description provided.