I'm writing an app using Electron but I'd assume this would be a problem for any software that lets you open links in the user's default browser through the OS.
Let's say I have app that reads something like a twitter feed and displays it. So the app displays 10 entries. Some of those entries have user supplied links. If the user clicks a link I want to launch it in the user's default browser.
In Electron I'm told I should call electron.shell.openExternal(url)
. Do I need to be filtering URLs? Common URLs are for example http://xxx
, https://xxx
, mailto:xxx
so I could just whitelist those 3 types of URLs. At the same time I don't want to wrongly limit good functionality. In other words I have no idea what other valid schemas there are. Allow ftp://
? sftp://
? gopher://
? So I'd prefer to just pass everything through.
At the same time I'm worried, are there are potentially bad URLs? Hypothetical example: 3rdpartyAppWithScriptingHandler://evil.script
Should I whitelist? Blacklist? Filter? If so what's the filter? Or should I just pass them to OS?