7 ms·
Does anyone else see the import directly from URL as a larger security/reliability issue than the currently imperfect modules? I'm sure I'm missing something o
by pedalpete 6y ago
Does anyone else see the import directly from URL as a larger security/reliability issue than the currently imperfect modules?
I'm sure I'm missing something obvious in that example, but that capability terrifies me.
- mrkurt 6y agoIt's basically the same "exposure" as importing a random npm, but it has the benefit if being explicit when you do it. It's also exactly what the websites you visit do. ;)
- xg15 6y ago> It's basically the same "exposure" as importing a random npm, but it has the benefit if being explicit when you do it. I'm not sure how this works in detail here, but at least in NPM you got a chance to download packages, inspect them and fix the versions if so desired. Importantly, this gave you control over your transitive dependencies as well. This seems more like the curl | bash school of package management. Edit: This is explained in more detail at https://deno.land/manual/linking_to_external_code https://deno.land/manual/linking_to_external_code and indeed seems a lot more sane. > It's also exactly what the websites you visit do. ;) Well yes, and it causes huge problems there already - see the whole mess we have with trackers and page bloat.
- mrkurt 6y agoThe tldr is Deno also gives you a chance to download + inspect packages, and then lock dependencies. The mechanism for import is different, but the tooling is good.
- thysultan 6y agoThe good thing about this is you can effectively build a register service that serves the same level of trust that npm provides, because at the end of the day that is the only deferential in this scenario as npm can just as well return malicious code.
- pedalpete 6y agoThanks for sharing that link. Seems much more sane, but not without issues. I'm sure this will continue to be iterated upon. Even with all NPMs flaws, I do feel this is a bit of throwing the baby out with the bath water. Time will tell.
- greggman3 6y agoAFAIK there is no option to allow a website to read and write random files anywhere to my hard drive period. At most a website can ask the user select a file or offer one for downloading. In the future maybe it can be given a domain specific folder. That's not true here. If I'm running a web server I'm going to need to give the app permission to read the files being served and access to the database. That something that never happens in the browser.
- eyelidlessness 6y ago> It's basically the same "exposure" as importing a random npm, but it has the benefit if being explicit when you do it. This is definitely false. For all the problems with the NPM registry and the Node dependency situation, an NPM package at a specific version is not just at the whims of whatever happens to be at the other end of a URL at any given moment it's requested. This is a huge vulnerability that the Node/NPM world does not currently have.
- mrkurt 6y agoThat is a fair point. I don't think most people who use npms really pay much attention, though, and you're still just an npm update away from getting something unexpected (because really, who puts explicit versions in package.json?). Deno does have lockfiles: https://deno.land/manual/linking_to_external_code/integrity_checking https://deno.land/manual/linking_to_external_code/integrity_... I prefer imports from URLs. And I loathe npm. I get why people would disagree though.
- megavolcano 6y agoDeno has lock files and caches files locally on first import.
- pedalpete 6y agoyeah, but we regularly clear out our cache and lock files, so this doesn't really solve the issue, unless you're commiting all of your packages
- mrkurt 6y agoWhat! Clearing lock files seems wild. How do you know you're getting the right code when you install dependencies?
- megavolcano 6y agoWhy are you _regularly_ clearing lock files? If you're bypassing lock files you're going to have the exact same issue with npm or yarn or any other package manager that downloads from the internet.
- frank2 6y agoDoes it also terrify you when code running in a browser does it?
- Saaster 6y agoThe code running in my browser isn't a multi-tenant production server, with access to the filesystem and DBs.
- yawn 6y agoFrom the article: "Also like browsers, code is executed in a secure sandbox by default. Scripts cannot access the hard drive, open network connections, or make any other potentially malicious actions without permission."
- hombre_fatal 6y agoThat just means you have to run with the -http -fs, etc. flags. But you are using those when writing any nontrivial Deno app like a webserver anyways. "web browsers already do this ;)" isn't a good comparison.
- mrkurt 6y ago"But I have to turn all that stuff on" is also not a good comparison. Actually, no Deno webserver I've written gets fs access. Some only get --allow-net.
- XCSme 6y agoI think that's the main selling point of deno, sandboxing.
- 0beah 6y agoExcept that with Deno, everything IO related is turned off by default and has to be granted access before it becomes a process. It's the first bullet point on the landing page. Here is the page with more detail. https://deno.land/manual/getting_started/permissions https://deno.land/manual/getting_started/permissions It can even restrict access down to a specific directory or host. This is cool. Whereas any NPM module can map your subnet, lift your .ssh directory, and yoink environment variables, wily-nily. It's happened before.
- Saaster 6y agoDoes Deno have some built in way to vendor / download the imports pre-execution? I don't want my production service to fail to launch because some random repo is offline.
- doctoboggan 6y agoI assume you would just download the packages and serve them yourself.
- afiori 6y agoDeno caches local copies and offer control on when to reload them. in term of vendoring you can simply download everything yourself and use local paths for imports.
- xg15 6y agoHow would this work with transitive dependencies? Sure I can control which parts I import myself, but how do I keep a vendored file from pulling in another URL a level deeper?
- thebradbain 6y agoUnlike node, recommended deno practice is to check-in your dependencies to the VCS. > Production software should always bundle its dependencies. In Deno this is done by checking the $DENO_DIR into your source control system, and specifying that path as the $DENO_DIR environmental variable at runtime. https://deno.land/manual/linking_to_external_code https://deno.land/manual/linking_to_external_code
- Rotareti 6y agodu -hs node_modules 1.7G node_modules
- deleted 6y ago[deleted]
- tvbusy 6y agodeno requires that you give the process explicitly which permissions it has. I think it's much better than praying that a package has not gone rough like with node. If you don't trust the remote script, run it without any permission and capture the output. Using multiple process with explicit permissions are much safer.
- dceddia 6y agoI'm wondering about the practicality of importing from URLs. I didn't see it addressed, but an import like this will be awfully hard to remember. import { serve } from "https://deno.land/std@0.50.0/http/server.ts"; Anyone know if there are alternatives or a plan for this aside from "use an IDE to remember it for you"?
- mrkurt 6y agoThe convention is to make a `deps.ts` and re-export what you need. Like this: https://deno.land/x/collections/deps.ts https://deno.land/x/collections/deps.ts I don't find versioned URLs much more difficult to work with than package@<version> though.
- uryga 6y agoi'm wondering if they'll end up adding a 'dependencies.json' to eliminate the boilerplate from 'deps.ts' and to simplify tooling. that'd be revolutionary! ;) jokes aside, i wonder how import-via-url will impact tooling. having to parse arbitrary JS (or even run it, for dynamic imports?) seems like it'd make writing a "list all dependencies" tool much harder than a "dumb" JSON/TOML/whatever file would. though i guess Go does a similar thing, and afaik they're fine
- mrkurt 6y agoWell they do have import maps! I think everyone likes shorthand package names.
- Roboprog 6y agoSure do. I wonder if they have a checksum mechanism like browsers do? You can add an “integrity” attribute to script tags in the browser. https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity https://developer.mozilla.org/en-US/docs/Web/Security/Subres...
- bgdam 6y agoIt's not just about the integrity. The url may very well provide what they claim to provide, so checksums would match, but it's the direct downloading and running of remote code that is terrifying. This is pretty much like all the bash one-liners piping and executing a curl/wget download. I understand there are sandbox restrictions, but are the restrictions on a per dependency level, or on a program level? If they are on a program level, they are essentially useless, since the first thing I'm going to do is break out of the sandbox to let my program do whatever it needs to do (read fs/network etc.). If it is on a per dependency level, then am I really expected to manage sandbox permissions for all of my projects dependencies?
- batmansmk 6y agoIf you afraid of "direct" downloading and executing some of that code, then what do you think happen when you npm install/pip install a package? I'm very interested if you can expose a new attack vector that didn't exist with the previous solutions.
- mirekrusin 6y agoYou can generate modules on the fly on the server, that require next generated module recursively blowing up your disk space. If deno stores those files uncompressed, you can generate module full of comments/zeros so it compresses very well for attacker and eats a lot of space on consumer side.
- james-mcelwain 6y agoOne advantage of urls is that you can link to a specific git sha, tag, or branch for a dependency, e.g. on github.
- batmansmk 6y agoI thought a lot about it, and it seems as secure as node_modules, because anybody can publish to npm anyway. You can even depend to your non-npm repo (github, urls...) from a npm-based package. If you want to "feel" as safe, you have import maps in deno, which works like package.json. Overall, I think Deno is more secure because it cuts the man in the middle (npm) and you can make a npm mirror with low effort, a simple fork will do. Which means you can not only precisely pin which code you want, but also make sure nobody knows you use those packages either. Take it with an open mind, a new "JSX" or async programming moment. People will hate it, then will start to see the value of this design down the road.
- ryanbrunner 6y agoOne advantage of having a centralized repository is that the maintainers of that repository have the ability to remove genuinely malicious changes (even if it's at the expense of breaking builds). Eliminating the middle man isn't always a great thing when one of the people on the end is acting maliciously.
- mhink 6y agoI'm just thinking out loud here, but it seems to me that you could just make sure you're importing all your dependencies from trusted package repos, right? And since the URL for a package is right there in the `import` statement, it seems like it'd be pretty easy to lint for untrusted imports. I don't detest NPM in the way that some people do, but I have always worried about the implications of the fact that nearly the entire community relies on their registry. If they ever fell over completely, they would have hamstrung a huge amount of the JS community.
- pimterry 6y ago> I thought a lot about it, and it seems as secure as node_modules, because anybody can publish to npm anyway npm installs aren't the same as installing from a random URL, because: * NPM (the org) guarantees that published versions of packages are immutable, and will never change in future. This is definitely not true for a random URL. * NPM (the tool) stores a hash of the package in your package-lock.json, and installing via `npm ci` (which enforces the lockfile and never updates it in any case) guarantees that the package you get matches that hash. Downloading from a random URL can return anything, at the whims of the owner, or anybody else who can successfully mitm your traffic. Installing a package via npm is the same only the very first time you ever install it. Once you've done that, and you're happy that the version you're using is safe, you have clear guarantees on future behaviour.
- austincheney 6y agoHow is it any different than how it works in the browser?
- jppope 6y agoMore than likely programming as a whole will get better because of this... Do you trust this thing? Better off developing it yourself, or working with something you trust then.
- ecares 6y agoespacially since https is not enforced! https://github.com/denoland/deno/issues/1063 https://github.com/denoland/deno/issues/1063
- speedgoose 6y agoYou are not alone, this is very unsafe in my humble opinion.