Skip to content

Commit 774a97d

Browse files
committed
fix(security): apply sanitization in refreshView() to prevent XSS (#580)
SECURITY FIX: XSS vulnerability when setting editor value via writeValue() The refreshView() method was setting innerHTML without sanitization, allowing XSS payloads to execute even with sanitize: true config. This affected all programmatic value setting: - ngModel binding - FormControl setValue/patchValue - Direct property assignment Now applies DomSanitizer in refreshView() based on config.sanitize flag. Fix verified with PoC from @MarioTesoro. Fixes #580
1 parent 4f7951f commit 774a97d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

projects/angular-editor/src/lib/editor/angular-editor.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,11 @@ export class AngularEditorComponent implements OnInit, ControlValueAccessor, Aft
275275
*/
276276
refreshView(value: string): void {
277277
const normalizedValue = value === null ? '' : value;
278-
this.r.setProperty(this.textArea.nativeElement, 'innerHTML', normalizedValue);
278+
// Apply sanitization to prevent XSS when setting innerHTML
279+
const sanitizedValue = this.config.sanitize !== false
280+
? this.sanitizer.sanitize(SecurityContext.HTML, normalizedValue)
281+
: normalizedValue;
282+
this.r.setProperty(this.textArea.nativeElement, 'innerHTML', sanitizedValue);
279283

280284
return;
281285
}

0 commit comments

Comments
 (0)