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

disable javascript execution by default #3818

Merged
merged 1 commit into from
Feb 13, 2017

Conversation

himanshug
Copy link
Contributor

most users don't use javascript but still have it enabled because it happens to be default behavior and are surprised that it is enabled by default even with severe security threat.

with 0.10.0, we can disable javascript by default.

@gianm
Copy link
Contributor

gianm commented Jan 5, 2017

Pretty bold @himanshug :)

There should be a doc change for this too, at least to javascript.md and probably a few other files. Maybe also add a property druid.javascript.enable so the config to enable javascript doesn't look so goofy (druid.javascript.disable=false is a double negative and looks weird). If you do that then there should be something verifying that the two properties match up if they're both defined.

That all being said, I'm not sure how I feel about making this change. JavaScript being off by default appeals to me because it's generally not recommended except for prototyping, and is not sandboxed at all (which, even though documented, is likely surprising to users). But I am also reticent to go buck wild with incompatible changes. I'll go along with whatever the consensus is though.

@pjain1
Copy link
Member

pjain1 commented Jan 5, 2017

I am 👍 with the changes. I agree with Gian, I think we can just have an enable or enabled property and we can keep getDefault() method in addition to getEnabled() which would have enable set to false.

@@ -73,8 +73,8 @@ public String toString()
'}';
}

public static JavaScriptConfig getDefault()
public static JavaScriptConfig getEnabled()
Copy link
Contributor

Choose a reason for hiding this comment

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

I did a double-take on this, thinking it was a method getting whether or not something was enabled. getEnabledInstance() or enabledInstance() would probably be clearer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@himanshug
Copy link
Contributor Author

@gianm I can make all the other doc updates etc , if we conclude that it makes sense to disable javascript by default. yes, it is backward incompatible and that is why 0.10.0 would be the right time to do it.
m adding the discuss tag on it.

@jon-wei
Copy link
Contributor

jon-wei commented Jan 6, 2017

I think having javascript disabled is a good default, and IMO it doesn't impose a huge incompatibility transition cost on users (just add the enable property to the config)

Also agree on flipping the setting name from druid.javascript.disabled to druid.javascript.enabled

@himanshug himanshug force-pushed the disable_javascript branch 2 times, most recently from efe1136 to 27de087 Compare January 6, 2017 20:43
@himanshug himanshug removed the Discuss label Jan 6, 2017
@himanshug
Copy link
Contributor Author

@gianm @jon-wei @pjain1 switched config name from "disabled" to "enabled" and updated javascript.md docs

@himanshug himanshug force-pushed the disable_javascript branch 5 times, most recently from 3a5b4bf to e73a915 Compare January 9, 2017 16:01
@pjain1
Copy link
Member

pjain1 commented Jan 9, 2017

👍

@fjy
Copy link
Contributor

fjy commented Jan 12, 2017

👍


Druid does not execute JavaScript functions in a sandbox, so they have full access to the machine. So Javascript
functions allow users to execute arbutrary code inside druid process. So, by default, Javascript is disabled.
However, on dev/staging environments or a secured production environments you can enable those by setting
Copy link
Contributor

Choose a reason for hiding this comment

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

a secured production environments -> remove the a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@jon-wei updated

@jon-wei
Copy link
Contributor

jon-wei commented Jan 12, 2017

Had a minor comment on doc wording, otherwise 👍

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

Looks good, but can I request we keep this open until next weeks dev sync?

@@ -22,6 +22,14 @@ without needing to write and deploy Druid extensions.

Druid uses the Mozilla Rhino engine at optimization level 9 to compile and execute JavaScript.

## Security

Druid does not execute JavaScript functions in a sandbox, so they have full access to the machine. So Javascript
Copy link
Contributor

Choose a reason for hiding this comment

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

"arbitrary"

@vogievetsky
Copy link
Contributor

👎 booo JavaScript makes the world go round. There are a number of cool things in Plywood that would stop working if JavaScript was disabled.

@vogievetsky
Copy link
Contributor

The specific things that JS is used for as a gap filler are:

$("time").timePart('SECOND_OF_DAY', 'Etc/UTC')

=>

{
  "dimension": "__time",
  "extractionFn": {
    "function": "function(s){try{\nvar d = new org.joda.time.DateTime(s);\nd = d.getSecondOfDay();\nreturn d;\n}catch(e){return null;}}",
    "type": "javascript"
  },
  "outputName": "Time",
  "type": "extraction"
}

@himanshug
Copy link
Contributor Author

@vogievetsky those are compelling reasons to have js enabled on cluster ( and by default specially for Pivot users)
couldn't discuss this one today, will conclude it in next sync-up.

@himanshug
Copy link
Contributor Author

so, we discussed both options in the dev sync and concluded that it should be secure by default and by making users explicitly enable it, they will know the risks versus current default where users have it enabled inadvertently and not even using the JS features.

@himanshug
Copy link
Contributor Author

this was discussed again today and still concluded to go ahead and disable javascript by default. @fjy @gianm

@gianm
Copy link
Contributor

gianm commented Feb 7, 2017

Ok, that sounds fair @himanshug. One request I have is to edit the docs for the "javascript" things to point out that it's disabled by default, otherwise users might get confused when the things they read about in the docs don't work. One way to do this is to change the info note that is next to all the javascript things to something like:

<div class="note info">
JavaScript-based functionality is disabled by default. Please refer to the Druid
<a href="../development/javascript.html">JavaScript programming guide</a> for
guidelines about using Druid's JavaScript functionality, including instructions on
how to enable it.
</div>

@gianm
Copy link
Contributor

gianm commented Feb 7, 2017

If you search in the docs for "JavaScript programming guide" you should then find all the boxes.

@himanshug himanshug force-pushed the disable_javascript branch 2 times, most recently from b672c5d to 266351f Compare February 9, 2017 19:03
@himanshug
Copy link
Contributor Author

@gianm docs for "JavaScript programming guide" are updated.

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@himanshug I am OK with this patch as-is after fixing conflicts

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

Successfully merging this pull request may close these issues.

6 participants