[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Security concerns with minified javascript code



 ❦ 28 août 2015 08:22 +0100, Philip Hands <phil@hands.com> :

>>> Or alternatively, by packaging the minifier that is being used with the package
>>> that needs it.  Yes, that's a horrible idea with lots of code duplication, but
>>> if I understand the problem, every JS file must be minified with the exact
>>> version of the minifier that upstream used, so then every package would have
>>> its own unique package that it depends on, and in that case they can just be
>>> merged.  But it can't really be that bad, right?
>>
>> Here is the dependency graph of jQuery (only to build it!):
>>
>> jquery@3.0.0-pre /home/bernat/src/jquery
> [ very long list ]
>> ├─┬ grunt-contrib-jshint@0.11.2
> ...
>> │ └─┬ jshint@2.8.0
>         ^^^^^^^^^^^^
>
> I don't know much about this, but I do know that that is a version that
> contains code licensed under the "Do No Evil" license of JSlint:
[...]

It would be quite easy to not use it at all. Here is a curated list
which removes any tool needed only for testing and linting:

jquery@3.0.0-pre /home/bernat/src/jquery
├─┬ commitplease@2.0.0
│ ├─┬ chalk@0.4.0
│ │ ├── ansi-styles@1.0.0
│ │ ├── has-color@0.1.7
│ │ └── strip-ansi@0.1.1
│ ├── mout@0.8.0
│ └── semver@2.2.1
├── core-js@0.9.17
├─┬ grunt@0.4.5
│ ├── async@0.1.22
│ ├── coffee-script@1.3.3
│ ├── colors@0.6.2
│ ├── dateformat@1.0.2-1.2.3
│ ├── eventemitter2@0.4.14
│ ├── exit@0.1.2
│ ├─┬ findup-sync@0.1.3
│ │ ├─┬ glob@3.2.11
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.3.0
│ │ │   ├── lru-cache@2.6.5
│ │ │   └── sigmund@1.0.1
│ │ └── lodash@2.4.2
│ ├── getobject@0.1.0
│ ├─┬ glob@3.1.21
│ │ ├── graceful-fs@1.2.3
│ │ └── inherits@1.0.2
│ ├─┬ grunt-legacy-log@0.1.2
│ │ ├── grunt-legacy-log-utils@0.1.1
│ │ ├── lodash@2.4.2
│ │ └── underscore.string@2.3.3
│ ├── grunt-legacy-util@0.2.0
│ ├── hooker@0.2.3
│ ├── iconv-lite@0.2.11
│ ├─┬ js-yaml@2.0.5
│ │ ├─┬ argparse@0.1.16
│ │ │ ├── underscore@1.7.0
│ │ │ └── underscore.string@2.4.0
│ │ └── esprima@1.0.4
│ ├── lodash@0.9.2
│ ├─┬ minimatch@0.2.14
│ │ ├── lru-cache@2.6.5
│ │ └── sigmund@1.0.1
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.7
│ ├── rimraf@2.2.8
│ ├── underscore.string@2.2.1
│ └── which@1.0.9
├─┬ grunt-babel@5.0.1
│ └─┬ babel-core@5.8.23
│   ├── babel-plugin-constant-folding@1.0.1
│   ├── babel-plugin-dead-code-elimination@1.0.2
│   ├── babel-plugin-eval@1.0.1
│   ├── babel-plugin-inline-environment-variables@1.0.1
│   ├── babel-plugin-jscript@1.0.4
│   ├── babel-plugin-member-expression-literals@1.0.1
│   ├── babel-plugin-property-literals@1.0.1
│   ├── babel-plugin-proto-to-assign@1.0.4
│   ├── babel-plugin-react-constant-elements@1.0.3
│   ├── babel-plugin-react-display-name@1.0.3
│   ├── babel-plugin-remove-console@1.0.1
│   ├── babel-plugin-remove-debugger@1.0.1
│   ├── babel-plugin-runtime@1.0.7
│   ├─┬ babel-plugin-undeclared-variables-check@1.0.2
│   │ └── leven@1.0.2
│   ├── babel-plugin-undefined-to-void@1.1.6
│   ├── babylon@5.8.23
│   ├── bluebird@2.9.34
│   ├─┬ chalk@1.1.1
│   │ ├── ansi-styles@2.1.0
│   │ ├── escape-string-regexp@1.0.3
│   │ ├─┬ has-ansi@2.0.0
│   │ │ └── ansi-regex@2.0.0
│   │ ├─┬ strip-ansi@3.0.0
│   │ │ └── ansi-regex@2.0.0
│   │ └── supports-color@2.0.0
│   ├── convert-source-map@1.1.1
│   ├── core-js@1.1.1
│   ├─┬ debug@2.2.0
│   │ └── ms@0.7.1
│   ├─┬ detect-indent@3.0.1
│   │ ├── get-stdin@4.0.1
│   │ └── minimist@1.2.0
│   ├── esutils@2.0.2
│   ├── fs-readdir-recursive@0.1.2
│   ├── globals@6.4.1
│   ├─┬ home-or-tmp@1.0.0
│   │ ├── os-tmpdir@1.0.1
│   │ └── user-home@1.1.1
│   ├─┬ is-integer@1.0.4
│   │ ├─┬ is-finite@1.0.1
│   │ │ └── number-is-nan@1.0.0
│   │ └─┬ is-nan@1.2.1
│   │   └─┬ define-properties@1.1.1
│   │     ├── foreach@2.0.5
│   │     └── object-keys@1.0.7
│   ├── js-tokens@1.0.1
│   ├── json5@0.4.0
│   ├─┬ line-numbers@0.2.0
│   │ └── left-pad@0.0.3
│   ├── lodash@3.10.1
│   ├─┬ minimatch@2.0.10
│   │ └─┬ brace-expansion@1.1.0
│   │   ├── balanced-match@0.2.0
│   │   └── concat-map@0.0.1
│   ├─┬ output-file-sync@1.1.1
│   │ ├─┬ mkdirp@0.5.1
│   │ │ └── minimist@0.0.8
│   │ └── xtend@4.0.0
│   ├── path-exists@1.0.0
│   ├── path-is-absolute@1.0.0
│   ├── private@0.1.6
│   ├─┬ regenerator@0.8.35
│   │ ├─┬ commoner@0.10.3
│   │ │ ├── commander@2.5.1
│   │ │ ├─┬ glob@4.2.2
│   │ │ │ ├─┬ inflight@1.0.4
│   │ │ │ │ └── wrappy@1.0.1
│   │ │ │ ├── inherits@2.0.1
│   │ │ │ ├─┬ minimatch@1.0.0
│   │ │ │ │ ├── lru-cache@2.6.5
│   │ │ │ │ └── sigmund@1.0.1
│   │ │ │ └─┬ once@1.3.2
│   │ │ │   └── wrappy@1.0.1
│   │ │ ├── graceful-fs@3.0.8
│   │ │ ├── iconv-lite@0.4.11
│   │ │ ├── install@0.1.8
│   │ │ └─┬ mkdirp@0.5.1
│   │ │   └── minimist@0.0.8
│   │ ├─┬ defs@1.1.0
│   │ │ ├─┬ alter@0.2.0
│   │ │ │ └── stable@0.1.5
│   │ │ ├── ast-traverse@0.1.1
│   │ │ ├── breakable@1.0.0
│   │ │ ├── esprima-fb@8001.1001.0-dev-harmony-fb
│   │ │ ├── simple-fmt@0.1.0
│   │ │ ├── simple-is@0.2.0
│   │ │ ├── stringmap@0.2.2
│   │ │ ├── stringset@0.2.1
│   │ │ ├── tryor@0.1.2
│   │ │ └── yargs@1.3.3
│   │ ├── esprima-fb@15001.1.0-dev-harmony-fb
│   │ ├─┬ recast@0.10.24
│   │ │ └── ast-types@0.8.5
│   │ └── through@2.3.8
│   ├─┬ regexpu@1.2.0
│   │ ├─┬ recast@0.10.32
│   │ │ ├── ast-types@0.8.11
│   │ │ └── esprima-fb@15001.1001.0-dev-harmony-fb
│   │ ├── regenerate@1.2.1
│   │ ├── regjsgen@0.2.0
│   │ └─┬ regjsparser@0.1.5
│   │   └── jsesc@0.5.0
│   ├─┬ repeating@1.1.3
│   │ └─┬ is-finite@1.0.1
│   │   └── number-is-nan@1.0.0
│   ├── resolve@1.1.6
│   ├── shebang-regex@1.0.0
│   ├── slash@1.0.0
│   ├─┬ source-map@0.4.4
│   │ └── amdefine@1.0.0
│   ├─┬ source-map-support@0.2.10
│   │ └─┬ source-map@0.1.32
│   │   └── amdefine@1.0.0
│   ├── to-fast-properties@1.0.1
│   ├── trim-right@1.0.1
│   └── try-resolve@1.0.1
├─┬ grunt-cli@0.1.13
│ ├─┬ findup-sync@0.1.3
│ │ ├─┬ glob@3.2.11
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.3.0
│ │ │   ├── lru-cache@2.6.5
│ │ │   └── sigmund@1.0.1
│ │ └── lodash@2.4.2
│ ├─┬ nopt@1.0.10
│ │ └── abbrev@1.0.7
│ └── resolve@0.3.1
├── grunt-compare-size@0.4.0
├─┬ grunt-contrib-uglify@0.7.0
│ ├─┬ chalk@0.5.1
│ │ ├── ansi-styles@1.1.0
│ │ ├── escape-string-regexp@1.0.3
│ │ ├─┬ has-ansi@0.1.0
│ │ │ └── ansi-regex@0.2.1
│ │ ├─┬ strip-ansi@0.3.0
│ │ │ └── ansi-regex@0.2.1
│ │ └── supports-color@0.2.0
│ ├── lodash@2.4.2
│ ├─┬ maxmin@1.1.0
│ │ ├─┬ chalk@1.1.1
│ │ │ ├── ansi-styles@2.1.0
│ │ │ ├── escape-string-regexp@1.0.3
│ │ │ ├─┬ has-ansi@2.0.0
│ │ │ │ └── ansi-regex@2.0.0
│ │ │ ├─┬ strip-ansi@3.0.0
│ │ │ │ └── ansi-regex@2.0.0
│ │ │ └── supports-color@2.0.0
│ │ ├── figures@1.3.5
│ │ ├─┬ gzip-size@1.0.0
│ │ │ ├─┬ browserify-zlib@0.1.4
│ │ │ │ └── pako@0.2.7
│ │ │ └─┬ concat-stream@1.5.0
│ │ │   ├── inherits@2.0.1
│ │ │   ├─┬ readable-stream@2.0.2
│ │ │   │ ├── core-util-is@1.0.1
│ │ │   │ ├── isarray@0.0.1
│ │ │   │ ├── process-nextick-args@1.0.2
│ │ │   │ ├── string_decoder@0.10.31
│ │ │   │ └── util-deprecate@1.0.1
│ │ │   └── typedarray@0.0.6
│ │ └─┬ pretty-bytes@1.0.4
│ │   ├── get-stdin@4.0.1
│ │   └─┬ meow@3.3.0
│ │     ├─┬ camelcase-keys@1.0.0
│ │     │ ├── camelcase@1.2.1
│ │     │ └── map-obj@1.0.1
│ │     ├─┬ indent-string@1.2.2
│ │     │ └─┬ repeating@1.1.3
│ │     │   └─┬ is-finite@1.0.1
│ │     │     └── number-is-nan@1.0.0
│ │     ├── minimist@1.2.0
│ │     └── object-assign@3.0.0
│ ├─┬ uglify-js@2.4.24
│ │ ├── async@0.2.10
│ │ ├─┬ source-map@0.1.34
│ │ │ └── amdefine@1.0.0
│ │ ├── uglify-to-browserify@1.0.2
│ │ └─┬ yargs@3.5.4
│ │   ├── camelcase@1.2.1
│ │   ├── decamelize@1.0.0
│ │   ├── window-size@0.1.0
│ │   └── wordwrap@0.0.2
│ └── uri-path@0.0.2
├─┬ grunt-git-authors@2.0.1
│ └── spawnback@1.0.0
├─┬ grunt-npmcopy@0.1.0
│ ├─┬ glob@4.5.3
│ │ ├─┬ inflight@1.0.4
│ │ │ └── wrappy@1.0.1
│ │ ├── inherits@2.0.1
│ │ ├─┬ minimatch@2.0.10
│ │ │ └─┬ brace-expansion@1.1.0
│ │ │   ├── balanced-match@0.2.0
│ │ │   └── concat-map@0.0.1
│ │ └─┬ once@1.3.2
│ │   └── wrappy@1.0.1
│ └── lodash@2.4.2
├─┬ gzip-js@0.3.2
│ ├── crc32@0.2.2
│ └── deflate-js@0.2.3
├─┬ jsdom@3.1.2 extraneous
│ ├── acorn@0.11.0
│ ├─┬ acorn-globals@1.0.5
│ │ └── acorn@2.3.0
│ ├── browser-request@0.3.3
│ ├─┬ contextify@0.1.14
│ │ ├── bindings@1.2.1
│ │ └── nan@1.8.4
│ ├── cssom@0.3.0
│ ├── cssstyle@0.2.29
│ ├─┬ escodegen@1.6.1
│ │ ├── esprima@1.2.5
│ │ ├── estraverse@1.9.3
│ │ ├── esutils@1.1.6
│ │ ├─┬ optionator@0.5.0
│ │ │ ├── deep-is@0.1.3
│ │ │ ├── fast-levenshtein@1.0.7
│ │ │ ├── levn@0.2.5
│ │ │ ├── prelude-ls@1.1.2
│ │ │ ├── type-check@0.3.1
│ │ │ └── wordwrap@0.0.3
│ │ └─┬ source-map@0.1.43
│ │   └── amdefine@1.0.0
│ ├─┬ htmlparser2@3.8.3
│ │ ├── domelementtype@1.3.0
│ │ ├── domhandler@2.3.0
│ │ ├─┬ domutils@1.5.1
│ │ │ └─┬ dom-serializer@0.1.0
│ │ │   ├── domelementtype@1.1.3
│ │ │   └── entities@1.1.1
│ │ ├── entities@1.0.0
│ │ └─┬ readable-stream@1.1.13
│ │   ├── core-util-is@1.0.1
│ │   ├── inherits@2.0.1
│ │   ├── isarray@0.0.1
│ │   └── string_decoder@0.10.31
│ ├── nwmatcher@1.3.6
│ ├── parse5@1.5.0
│ ├─┬ request@2.61.0
│ │ ├── aws-sign2@0.5.0
│ │ ├─┬ bl@1.0.0
│ │ │ └─┬ readable-stream@2.0.2
│ │ │   ├── core-util-is@1.0.1
│ │ │   ├── inherits@2.0.1
│ │ │   ├── isarray@0.0.1
│ │ │   ├── process-nextick-args@1.0.2
│ │ │   ├── string_decoder@0.10.31
│ │ │   └── util-deprecate@1.0.1
│ │ ├── caseless@0.11.0
│ │ ├─┬ combined-stream@1.0.5
│ │ │ └── delayed-stream@1.0.0
│ │ ├── extend@3.0.0
│ │ ├── forever-agent@0.6.1
│ │ ├─┬ form-data@1.0.0-rc3
│ │ │ └── async@1.4.2
│ │ ├─┬ har-validator@1.8.0
│ │ │ ├── bluebird@2.9.34
│ │ │ ├─┬ chalk@1.1.1
│ │ │ │ ├── ansi-styles@2.1.0
│ │ │ │ ├── escape-string-regexp@1.0.3
│ │ │ │ ├─┬ has-ansi@2.0.0
│ │ │ │ │ └── ansi-regex@2.0.0
│ │ │ │ ├─┬ strip-ansi@3.0.0
│ │ │ │ │ └── ansi-regex@2.0.0
│ │ │ │ └── supports-color@2.0.0
│ │ │ ├─┬ commander@2.8.1
│ │ │ │ └── graceful-readlink@1.0.1
│ │ │ └─┬ is-my-json-valid@2.12.1
│ │ │   ├── generate-function@2.0.0
│ │ │   ├─┬ generate-object-property@1.2.0
│ │ │   │ └── is-property@1.0.2
│ │ │   ├── jsonpointer@1.1.0
│ │ │   └── xtend@4.0.0
│ │ ├─┬ hawk@3.1.0
│ │ │ ├── boom@2.8.0
│ │ │ ├── cryptiles@2.0.4
│ │ │ ├── hoek@2.14.0
│ │ │ └── sntp@1.0.9
│ │ ├─┬ http-signature@0.11.0
│ │ │ ├── asn1@0.1.11
│ │ │ ├── assert-plus@0.1.5
│ │ │ └── ctype@0.5.3
│ │ ├── isstream@0.1.2
│ │ ├── json-stringify-safe@5.0.1
│ │ ├─┬ mime-types@2.1.5
│ │ │ └── mime-db@1.17.0
│ │ ├── node-uuid@1.4.3
│ │ ├── oauth-sign@0.8.0
│ │ ├── qs@4.0.0
│ │ ├── stringstream@0.0.4
│ │ ├── tough-cookie@2.0.0
│ │ └── tunnel-agent@0.4.1
│ ├── xml-name-validator@1.0.0
│ └── xmlhttprequest@1.7.0
├─┬ load-grunt-tasks@1.0.0
│ ├─┬ findup-sync@0.1.3
│ │ ├─┬ glob@3.2.11
│ │ │ ├── inherits@2.0.1
│ │ │ └─┬ minimatch@0.3.0
│ │ │   ├── lru-cache@2.6.5
│ │ │   └── sigmund@1.0.1
│ │ └── lodash@2.4.2
│ └─┬ multimatch@1.0.1
│   ├── array-differ@1.0.0
│   ├─┬ array-union@1.0.1
│   │ └── array-uniq@1.0.2
│   └─┬ minimatch@1.0.0
│     ├── lru-cache@2.6.5
│     └── sigmund@1.0.1
├── native-promise-only@0.7.8-a
├── q@1.1.2
├── requirejs@2.1.17
├── sizzle@2.2.0
├── strip-json-comments@1.0.3
└── win-spawn@2.0.0

Maybe it can be trimmed a bit more, but that's still 239 unique
dependencies. But no jshint is needed (and for building, its usefulness
is void, so we could just remove the grunt-contrib-jshint package and
keep every other tests).

> You seem to be advocating sweeping this under the carpet, but by doing
> that you're advocating relying on non-DFSG, unpackaged tools for
> building main.

So, only unpackaged tools. Would it be a difference if we shipped a
post-processed un-minified JS. For example, for jQuery, that would be
this file:

 http://code.jquery.com/jquery-2.1.4.js

It's not the preferred form of modification for jQuery's contributors
but it enables any downstream to do any modification they deem necessary
with little efforts. It's even better than modifying a ./configure
because the difference with the original source code is far smaller.
-- 
Extreme fear can neither fight nor fly.
		-- William Shakespeare, "The Rape of Lucrece"

Attachment: signature.asc
Description: PGP signature


Reply to: