-
Notifications
You must be signed in to change notification settings - Fork 32
fix: Relates to #124. Security #451
Conversation
5a06f97 to
944bd9d
Compare
|
Small conflict, can you resolve it @ltfschoen ? edit: Sorry, just realized it's not labelled as "pleasereview". |
|
Thanks for reviewing it so far, but I'm still reviewing security guides and would prefer to bundle all the changes in the same PR. I've added a checklist of bulletpoints and will try and address as much as possible in the implementation. If I can't implement a security recommendation I'll add a note in the checklist. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice, thanks Luke! This is crucial.
I have a couple of small comments, but overall it looks good to me
'unsafe-eval' is currently required for Fether to work
Only in dev (i.e. with yarn start). If there's a way to have different CSP by NODE_ENV, that'd be perfect.
Dev:
default-src 'none';
script-src http: 'unsafe-inline' 'unsafe-eval';
connect-src http: https: ws: wss:;
img-src 'self' 'unsafe-inline' file: data: blob: http: https:;
style-src 'unsafe-inline' blob: file:;
worker-src 'blob';
Prod:
default-src 'none';
script-src file: 'unsafe-inline';
connect-src http: https: ws: wss:;
img-src 'self' 'unsafe-inline' file: data: blob: http: https:;
style-src 'unsafe-inline' blob: file:;
worker-src 'blob';
(^ can possibly be even more strict, needs testing)
Preload Script to be used
No, we don't need preload scripts in Fether. Actually we do.
I think you may not have pulled the latest from my branch. In my latest commit |
Ah ok, that's possible. I'll have another look tomorrow in the morning 👍 |
|
@amaurymartiny I've pushed commits addressing your latest review comments. I've tested that it works on Linux (Debian 8) using We still need to test that it works on macOS and Windows |
amaury1093
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code lgtm!
When I was checking that it worked I create both a non-Parity Signer account plus imported...
This is expected. yarn start, yarn electron and the binary have each their own localStorage, so the signer accounts are not shared (unfortunately).
| '--ws-port', | ||
| cli.wsPort | ||
| cli.wsPort, | ||
| '--ws-origins', |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
| cli.wsPort | ||
| cli.wsPort, | ||
| '--ws-origins', | ||
| TRUSTED_WS_ORIGINS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can remove this. parity by default allows all origins in *.parity
amaury1093
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit (introduced recently), otherwise I'm okay to merge this 🎉 !
| "lint-files": "./scripts/lint-files.sh", | ||
| "lint": "yarn lint-files '**/*.js'", | ||
| "lint-files": "./scripts/lint-files.sh '**/*.js'", | ||
| "lint": "yarn lint-files", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change? This makes the pre-commit hook less performant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the change it was trying to lint the .ts files and the pre-commit hook was preventing me from pushing
|
Also, I just noticed this: can you remove the package-lock.json? |
|
Unfortunately i accidently left my laptop charger in the office so may not be able to address the removal of package-lock.json until Monday |
Tbaut
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
Let's merge it then! I'll test the generated binaries right after. Thanks Luke for this important PR. |
| version "5.1.1" | ||
| resolved "https://registry.yarnpkg.com/@parity/light.js/-/light.js-5.1.1.tgz#141f4c168f46208b1caa6273161ad9a8b1675862" | ||
| integrity sha512-AJ/klFpim+lKLxYKpIhJL9Btu4OuXs43lfbBK8XA0kXOV6M51vCv5n+sO5oTWVx6IJE3lXuDIc674H9BC4fcvQ== | ||
| version "5.1.3" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AH I didn't see this, I merged too fast... @parity/* should NOT have been updated, with this update we cannot send a tx. I'll add a patch asap

'unsafe-eval'is currently required for Fether to workhttps:in CSPnodeIntegration, expose custom APIs to the later loaded website that consume Node.js modules or features using a preload scripts, since the preload script has access Node.js features likerequire, but then the website only has access to methods attached to thewindowobject, but no Node.js features.contextIsolationin any renderer (i.e. BrowserWindow, BrowserView, or ) that loads remote content to limit power granted. Grant additional permissions for specific hosts (i.e. give websites we are opening such asexample.com/usingBrowserWindowonly the power it needs.nodeIntegration: trueorcontextIsolation: falsenew BrowserWindowcontextIsolationto to need foripcRendererrequirebeing available in Chrome Dev Tools ConsolesetPermissionRequestHandlerwebSecurity: trueis set) - Action taken: explicitly enabledContent-Security-Policymetatag in fether-react/public/index.htmlallowRunningInsecureContent: true- Action taken: explicitly disabledexperimentalFeatures: true- Action taken: explicitly disabledenableBlinkFeatures- Action taken: explicitly disabledallowpopups- Action taken: not usedopenExternalwith untrusted contentFix all
// FIXMEcomments in this PR. UPDATE: As many as necessary to merge the PR.Misc
Update this summary incorporating changes since merging PR from amaurymartiny. amaurymartiny clarified that whilst we've got
sandbox: truein the config the reasons why we've removed--enable-sandboxfrom package.json (which is supposed to sandbox all BrowserWindow instances) is because:We will only have that one BrowserWindow (or should restrict to only have one)
The script where
--enable-sandboxwas included in package.json was foryarn electron, which is also mainly used in dev. The final binary won't have--enable-sandbox. Fether passes down--...flags to parity-ethereum (see https://github.com/paritytech/fether#passing-config-flags-to-the-underlying-parity-ethereum-node). So when run, it is as if we ranparity-ethereum --enable-sandbox --some-other-flags, which crashed parity-ethereumAll in all, it might be easier to put sandbox: true, and limit to 1 BrowserWindow.
We must ensure only 1 BrowserWindow is allowed.
Fix preload.js. See amaurymartiny's issue below
Update WS interface and port based on comments here fix: Relates to #124. Security #451 (comment)
Fix isDev approach by using
appIsPackagedto determine current environment, as highlighted by Amaury and Axel. See fix: Relates to #124. Security #451 (comment)Future - investigate https://hackmd.io/O1FA34BuSNyJoPV1Cu3L0A
Add removal of
wsInterfacefix: Relates to #124. Security #451 (comment) to the release notes