Skip to content
This repository was archived by the owner on Apr 13, 2025. It is now read-only.

Add doc entry about security considerations of nodecg-io #143

Merged
merged 4 commits into from
Jul 23, 2023

Conversation

hlxid
Copy link
Member

@hlxid hlxid commented Sep 20, 2022

Adds a documentation entry about our security considerations and tells users what and what not to expect from nodecg-io regarding handling of the entered configuration and credentials.

For codeoverflow-org/nodecg-io#424

@hlxid hlxid self-assigned this Sep 20, 2022

1. No service configuration is accessible to someone with only filesystem access.
- A exception to this is a nodecg-io install with automatic login as the password is stored in plain text.
2. No bundle will be able to access your plain text password.
Copy link
Member

Choose a reason for hiding this comment

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

This seems to contradict point 3. Did you mean not loaded bundle?

Copy link
Member Author

Choose a reason for hiding this comment

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

The plain text password is only stored inside the nodecg-io dashboard and not transmitted to the backend and never enters NodeCG.
While writing that I thought this would mean the password is safe but other bundles can obviously also have dashboards, can use window.parent to escape the iframe and then interact with the iframe of our dashboard. From there the password is readable using the HTML input element. So this is sadly not true anymore.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've tested it and sadly this works. I've updated this in 55acf4d.


## Implementation

1. The configuration is stored encrypted only in a NodeCG replicant. If someone reads the persistent value of the replicant from the filesystem the configuration cannot be read because it is encrypted using your chosen password.
Copy link
Member

Choose a reason for hiding this comment

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

Can we even provide the encryption method and key length?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, added in 57b5739

3. All loaded bundles may change nodecg-io settings like deleting instances
4. All loaded bundles may access all your configurations and passwords.
- It is highly recommended to only use bundles you trust!
5. Anyone intercepting network traffic between the NodeCG instance and browser with a logged in dashboard can access all configuration and passwords.
Copy link
Member

Choose a reason for hiding this comment

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

Also the usual attacks on the browser window and Keylogger will work. This is not surprising but may be added for comprehensiveness

Copy link
Member Author

Choose a reason for hiding this comment

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

Good suggestion! Added in 57b5739

1. The configuration is stored encrypted only in a NodeCG replicant. If someone reads the persistent value of the replicant from the filesystem the configuration cannot be read because it is encrypted using your chosen password.
2. When you enter your password inside the dashboard it is used to derive a encryption key using argon2id. Only this encryption key is ever transmitted and leaves the browser tab. Therefore other bundles can listen to the communication but it only contains the derived encryption key, not your plain text password.
3. Bundles can listen to the login message from the dashboard to get the encryption key. This can be used to send authenticate messages to the nodecg-io-core bundle to add/delete instances, change service instance assignments and do everything that is possible in the dashboard.
4. As mentionted in 3 all bundles can get the encryption key. The encrypted configuration is stored in a replicant which can be accessed by all bundles as well. Using these two any bundle could decrypt the configuration and have access to it.
Copy link
Member

Choose a reason for hiding this comment

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

All loaded bundles?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, all loaded bundles.
In NodeCG any bundle can listen for any message that is addressed for any other bundle. Meaning you can access all messages .
You can just listen for the login message like this:

nodecg.listenFor("login", "nodecg-io-core", (data) => {/* ... */});

The same goes for replicants, which can also be accessed by passing the bundle name in the constructor in any bundle.

We could use asymmetric encryption but again we cannot transmit the public key from the backend to the front end as any bundle could again listen for the same message or modify the replicant and provide its own public key to the dashboard that would use it to encrypt the key on transport.
I'm planning on implementing that anyways as we can try to detect tampering of other bundles which might not be perfect but better than nothing.

@hlxid hlxid requested a review from sebinside October 1, 2022 14:00
@hlxid hlxid marked this pull request as ready for review October 12, 2022 08:03
Copy link
Contributor

@TimTechDev TimTechDev left a comment

Choose a reason for hiding this comment

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

I would like you to make some minor grammatical and stylistic changes.

Co-authored-by: Tim <github@timtechdev.de>
@hlxid
Copy link
Member Author

hlxid commented Oct 12, 2022

Thank you very much @TimTechDev

@hlxid hlxid merged commit 1fc9009 into main Jul 23, 2023
@hlxid hlxid deleted the feat/security-considerations branch July 23, 2023 18:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants