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

@LukasReschke LukasReschke commented Dec 2, 2014

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

@kogmbh-ci kogmbh-ci commented Dec 2, 2014

Can one of the admins verify this patch?

Loading

@kossebau
Copy link
Contributor

@kossebau kossebau commented Dec 2, 2014

ok to test

Loading

@kogmbh-ci
Copy link

@kogmbh-ci kogmbh-ci commented Dec 2, 2014

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

Loading

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

@peitschie peitschie Dec 3, 2014

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)

Loading

Copy link
Contributor

@peitschie peitschie Dec 3, 2014

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");

Loading

Copy link
Contributor Author

@LukasReschke LukasReschke Dec 3, 2014

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)

Loading

@LukasReschke LukasReschke force-pushed the allow-data-and-js-uris branch from 55d71e3 to 805a110 Dec 3, 2014
@kogmbh-ci
Copy link

@kogmbh-ci kogmbh-ci commented Dec 3, 2014

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

Loading

@peitschie
Copy link
Contributor

@peitschie peitschie commented Dec 3, 2014

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

Loading

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

@kossebau kossebau Dec 5, 2014

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):/?

Loading

Copy link
Contributor Author

@LukasReschke LukasReschke Dec 19, 2014

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.

Loading

@LukasReschke LukasReschke force-pushed the allow-data-and-js-uris branch from 805a110 to 0f4190a Dec 19, 2014
@kogmbh-ci
Copy link

@kogmbh-ci kogmbh-ci commented Dec 19, 2014

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

Loading

@LukasReschke LukasReschke force-pushed the allow-data-and-js-uris branch from 0f4190a to 934cb91 Jan 7, 2015
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 LukasReschke force-pushed the allow-data-and-js-uris branch from 934cb91 to 5bd39ab Jan 7, 2015
@LukasReschke
Copy link
Contributor Author

@LukasReschke LukasReschke commented Jan 7, 2015

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

I also fixed c29f77c#commitcomment-9190875

Loading

LukasReschke referenced this issue 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

@kogmbh-ci kogmbh-ci commented Jan 7, 2015

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

Loading

@kogmbh-ci
Copy link

@kogmbh-ci kogmbh-ci commented Jan 7, 2015

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

Loading

@peitschie
Copy link
Contributor

@peitschie peitschie commented Jan 7, 2015

@kossebau this is waiting for your +1 😸

Loading

@kossebau
Copy link
Contributor

@kossebau 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 :)

Loading

kossebau pushed a commit that referenced this issue Jan 8, 2015
Prevent hyperlink handler for potential dangerous URIs
@kossebau kossebau merged commit d35829a into webodf:master Jan 8, 2015
1 check passed
Loading
@LukasReschke LukasReschke deleted the allow-data-and-js-uris branch Jan 8, 2015
@LukasReschke
Copy link
Contributor Author

@LukasReschke LukasReschke commented Jan 8, 2015

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

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants