signal-desktop/js/modules
Disconnect3d fa4b2d412f Fix SUPPORTED_MEDIA_DOMAINS regex whitelist (#3459)
The `SUPPORTED_MEDIA_DOMAINS` regex whitelist, used to check if media link comes from trusted hosts is invalid. It does not expose a security risk or I couldn't find an example for such as of now, but if someone would add a subdomain host to it using the same pattern, it would.

A counter example below:
```js
const SUPPORTED_MEDIA_DOMAINS = /^([^.]+\.)*(ytimg.com|cdninstagram.com|redd.it|imgur.com|fbcdn.net|pinimg.com)$/i;

console.log('Testing redd.it: ' + SUPPORTED_MEDIA_DOMAINS.test('redd.it'));
console.log('Testing reddjit: ' + SUPPORTED_MEDIA_DOMAINS.test('reddjit'));
```

Output:
```
$ node example.js
Testing redd.it: true
Testing reddjit: true
```

---

To be more clear, if someone would extend the regex in the future with e.g. `media.redd.it`, an attacker would be able to create a `mediaXredd.it` domain and bypass the whitelist.

---

A visualisation of the incorrect regex can be found on https://regexper.com/#%5E%28%5B%5E.%5D%2B%5C.%29*%28ytimg.com%7Ccdninstagram.com%7Credd.it%7Cimgur.com%7Cfbcdn.net%7Cpinimg.com%29%24

The issue has been found with LGTM: b626ef0b64/files/js/modules/link_previews.js (xdabadfc2bf20f0c3):1
2019-07-16 13:28:16 -07:00
..
metadata Ensure that we capture sender even if thrown error is falsey 2019-02-13 16:04:58 -08:00
migrations Move all remaining stores to SQLCipher 2018-10-31 17:36:51 -07:00
types Stickers 2019-05-16 16:10:37 -07:00
views Show and log progress during the SQLCipher migration 2018-08-02 17:25:51 -07:00
.eslintrc Auto-fixes: UX Improvements (#2077) 2018-03-02 15:54:15 -05:00
attachment_downloads.js Ensure only one active attachment download setTimeout 2019-06-24 13:39:37 -07:00
auto_orient_image.js Format all source code using Prettier 2018-04-30 16:53:34 -04:00
backup.js Debug log optimizations and improvements 2019-02-20 16:51:30 -08:00
crypto.js Stickers 2019-05-16 16:10:37 -07:00
data.d.ts Support additional sticker states 2019-05-29 11:01:32 -07:00
data.js Support additional sticker states 2019-05-29 11:01:32 -07:00
database.js Format all source code using Prettier 2018-04-30 16:53:34 -04:00
debug.js Move conversations to SQLCipher 2018-10-01 18:18:37 -07:00
debuglogs.js Add some logging for debug log upload 2019-05-28 17:24:28 -07:00
deferred_to_promise.d.ts Let's make it all pretty, shall we? 2018-05-02 13:40:57 -07:00
deferred_to_promise.js Extract deferredToPromise 2018-04-02 12:17:36 -04:00
emojis.js Maintain last-known cursor position for inserting emojis 2019-05-30 16:37:28 -07:00
i18n.js Use window.log in browser context, turn on console eslint rule 2018-07-21 14:52:43 -07:00
idle_detector.js Use window.log in browser context, turn on console eslint rule 2018-07-21 14:52:43 -07:00
indexeddb.js Migrate from IndexedDB before doing new version checks 2019-06-27 15:21:08 -07:00
link_previews.d.ts Improve handling for URLs composed of mixed character sets 2019-03-12 17:44:14 -07:00
link_previews.js Fix SUPPORTED_MEDIA_DOMAINS regex whitelist (#3459) 2019-07-16 13:28:16 -07:00
logs.js Refactor: db tasks to database.js, log delete to modules/logs.js 2018-03-14 14:42:15 -07:00
messages_data_migrator.js Move conversations to SQLCipher 2018-10-01 18:18:37 -07:00
migrate_to_sql.js Remove groups table, conversation is single source of truth 2019-02-13 16:04:58 -08:00
privacy.js Remove newlines from group IDs 2018-05-03 13:24:39 -04:00
refresh_sender_certificate.js Fix reference to nonexistent variable 2018-11-14 15:25:03 -08:00
settings.js Show and log progress during the SQLCipher migration 2018-08-02 17:25:51 -07:00
signal.js Only preload emoji after the window is fully loaded 2019-06-20 17:48:54 -07:00
sleep.js Format all source code using Prettier 2018-04-30 16:53:34 -04:00
stickers.d.ts Support additional sticker states 2019-05-29 11:01:32 -07:00
stickers.js Only use attemptedStatus on re-download if it is 'installed' 2019-05-30 12:43:18 -07:00
string_to_array_buffer.js Format all source code using Prettier 2018-04-30 16:53:34 -04:00
web_api.js Stickers 2019-05-16 16:10:37 -07:00