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

Prevent hyperlink handler for potential dangerous URIs #850

Merged
merged 1 commit into from
Jan 8, 2015

Conversation

LukasReschke
Copy link
Contributor

This prevents the user from clicking on URIs starting with javascript or data. The reason behind this is that this may be used to trick users in executing dangerous JS when viewing an untrusted document. (which is the case in our deployment for ownCloud)

I'm not absolutely happy with that patch for multiple reasons, but I consider it a feasible approach:

  1. It uses a blacklisting instead of a whitelisting approach. But when it comes to URI schemes there may be a lot of possible values such as mailto:foo@bar.com or ftp://. That's why I went with this route instead.
  2. I originally wanted to check for javascript: instead but this fails due to the JSLint policy which then complains about lib/gui/HyperlinkClickHandler.js:119:28: error: JavaScript URL.

@kogmbh-ci
Copy link

Can one of the admins verify this patch?

@kossebau
Copy link
Contributor

kossebau commented Dec 2, 2014

ok to test

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2288/

window.open(url);
// Ask the browser to open the link in a new window. `javascript` and `data` URIs are disabled for
// security reasons.
if (url.toLowerCase().indexOf('javascript') !== 0 && url.toLowerCase().indexOf('data') !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be done via regex:

/(javascript|data):/i.test(url)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it's worth logging when the url is ignored:

runtime.log("WARN:", "potentially malicious URL ignored");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. Updated the PR. Though I went with /^(javascript|data):/i.test(url)

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2289/

@peitschie
Copy link
Contributor

I'm happy with this, so 👍 from me. @kossebau, are you wanting further reviews on this?

window.open(url);
// Ask the browser to open the link in a new window. `javascript` and `data` URIs are disabled for
// security reasons.
if(/^(javascript|data):/i.test(url)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least firefox 33.0 also deals with urls that are prepended with whitespaces, so evil persons could hack this by prepending whitespaces. So perhaps better /^\s*(javascript|data):/?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta love browser's forgiveness … - Adjusted. THX.

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2291/

This prevents the user from clicking on URIs starting with `javascript:` or `data:`. The reason behind this is that this may be used to trick users in executing dangerous JS when viewing an untrusted document. (which is the case in our deployment for ownCloud)

I'm not absolutely happy with that patch since it uses a blacklisting instead a whitelisting approach, but I consider it a feasible approach. Especially, considering all the possible values. (`mailto:foo@bar.com`, `ftp://`, `skype://`, etc...)

Conflicts:
	ChangeLog.md
@LukasReschke
Copy link
Contributor Author

I rebased this - can I please get some momentum on this?

I also fixed c29f77c#commitcomment-9190875

LukasReschke referenced this pull request Jan 7, 2015
…ments

If there are only floating elements, the Dojo toolbar shrinks to 0 height.

To prevent this for left-aligned elements, do not set them as
float:left. (Also reorder generation to keep current tool ordering)

And for elements floating to the right, clear any floating for the toolbar element
with "clear:both" on the pseudo :after element.
@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2301/

@kogmbh-ci
Copy link

Build succeeded.
Refer to this link for build results: http://ci.kogmbh.com/jenkins/job/WebODF-PullReq/2302/

@peitschie
Copy link
Contributor

@kossebau this is waiting for your +1 😸

@kossebau
Copy link
Contributor

kossebau commented Jan 8, 2015

Time to work the switches to have this roll into master. There is a button with a switch symbol, perhaps that does it...
Thanks for the patch :)

kossebau pushed a commit that referenced this pull request Jan 8, 2015
Prevent hyperlink handler for potential dangerous URIs
@kossebau kossebau merged commit d35829a into webodf:master Jan 8, 2015
@LukasReschke LukasReschke deleted the allow-data-and-js-uris branch January 8, 2015 12:29
@LukasReschke
Copy link
Contributor Author

@kossebau THX - I'll coordinate some patches on our side - please don't share this too prominently yet.

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

Successfully merging this pull request may close these issues.

4 participants