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

Filter out url parameter when a non-relative path is provided. Also a… #1687

Merged
merged 5 commits into from Feb 4, 2019
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
2 changes: 1 addition & 1 deletion bin/copy_swagger_ui.sh
Expand Up @@ -5,4 +5,4 @@
# will need to be manually updated based on node_modules/swagger-ui-dist/index.html
# if it ever changes.
cp node_modules/swagger-ui-dist/{*.js,*.css,*.png} public/swagger-ui
cp node_modules/js-cookie/src/js.cookie.js public/swagger-ui
cp node_modules/js-cookie/src/js.cookie.js public/swagger-ui
9 changes: 9 additions & 0 deletions public/swagger-ui/api.html
Expand Up @@ -82,6 +82,15 @@
console.warn('Unable to retrieve CSRF Token from cookie');
}
}
// Add check for protocol so that we know if someone tries to throw a non-relative path in the url parameter.
// This is here to prevent malicious actors using the parameter to execute arbitrary malicious code on an
// unsuspecting user (swagger-ui behavior causes this to happen otherwise).
var protocolRegex = /(http|https):*/;
var isNonRelativePath = protocolRegex.test(req['url']);
if (isNonRelativePath) {
req['url'] = null;
}

return req;
};

Expand Down
9 changes: 9 additions & 0 deletions public/swagger-ui/internal.html
Expand Up @@ -82,6 +82,15 @@
console.warn('Unable to retrieve CSRF Token from cookie');
}
}
// Add check for protocol so that we know if someone tries to throw a non-relative path in the url parameter.
// This is here to prevent malicious actors using the parameter to execute arbitrary malicious code on an
// unsuspecting user (swagger-ui behavior causes this to happen otherwise).
var protocolRegex = /(http|https):*/;
var isNonRelativePath = protocolRegex.test(req['url']);
if (isNonRelativePath) {
req['url'] = null;
}

return req;
};

Expand Down