Skip to content

Commit 57d215b

Browse files
Security: Sanitize mathjaxBind content to prevent stored XSS (#5108)
Render challenge HTML through Angular sanitize instead of compiling user content as live Angular templates. Co-authored-by: Cursor Agent <cursoragent@cursor.com>
1 parent 240856c commit 57d215b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

frontend/src/js/directives/directives.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,12 @@ function dashboardFooterController($scope) {
340340
(function() {
341341
'use strict';
342342

343-
angular.module('evalai').directive("mathjaxBind", ['$compile', '$timeout', function($compile, $timeout) {
343+
angular.module('evalai').directive("mathjaxBind", ['$sanitize', '$timeout', function($sanitize, $timeout) {
344344
return {
345345
restrict: "A",
346346
link: function(scope, element, attrs) {
347347
scope.$watch(attrs.mathjaxBind, function(texExpression) {
348-
var template = angular.element('<div>').html(texExpression).contents();
349-
var compiledTemplate = $compile(template)(scope);
350-
element.empty().append(compiledTemplate);
348+
element.html($sanitize(texExpression || ''));
351349
$timeout(function() {
352350
/* eslint-disable no-undef */
353351
MathJax.Hub.Queue(["Typeset", MathJax.Hub, element[0]]);

0 commit comments

Comments
 (0)