I'm trying to understand if there is a chance for an XSS attack when our api endpoint returns a json response with a property returning html data:
e.g.
https://www.link-to-my-website.com/api/v1/data
Resp:
{
footer: "<a href='https://www.link-to-my-website.com'>My Link</a>"
}
and then in React.js (or any js frontend) doing something like:
import React from 'react';
import PropTypes from 'prop-types';
export default class MyFooterComponent extends React.Component {
render() {
return (
<div className="footer" dangerouslySetInnerHTML={{ __html: this.props.footer }} />
);
}
}
Am I putting my end users at risk? and should I sanitize or simply not pass data this way? Or am I too paranoid here?
Thank you!