Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-enable CSP via whitelist #1662

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Re-enable CSP via whitelist #1662

wants to merge 2 commits into from

Conversation

rauenzi
Copy link
Member

@rauenzi rauenzi commented Aug 29, 2023

This will re-enable the Discord CSP but whitelist all currently known used remote resources. This would finally fix #442

I personally think that we should strongly encourage themes to move off of some of these more sketchy and less reputable domains and onto others, then remove them from this list before approving.

@9o3
Copy link

9o3 commented Sep 8, 2023

A PR for improving security! That's great! I think we should all strive to improve security as much as possible.

I would like to add some things that warrants serious consideration:
CSP defines a security boundary of domains whose content you trust to be safe.
There is no reasonable belief that code hosted on GitHub is safe. Implementing CSP is unfortunately not going to improve the security of BetterDiscord, as BetterDiscord inherently needs to "trust" code from these type of untrusted sourced.

These CSP rules would not stop a malicious actor, but would only limit the freedom that BetterDiscord gives. Thereby increasing the barrier of entry for future development that may need to rely on resources on a domain that is not included in this whitelist.

Feel free to hit me up if you want to discuss possible alternatives, but I think that's a different topic for a different time :)

const whitelist = {
// Discord includes unsafe-inline already
script: [
"https://*.github.io",
Copy link
Member

@Inve1951 Inve1951 Sep 24, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think *.github.io can be removed. If some plugin still relies on it, it shall break.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed

// Discord includes unsafe-inline already
script: [
"https://*.github.io",
"https://cdnjs.cloudflare.com" // Used for Monaco
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of hosting Monaco on betterdiscord.app instead?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Open to tossing around the idea, but with our site issues over the last several months I'm hesitant.

if (!this.hasUpdate || !showNotice) return;
try {
const buffer = await new Promise((resolve, reject) => {
request({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure about using request?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No this will definitely be updated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improper Electron Security Practices (CSP)
3 participants