-
Notifications
You must be signed in to change notification settings - Fork 59
Prevent possible XSS via changeDebugUrl #519
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes look good to me. Which issue is this for again? I don't see the issue number in the PR description or any of the commit messages. Did you do that for a specific reason?
@snake14 This was a fix for XSS vulnerability report which I have shared in the slack channel you can check that |
@AltamashShaikh Thank you. I see it now. |
API.php
Outdated
{ | ||
$this->accessValidator->checkWriteCapability($idSite); | ||
if (!filter_var($url, FILTER_VALIDATE_URL)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually wondering if using FILTER_VALIDATE_URL
only might cause problems here. It does not check if the protocol is "safe". It could also be ssh://
or similar. So we could additionally check preg_match('/^https?:\/\//')
, or do you think other protocols are needed there as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@sgiehl Added stripos($url, 'http')
check to ensure valid protocol is present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the problem with stripos === false
is, that you don't check if it's in the beginning. So something like ssh://http.webhost.com
would pass here... So guess you would need to compare with !== 0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated and added few testcases too
API.php
Outdated
{ | ||
$this->accessValidator->checkWriteCapability($idSite); | ||
if (!filter_var($url, FILTER_VALIDATE_URL) || stripos($url, 'http') !== 0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fyi @AltamashShaikh does it make sense to also look at UrlHelper::isLookLikeSafeurl("")
here additionally? it includes a few additional checks. There's also isLookLikeurl("")
which may be interesting too not sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tsteur Ideally the 'stripos($url, 'http') === 0' should fix most of the cases but adding both the methods makes no harm.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 that's what I thought. Better be safe. Also in the future someone might add more changes to core and we won't remember to add them here as well meaning then we're covered.
Description:
Changes to fix possible XSS via changeDebugUrl
Review