Skip to content
XSS Disclosed report Beginner

Reflected Self-XSS Vulnerability in the Comment section of Files Information

A self-XSS in the file comments section executes a user-supplied payload when the user clicks edit after posting a comment.

naveenv Follow

Originally disclosed on HackerOne

Bounty$100incl. $100 bonus View original
  • Triaged in 16 hours
  • Fixed in 19 hours
  • Paid in 19 hours
  • Disclosed after 2 days

Vulnerability Found In the test domain: demo.nextcloud.com Vulnerability Type : Reflected XSS

STEPS TO REPRODUCE:

STEP 1: Login to demo nextcloud server site using test credentials.(demo.nextcloud.com) STEP 2: On the All Files Tab ,Select Any File. STEP 3: A tab opens on the Right Hand side of the screen which holds the informations of File Selected.Choose the "Comments" Section Next to Activities. STEP 4: In the Comments Box,the payload to execute XSS is passed.

Test Payloads:

</textarea> </textarea><script>alert(1)</script>

STEP 5: Click on the Post button. STEP 6: After the comment is posted,"Click on the Edit Comments Button that will appear near the posted comment when cursor was hovered over comment" "THE APPLIED XSS PAYLOAD GETS EXECUTED WHILE CLICKING THE EDIT BUTTON THAT APPEARS"

The original report as published on HackerOne, by naveenv. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What the report shows

The researcher tested the file information panel on the Nextcloud test domain at demo.nextcloud.com and reported a reflected cross-site scripting issue in the Comments section. The report classifies the finding as Reflected XSS. It does not give a severity rating or a CVSS score, and it does not describe a fix.

The reproduction steps are short and entirely manual:

  1. Log in to the demo Nextcloud server with test credentials.
  2. On the All Files tab, select any file.
  3. A panel opens on the right-hand side of the screen with the information for the selected file. Choose the Comments section, next to Activities.
  4. Enter the XSS payload in the Comments box.
  5. Click the Post button.
  6. Hover over the posted comment and click the Edit Comments button that appears next to it. The payload executes at that point.

The payload the researcher used is given as a test payload:

HTML
</textarea><script>alert(1)</script>

The closing </textarea> tag suggests the comment text may be placed inside a textarea element when the edit view is rendered, so the injected closing tag could end that element and let the following script element be parsed as markup. The report does not show the server response or the HTML that contains the payload, so the exact rendering context is inferred from the payload rather than demonstrated.

The researcher's own summary of the outcome is that the payload is executed when the Edit button is clicked. That timing matters: the comment is stored and displayed first, and the script runs when the edit interface is opened. The report calls the issue reflected, but the sequence described, posting a comment and then triggering execution through a later action on that same comment, is closer to what is usually called stored or persistent XSS. The report does not resolve that discrepancy.

Root cause

A plausible explanation is that the comment text is inserted into the edit form's HTML without being HTML-encoded, in a position where the application assumes the content sits safely inside a textarea. Because the comment body is not escaped, a user-supplied </textarea> sequence closes the element early and anything after it is treated as HTML by the browser. The report does not identify the specific template, function or parameter responsible.

Impact

The report gives only an alert(1) payload. In the scenario described, the payload runs when the user who posted the comment clicks Edit, which looks like self-XSS: the person who enters the payload is the person who triggers it. Any wider impact would depend on whether a comment containing the payload can be made to reach a second user's edit view, which the report does not establish.

How this kind of bug works

Cross-site scripting happens when untrusted data is placed into a document in a context where the browser will interpret it as code or markup. The context determines the escape that is needed. Inside an element's text content, < and & must be encoded. Inside an attribute, quotes must be encoded as well. Inside a script block or an event handler, HTML encoding is not enough and the data must be handled as JavaScript data, ideally through a safe API rather than string concatenation.

A textarea is a raw text element: character references are decoded, but tags inside it are not parsed as elements. That is why applications sometimes place user content there without escaping, on the assumption that nothing can break out. The assumption fails as soon as the content contains the element's own closing tag, because the HTML parser ends the raw text element at the first matching </textarea> and resumes normal parsing. Everything after it is markup.

The robust defence is contextual output encoding applied automatically by the templating layer, so that < becomes &lt; and the closing tag can never terminate the element. Content Security Policy, framework-level auto-escaping and input validation reduce the chance or the effect, but encoding at the point of output is the control that actually stops this class of bug.

How to test for it

  1. Identify every place where user-controlled text is rendered back into a page: comments, descriptions, file names, display names, labels, share messages, activity entries.
  2. For each, submit a harmless marker that is distinctive and easy to search for, for example a short random string, and find where it appears in the response.
  3. Inspect the surrounding HTML to determine the context: element text, attribute value, textarea, title, script block, JSON embedded in the page, or an event handler.
  4. Send a context-appropriate probe. For a suspected raw text element, a closing tag followed by a simple script is the standard check. For attributes, break out of the quotes. For script blocks, try a string terminator.
  5. Trigger every view of the same data, not just the display view. Edit forms, previews, moderation queues and notification emails often render the same content through different code paths, and one of them may skip encoding.
  6. A positive result is your probe executing in the browser, or appearing unencoded in the response in a position where it would execute. Confirm with a benign payload such as an alert or a DOM change, and record the exact request and response.

Common false positives: the payload appears encoded in the response but a client-side script later decodes and inserts it; the payload is reflected but the response has a content type that prevents HTML parsing; the browser's own XSS auditor or a CSP blocks execution, which hides a real encoding bug rather than proving its absence; and self-XSS where only the submitting user can reach the payload, which is usually not accepted as a vulnerability on its own.

How it is fixed

Apply contextual output encoding to all user-controlled values, including those placed inside textarea, title and other raw text elements. Use the templating engine's automatic escaping rather than manual string building, and never mark user content as safe HTML. Where rich text is genuinely required, sanitise it with a well-maintained HTML sanitiser on the server and allow only a safe subset of tags and attributes. Add a restrictive Content Security Policy as defence in depth, and add regression tests that post a comment containing a closing tag and assert that it is rendered as text.

Hunting notes

This class of bug tends to hide in secondary rendering paths: edit forms, previews, print views, export templates, notification emails and administrative interfaces that reuse stored content. Any feature that stores text and later re-renders it in a different component is worth checking, because the two paths may not share the same escaping.

Recon signals include applications that render user content into textarea or title elements, older templating code that concatenates strings, endpoints that return HTML fragments for AJAX updates, and features with a separate edit mode. Watching how a value is encoded in the display view and then comparing it with the edit view is often enough to spot the gap.

To make a report accepted, show execution with a minimal payload, include the exact request and the relevant part of the response, and be explicit about who can trigger it. If only the submitting user can trigger the payload, say so plainly; programs generally treat that as self-XSS and may close it, so look for a path where the stored content reaches another user's browser before claiming impact.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 9 min read.

What happened, in plain words

Each file has an information panel, and that panel has a Comments section where people can write notes about the file. The researcher tested this on the Nextcloud test domain at demo.nextcloud.com and found that a comment containing a small piece of code could make the browser run that code.

The report calls the issue Reflected XSS. It does not describe a fix.

The steps are short and entirely manual:

  1. Log in to the demo Nextcloud server with test credentials.
  2. On the All Files tab, select any file.
  3. A panel opens on the right-hand side of the screen with the information for the selected file. Choose the Comments section, next to Activities.
  4. Enter the XSS payload in the Comments box.
  5. Click the Post button.
  6. Hover over the posted comment and click the Edit Comments button that appears next to it. The payload executes at that point.

Step 3 matters because it shows where the comment box sits: in the file information panel. Step 6 matters because of the timing. The comment is saved and shown first, and the code only runs when the edit interface is opened. That is a different moment from the one where the text was typed.

The payload the researcher used is given as a test payload:

HTML
</textarea><script>alert(1)</script>

Line by line:

  • </textarea> is a closing tag for a textarea, the multi-line text box used in web forms. The researcher put it at the start, which suggests the comment text may be placed inside a textarea when the edit view is built. Sending the closing tag could end that box early.
  • <script>alert(1)</script> is a script element. alert(1) asks the browser to show a small pop-up with the number 1. It does nothing harmful; it is the standard way to prove that code ran.

If the closing tag ends the textarea, the browser would stop treating what follows as plain text and start treating it as part of the page, so the script element would be parsed as real markup and executed. The report does not show the server response or the HTML that contains the payload, so this rendering context is inferred from the payload rather than demonstrated.

The researcher's own summary is that the payload executes when the Edit button is clicked. The report calls the issue reflected, but the sequence described, posting a comment and then triggering execution through a later action on that same comment, is closer to what is usually called stored or persistent XSS. The report does not resolve that discrepancy.

Root cause

A plausible explanation is that the comment text is inserted into the edit form's HTML without being HTML-encoded, in a position where the application assumes the content sits safely inside a textarea. Because the comment body is not escaped, a user-supplied </textarea> sequence closes the element early and anything after it is treated as HTML by the browser. The report does not identify the specific template, function or parameter responsible.

Impact

The report gives only an alert(1) payload. In the scenario described, the payload runs when the user who posted the comment clicks Edit, which looks like self-XSS: the person who enters the payload is the person who triggers it. Any wider impact would depend on whether a comment containing the payload can be made to reach a second user's edit view, which the report does not establish.

In general, how this kind of bug works

Cross-site scripting, usually shortened to XSS, happens when untrusted data is placed into a web page in a spot where the browser will read it as code or markup instead of as text. Think of a form where you write your name and the site later prints it on a page: if the site prints it as text, a name like <b>hello</b> just shows up as those characters. If the site pastes it into the page as raw HTML, the browser sees a bold tag and renders it. XSS is the same idea with a script instead of bold text.

The place where the data lands is called the context, and the context decides what escaping is needed. Inside an element's text content, < and & must be encoded. Inside an attribute, quotes must be encoded as well. Inside a script block or an event handler, HTML encoding is not enough and the data must be handled as JavaScript data, ideally through a safe API rather than string concatenation.

A textarea is a raw text element: character references are decoded, but tags inside it are not parsed as elements. That is why applications sometimes place user content there without escaping, on the assumption that nothing can break out. The assumption fails as soon as the content contains the element's own closing tag, because the HTML parser ends the raw text element at the first matching </textarea> and resumes normal parsing. Everything after it is markup.

The robust defence is contextual output encoding applied automatically by the templating layer, so that < becomes &lt; and the closing tag can never terminate the element. Content Security Policy, framework-level auto-escaping and input validation reduce the chance or the effect, but encoding at the point of output is the control that actually stops this class of bug.

In general, how to test for it

  1. Identify every place where user-controlled text is rendered back into a page: comments, descriptions, file names, display names, labels, share messages, activity entries.
  2. For each, submit a harmless marker that is distinctive and easy to search for, for example a short random string, and find where it appears in the response.
  3. Inspect the surrounding HTML to determine the context: element text, attribute value, textarea, title, script block, JSON embedded in the page, or an event handler.
  4. Send a context-appropriate probe. For a suspected raw text element, a closing tag followed by a simple script is the standard check. For attributes, break out of the quotes. For script blocks, try a string terminator.
  5. Trigger every view of the same data, not just the display view. Edit forms, previews, moderation queues and notification emails often render the same content through different code paths, and one of them may skip encoding.
  6. A positive result is your probe executing in the browser, or appearing unencoded in the response in a position where it would execute. Confirm with a benign payload such as an alert or a DOM change, and record the exact request and response.

Common false positives: the payload appears encoded in the response but a client-side script later decodes and inserts it; the payload is reflected but the response has a content type that prevents HTML parsing; the browser's own XSS auditor or a CSP blocks execution, which hides a real encoding bug rather than proving its absence; and self-XSS where only the submitting user can reach the payload, which is usually not accepted as a vulnerability on its own.

In general, how it is fixed

Apply contextual output encoding to all user-controlled values, including those placed inside textarea, title and other raw text elements. Use the templating engine's automatic escaping rather than manual string building, and never mark user content as safe HTML. Where rich text is genuinely required, sanitise it with a well-maintained HTML sanitiser on the server and allow only a safe subset of tags and attributes. Add a restrictive Content Security Policy as defence in depth, and add regression tests that post a comment containing a closing tag and assert that it is rendered as text.

In general, where to look when hunting

This class of bug tends to hide in secondary rendering paths: edit forms, previews, print views, export templates, notification emails and administrative interfaces that reuse stored content. Any feature that stores text and later re-renders it in a different component is worth checking, because the two paths may not share the same escaping.

Recon signals include applications that render user content into textarea or title elements, older templating code that concatenates strings, endpoints that return HTML fragments for AJAX updates, and features with a separate edit mode. Watching how a value is encoded in the display view and then comparing it with the edit view is often enough to spot the gap.

To make a report accepted, show execution with a minimal payload, include the exact request and the relevant part of the response, and be explicit about who can trigger it. If only the submitting user can trigger the payload, say so plainly; programs generally treat that as self-XSS and may close it, so look for a path where the stored content reaches another user's browser before claiming impact.

Glossary

  • XSS (cross-site scripting): a bug where untrusted text ends up in a page in a position where the browser runs it as code or markup.
  • Reflected XSS: the payload comes back in the response to the same request that sent it, rather than being saved and shown later.
  • Stored (persistent) XSS: the payload is saved by the application and runs whenever the saved content is later displayed.
  • Self-XSS: the person who enters the payload is also the person who triggers it, so no other user is affected.
  • Payload: the piece of text or code an attacker sends to try to trigger a bug.
  • HTML: the markup language browsers use to build pages from tags such as <script> and </textarea>.
  • Tag: a piece of HTML markup in angle brackets, such as <script>, that tells the browser what an element is.
  • Element: a complete piece of HTML, from its opening tag to its closing tag, such as <textarea>...</textarea>.
  • textarea: a multi-line text input box in a web form. Its contents are treated as raw text, not as markup.
  • Raw text element: an HTML element whose contents the parser does not treat as markup, ending only at its own closing tag.
  • HTML encoding (escaping): converting characters such as < into safe forms such as &lt; so the browser shows them as text instead of reading them as markup.
  • Context: the exact place in a page where data lands (text, attribute, script, textarea), which decides what escaping is needed.
  • Templating engine: the part of a web application that builds HTML pages from templates and data, and can escape values automatically.
  • Content Security Policy (CSP): a response header that tells the browser which sources of script and other content are allowed, as an extra layer of defence.
  • Sanitiser: a tool that removes dangerous tags and attributes from user-supplied HTML while keeping a safe subset.
  • DOM: the browser's in-memory model of the page, which scripts can read and change.
  • AJAX: a way for a page to fetch data from the server and update part of itself without a full reload.
  • CVSS: a standard scoring system for rating the severity of a vulnerability.
  • Bounty: a payment a program makes to a researcher who reports a valid vulnerability.
  • False positive: a result that looks like a bug but is not one, for example because something else blocks or changes the payload.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site scripting (XSS)

The lesson behind this report.

Script an attacker supplies runs in another user's browser, on the target's origin, with that user's session.