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

Fixing Vulnerability A Fortify Scan finds a critical Cross-Site Scrip… #2451

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/helpers/isURLSameOrigin.js
@@ -1,6 +1,7 @@
'use strict';

var utils = require('./../utils');
var isValidXss = require('./isValidXss');

module.exports = (
utils.isStandardBrowserEnv() ?
Expand All @@ -27,6 +28,8 @@ module.exports = (
href = urlParsingNode.href;
}

isValidXss(url);

urlParsingNode.setAttribute('href', href);

// urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
Expand Down
6 changes: 6 additions & 0 deletions lib/helpers/isValidXss.js
@@ -0,0 +1,6 @@
'use strict';

module.exports = function isValidXss(requestURL) {
var regex = RegExp('<script+.*>+.*<\/script>');
return regex.test(requestURL);
};
4 changes: 4 additions & 0 deletions test/specs/helpers/isURLSameOrigin.spec.js
Expand Up @@ -8,4 +8,8 @@ describe('helpers::isURLSameOrigin', function () {
it('should detect different origin', function () {
expect(isURLSameOrigin('https://github.com/axios/axios')).toEqual(false);
});

it('should detect xss', function () {
expect(isURLSameOrigin('https://github.com/axios/axios?<script>alert("hello")</script>')).toEqual(false)
})
});