Repository navigation
Conversation
MarshallOfSound
left a comment
There was a problem hiding this comment.
Good initial change, I like that the diff is minimal
|
|
||
| When no handler is set using `session.setPermissionRequestHandler()`, it behaves as if `callback(false)` was called. | ||
|
|
||
| This method can only be called before app is ready. |
There was a problem hiding this comment.
This will involve a race condition, is there any technical reason why this is the case. I would imagine it doesn't matter when this is called?
There was a problem hiding this comment.
it probably does not matter, but it seems more future-proof to make this limitation? it should be enabled before any windows are created.
There was a problem hiding this comment.
Let's make that the restriction then instead of before app ready. Enforce that it must be called before any webcontents are made.
There was a problem hiding this comment.
my concern is that people are used to the limitation that APIs must / cannot be called before / after app.isReady. do we have any API which can only be used before webcontents are created?
There was a problem hiding this comment.
Dumb question, would it make sense to make this a webPreferences argument instead? That would prevent the race condition and also resolve the question of when the API call was allowed.
There was a problem hiding this comment.
btw where is the race condition?
There was a problem hiding this comment.
@miniak It is very easy to delay a task (run something after an event)
There is no easy way to guarantee to do something before an event.
If there is not a technical limitation here, I would suggest we tie this to the actual thing we care about not some other arbitrary event.
There was a problem hiding this comment.
Ok, I will change the condition. Is checking if there are 0 webcontents instances alive at the time the API is called good enough check?
There was a problem hiding this comment.
webContents().getAll().length === 0 sounds like it will suffice for the actual condition you are trying to enforce here. (That this API is called before any windows / web contents are made)
There was a problem hiding this comment.
@MarshallOfSound I've implemented the check in native code, can you check that? if you don't like the approach, I can do it in JS instead
917105a to
7b73779
Compare
|
@MarshallOfSound should I mark it |
f2cbd00 to
106aa5d
Compare
|
@MarshallOfSound I've added |
f982023 to
1b5053d
Compare
|
|
||
| When no handler is set using `session.setPermissionRequestHandler()`, it behaves as if `callback(false)` was called. | ||
|
|
||
| This method can only be called before app is ready. |
There was a problem hiding this comment.
Dumb question, would it make sense to make this a webPreferences argument instead? That would prevent the race condition and also resolve the question of when the API call was allowed.
8f5b266 to
5bdef48
Compare
| #endif | ||
| SetDefaultBoolIfUndefined(options::kOffscreen, false); | ||
|
|
||
| if (Browser::Get()->secure_mode_enabled()) { |
There was a problem hiding this comment.
This might have gotten lost in the original comment but I meant that we should always do the SetDefaultBoolIfUndefined calls for the normal defaults. And if secure_mode_enabled() then override the values regardless of whether they are undefined. E.g.
SetBoolIfUndefined(optionA, true);
if (is_secure_mode) {
SetBool(optionA, false);
}Then we can remove the if (!secure_mode_enabled && IsEnabled(options::kNodeIntegration)) style code below (we won't need to check secure_mode_enabled)
There was a problem hiding this comment.
some options need to stay overridable. I only want to kill nodeIntegration and nodeIntegrationInWorker as those are not necessary to keep functionality as you can use preload script instead.
There was a problem hiding this comment.
or maybe it should be configurable, which options are going to be disabled completely.
There was a problem hiding this comment.
something like?
interface OverridableOptions {
sandbox?: boolean;
contextIsolation?: boolean;
nativeWindowOpen?: boolean;
enableRemoteModule?: boolean;
nodeIntegration?: boolean;
nodeIntegrationInWorker?: boolean;
}
app.enableSecureMode(overridableOptions: OverridableOptions): void;There was a problem hiding this comment.
options will always default to the more secure value and will only be overridable if specified in this list
There was a problem hiding this comment.
e.g.
app.enableSecureMode({
contextIsolation: true // allow disabling contextIsolation
});There was a problem hiding this comment.
or some other variant of this, to make the API as least confusing as possible
There was a problem hiding this comment.
some options need to stay overridable.
I disagree, if the options can be overridable then any of the previous vulns we've had where people have been able to set nodeIntegration: true (somehow) would still work making this option not very helpful.
I think this option should give no options and violently enforce the security guidelines (disable node, enable isolation, reject permission requests if not already handled, etc..)
That's just IMO though, would like some weigh in from @electron/wg-security
There was a problem hiding this comment.
Unfortunately, contextIsolation for example is not an option for us for now (we'll need to do a lot of refactoring to get there). We need it to be optionally overridable. The default can be that nothing is overridable and you have to opt-in explicitly into being able to override some options.
5263bc3 to
e537a89
Compare
a8d8f10 to
70eb367
Compare
486ebaf to
256fe3e
Compare
29daf8d to
6b6c80a
Compare
6b6c80a to
4285156
Compare
|
Closing this due to discussion in @electron/wg-security meeting. This should be implemented as granular, descriptive APIs, not as one "secure mode" flag. |
Description of Change
This is an opt-in locked down mode designed for apps loading remote content.
Check docs/api/secure-mode.md for details.
Checklist
npm testpassesRelease Notes
Notes: Added
app.enableSecureMode()API to opt-in into more secure mode designed for apps running remote content./cc @electron/wg-security