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

HPFortify XSS vulnerability #781

Open
TheRedeemed opened this issue Mar 25, 2020 · 2 comments
Open

HPFortify XSS vulnerability #781

TheRedeemed opened this issue Mar 25, 2020 · 2 comments

Comments

@TheRedeemed
Copy link

Hi,

We are using useHistory() from the react-router-dom in our project. Our code was flagged for XSS vulnerability by HPFortify. The following line "window.location.href = href;" seems to be the problem.
This line is in the function push(path, state) which is in createBrowserHistory(props). I'm assuming this is coming from the history package.

Could you please comment on this issue? If there will be a fix, it will be helpful to know a tentative date for the fix?

Regards,

@gauravshah27
Copy link

Hi,

I have been facing the same issue from the push function. There are 2 places within the push function that use "window.location.href=href". Here is the code snippet from history.js that is causing an issue:

if (canUseHistory) {
    globalHistory.pushState({
         key: key,
         state: state
     }, null, href);

     if (forceRefresh) {
          window.location.href = href;
      } else {
          var prevIndex = allKeys.indexOf(history.location.key);
          var nextKeys = allKeys.slice(0, prevIndex + 1);
          nextKeys.push(location.key);
          allKeys = nextKeys;
          setState({
            action: action,
            location: location
          });
      }
} else {
     warning(state === undefined, 'Browser history cannot push state in browsers that do not support HTML5 history');
      window.location.href = href;
}

I have gone through my code and confirmed that we are not passing the forceRefresh prop and all the browsers that I am using support HTML5 history api which would result in canUseHistory being true and so the outer else block code never executes.

What is the recommended solution for this? Is there an update in the works that will address this issue that we are facing?

@TheRedeemed
Copy link
Author

@gauravshahhere I ended up doing the same thing that you did and marked it as a non issue.

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

2 participants