.. / tinymce
Star Fork

The world’s #1 JavaScript library for rich text editing. Available for React, Vue and Angular.

tinymce
tinymce
...

Latest

<any> @any ⏱️ func-parameter
More information

Root Cause

Source: https://github.com/tinymce/tinymce/blob/b7a0e50b920961aac4d29619f721a4f915221df1/modules/tinymce/src/core/main/ts/content/SetContentImpl.ts#L66

const setContentString = (editor: Editor, body: HTMLElement, content: string, args: SetContentArgs): SetContentResult => {
  // [...]

  } else {
    if (args.format !== 'raw') {
      content = HtmlSerializer({ validate: false }, editor.schema).serialize(
        editor.parser.parse(content, { isRootContent: true, insert: true })
      );
    }

    const trimmedHtml = isWsPreserveElement(SugarElement.fromDom(body)) ? content : Tools.trim(content);
    setEditorHtml(editor, trimmedHtml, args.no_selection);

    return { content: trimmedHtml, html: trimmedHtml };
  }
};

Related links:


≤6.8.3&≤7.1.2 | CVE-2024-38357

<noscript> @any ⏱️ func-parameter
More information

Root Cause

Source: https://github.com/tinymce/tinymce/blob/f59e49f83b66262c5e6cc3b53e5258047eb56f4f/modules/tinymce/src/core/main/ts/dom/DomSerializerFilters.ts#L86

  htmlParser.addNodeFilter('noscript', (nodes) => {
    let i = nodes.length;
    while (i--) {
      const node = nodes[i].firstChild;

      if (node) {
        node.value = Entities.decode(node.value ?? '');
      }
    }
  });

Related links:

Found by Malav-MK.


≤5.10.8&≤6.7.2 | CVE-2023-48219

<noscript> @any ⏱️ func-parameter
More information

Root Cause

Source: https://github.com/tinymce/tinymce/blob/403c51d35c21b1cde13ec4f3c58e0fd976e816a1/modules/tinymce/src/core/main/ts/dom/TrimBody.ts#L36-L46

const removeCommentsContainingZwsp = (body: HTMLElement): void => {
  const walker = createCommentWalker(body);
  let nextNode = walker.nextNode();
  while (nextNode !== null) {
    const comment = walker.currentNode as Comment;
    nextNode = walker.nextNode();
    if (Type.isString(comment.nodeValue) && comment.nodeValue.includes(Zwsp.ZWSP)) {
      Remove.remove(SugarElement.fromDom(comment));
    }
  }
};

Related links:

Found by @kinugawamasato.


≤5.10.7&≤6.7.0 | CVE-2023-45818

<comment> <noscript> @any ⏱️ func-parameter
More information

Root Cause (PoC #1)

Source: https://github.com/tinymce/tinymce/blob/79fae0b5868a52bfe2303d237326f7fcf5bdf739/modules/tinymce/src/core/main/ts/dom/TrimHtml.ts#L86

const trimHtml = (tempAttrs: string[], html: string): string => {
  const trimContentRegExp = new RegExp([
    '\\s?(' + tempAttrs.join('|') + ')="[^"]+"' // Trim temporary data-mce prefixed attributes like data-mce-selected
  ].join('|'), 'gi');

  return html.replace(trimContentRegExp, '');
};

Root Cause (PoC #2)

Source: https://github.com/tinymce/tinymce/blob/79fae0b5868a52bfe2303d237326f7fcf5bdf739/modules/tinymce/src/core/main/ts/dom/TrimHtml.ts#L109

const trimInternal = (serializer: DomSerializer, html: string): string => {
  // [...]

  while ((matches = bogusAllRegExp.exec(content))) {
    // [...]

    content = content.substring(0, index - matchLength) + content.substring(endTagIndex);
    bogusAllRegExp.lastIndex = index - matchLength;
  }

  // [...]
};

Root Cause (PoC #3)

Source: https://github.com/tinymce/tinymce/blob/79fae0b5868a52bfe2303d237326f7fcf5bdf739/modules/tinymce/src/core/main/ts/dom/TrimHtml.ts#L113

const trimInternal = (serializer: DomSerializer, html: string): string => {
  // [...]

  return Zwsp.trim(content);
};

Related links:

Found by @kinugawamasato.


Source | History