Skip to content

Fix XSS Issue #6699

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

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,21 @@ async function onExpressJsSetup(server) {
* HTML document (/src/shared/services/__mocks__/data/docu-sign-mock.html)
* that has two buttons, that do the same redirects, as the real DocuSign
* page would do on signing / rejecting a document. */
server.use('/community-app-assets/api/mock/docu-sign', (req, res) => setTimeout(() => res.send(mockDocuSignFactory(req.query.returnUrl)), 3000));
server.use('/community-app-assets/api/mock/docu-sign', (req, res) => {
const isValidUrl = (urlString) => {
const urlPattern = new RegExp('^(https?:\\/\\/)?'// validate protocol
+ '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' // validate domain name
+ '((\\d{1,3}\\.){3}\\d{1,3}))'// validate OR ip (v4) address
+ '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*'// validate port and path
+ '(\\?[;&a-z\\d%_.~+=-]*)?'// validate query string
+ '(\\#[-a-z\\d_]*)?$', 'i'); // validate fragment locator
return !!urlPattern.test(urlString);
};
if (isValidUrl(req.query.returnUrl)) {
return setTimeout(() => res.send(mockDocuSignFactory(req.query.returnUrl)), 3000);
}
return res.status(400).send('Invalid return URL');
});

/* TODO:
* This is a temporary fallback route: some of the assets in the app are not
Expand Down