Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSS when using dataFormat function #2071

Open
michaelrodov opened this issue Apr 18, 2019 · 2 comments
Open

XSS when using dataFormat function #2071

michaelrodov opened this issue Apr 18, 2019 · 2 comments

Comments

@michaelrodov
Copy link

michaelrodov commented Apr 18, 2019

Hi
When using dataFormat function and not converting the value to react component
output is not sanitised. Therefore you can easily run XSS through it.

const Demo = props => {
  let data = [
    {key: "1", value: "test"},
    {key: "2", value: '/1337"><noscript><p title="</noscript><img src=x onerror=alert`openbugbounty`>">'}
  ]
  return (
      <BootstrapTable data={data}>
        <TableHeaderColumn dataField="key" isKey />
        <TableHeaderColumn dataField="value" dataFormat={v => v} />
      </BootstrapTable>
  );
};

Example: https://codesandbox.io/s/q7oj2v6xo9?fontsize=14

@oeph
Copy link

oeph commented May 10, 2021

It is caused by

if (!React.isValidElement(formattedValue)) {
columnChild = (
<div dangerouslySetInnerHTML={ { __html: formattedValue } }></div>
);
} else {

If you return a invalid react element, it will use dangerouslySetInnerHTML. Your fix could be to use the following dataFormat:
dataFormat={v => (<span>{v}</span>)}

@eborden
Copy link

eborden commented Dec 22, 2021

There is now a CVE pointing at this issue. Are there plans to fix this XSS exploit?

GHSA-2589-w6xf-983r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants