Live data from Hacker News

window.showDirectoryPicker opens up a whole new world

steveharrison.dev

31–40 of 122 posts

Re: window.showDirectoryPicker opens up a whole new world

#31

Currently using this in socket2.me Not truly supported across all mobile browser currently, but it's certainly better than just one year ago.

https://caniuse.com/mdn-api_window_showdirectorypicker * Global 75.2% Mainly missing Safari and Firefox

You say “mainly missing Safari and Firefox”, but the better way to look at it is “only Chromium”. There is only one implementation, and the other two major implementers have explicitly rejected it. And we don’t standardise things without at least two implementations.

Re: window.showDirectoryPicker opens up a whole new world

#32
post #7
post #6

Earlier quoted context omitted.

Firefox may not be the best browser, but it's the last full-featured non-commercial independent browser still available (excluding forks like Waterfox). If we want a free and open internet, we need to protect Firefox at all costs.

Please don't give trolls attention. Just downvote & move on.

But it's fun

Re: window.showDirectoryPicker opens up a whole new world

#33

I wish we had this in the operating system. It would solve an immense number of risks such as data deletion from bugs and even ransomware.

MacOS has this and what happens is that you get into the habit of just clicking through it. It won't help with ransomware, only backups would.

Re: window.showDirectoryPicker opens up a whole new world

#34
post #9

First time I've heard about this. I'll have to look into the security model around it. I'm curious what safeguards are in place to prevent click jacking. I know showing a file picker """should""" be enough of a warning to users to be careful, but it's not hard to imagine a world where a couple of fish accidentally bite the bait of an allow-button, or because they followed instructions they incorrectly trusted.

Looks like these safeguards are in place: * System and root directories cannot be selected. * Can only being activated after user action. * Requires https. * Double-confirmation for write access. No API like this could ever be bulletproof, but it's a start I guess. Very cool API though, and it really does open up a whole new world of possibilities.

> System and root directories cannot be selected.

That desperately needs something like the Public Suffix List [1] - a community-managed list where authors of software can blacklist directories containing sensitive files or such files directly for all browsers implementing this feature.

If I were to design such a list, it would include ~/.ssh, ~/.aws, ~/.config, ~/Library, ~/.{ba,z}sh{rc,_profile,_history}, ~/.m2, ~/.npm, ~/.npmrc, ~/.profile at the very least. Because users will get phished.

[1] https://en.wikipedia.org/wiki/Public_Suffix_List

Re: window.showDirectoryPicker opens up a whole new world

#35
post #28

So websites can now nag users to allow access to the root of their local disk and then read all their files and settings, all their SSH keys and other passwords? From what I gather from the docs [1], this API gives you a FileSystemDirectoryHandle object, and then you just call getDirectoryHandle() on that to recursively read the the entire filesystem. The spec [2] has some vague suggestions about blacklisting certain…

> So websites can now nag users to allow access to the root of their local disk

No, Chrome doesn't allow this.

Here's a simple demo: https://output.jsbin.com/kekekac/quiet - note that you can't select root, Downloads etc.

Re: window.showDirectoryPicker opens up a whole new world

#36
post #29

Earlier quoted context omitted.

Looks like these safeguards are in place: * System and root directories cannot be selected. * Can only being activated after user action. * Requires https. * Double-confirmation for write access. No API like this could ever be bulletproof, but it's a start I guess. Very cool API though, and it really does open up a whole new world of possibilities.

Those are some pretty flimsy safeguards. I don't keep my secrets in system directories and using HTTPS doesn't mean the site isn't malicious.

> I don't keep my secrets in system directories

Root of the home directory is also excluded.

But obviously yeah, nothing's going to prevent you from giving a website access to your .ssh directory if you explicitly select it.

Personally I don't have a problem with that. The ability to upload files has been a thing on the web for forever and I don't think there's ever been anything that stopped users from uploading their private key. Possibly some users have gotten phished that way, but at a certain point you have to accept responsibility for your own actions, otherwise you start ceding control of your life to a corporate nanny state.

Re: window.showDirectoryPicker opens up a whole new world

#37
post #12

> Chrome introduced a new API, window.showDirectoryPicker() that allows the user to grant access to a directory on their computer and allow a website to read/write everything inside. I mean, what could go wrong? It's not like an user is tricked into uploading a file from a folder (let's say, the main "Documents" folder) and some malicious website steals all the files over there.

If you tried this out in Linux, for example, the system would block you from selecting folders that contain files that are flagged as dangerous or "system files". I'm assuming this was implemented across all OSes.

That does not sound at all reassuring, that the only safeguard is the system blocking access and that the API has no safeguard.

Its also easily possible to have sensitive files misplaced, especially for a general non-technical user that would be the one falling for a browser hijacking attack

Re: window.showDirectoryPicker opens up a whole new world

#38
post #5

But webkitdirectory="true" could already do that, no?

No, they're very different. Using webkitdirectory="true" on an element just allows you to select a directory to e.g. upload it to the server. It's a one-time operation.

This API returns a handle to the selected directory, giving the webpage ongoing read/write access to the directory.

You couldn't use the former to e.g. create a local-first notes app that stores its files on disk.

Re: window.showDirectoryPicker opens up a whole new world

#39

I wish we had this in the operating system. It would solve an immense number of risks such as data deletion from bugs and even ransomware.

Which operating system do you mean? Flatpak has this already, Android enforces this kind of API for shared files, Windows UWP has pretty much the exact same API (https://learn.microsoft.com/en-us/uwp/api/windows.storage.pi...).

App developers will often choose not to sandbox their applications because it's a lot easier (and sometimes faster) do to all file management yourself, but the APIs are there and ready to be used.

Post reply on HN