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

VPN-5992 Allow extensions to request Access to the Proxy Network #9639

Merged
merged 13 commits into from
Jun 24, 2024

Conversation

strseb
Copy link
Collaborator

@strseb strseb commented Jun 5, 2024

This pull request introduces support for a new StateOnPartial state in the controller, enhancing the VPN's state management. It also adds an ActivationPrincipal enum to track whether a connection was initiated by a user or an extension, along with corresponding permission checks for deactivation. Additionally, this update includes several new methods and refines existing ones to handle the new state and activation principal, ensuring improved VPN control and security.

@strseb strseb changed the title Allow extensions to request Access to the Proxy Network Jun 5, 2024
@mcleinman
Copy link
Collaborator

Since @lesleyjanenorton has more context, I'm going to let her review this one. If you want a review from me as well, let me know - I'll take the time to read the docs for this project so I can do this PR justice.

Copy link
Member

@lesleyjanenorton lesleyjanenorton left a comment

Choose a reason for hiding this comment

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

Will keep going through this tomorrow but it is looking good! Just a few comments/Qs so far.

src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
src/controller.cpp Outdated Show resolved Hide resolved
src/inspector/inspectorhandler.cpp Outdated Show resolved Hide resolved
src/statusicon.cpp Show resolved Hide resolved
src/systemtraynotificationhandler.cpp Show resolved Hide resolved
Copy link
Member

@lesleyjanenorton lesleyjanenorton left a comment

Choose a reason for hiding this comment

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

R+ Left a few open questions but what we want to do with them is probably outside the scope of this PR.

src/controller.h Outdated Show resolved Hide resolved
@@ -19,7 +19,8 @@ MZButtonBase {

function handleClick() {
toolTip.close();
if (VPNController.state !== VPNController.StateOff) {
if (VPNController.state !== VPNController.StateOff &&
VPNController.state !== VPNController.StateOnPartial) {
Copy link
Member

Choose a reason for hiding this comment

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

One scenario I think we'll need to resolve but not in this PR...

  • We connect via the extension, we're in StateOnPartial...
  • We connect via the client, now we're in StateOn...
  • We deactivate from the client... we're in StateOff... but then that means Firefox is now also unprotected(?)

This is how it is supposed to work from the PRD but I'm guessing we'll get foxfooder feedback saying this is unexpected behavior so we might think about how to persist the extension vpn state through a deactivation in the client.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Given that the proxy api works on request basis, and we stream the state of the vpn we can simply request to re-enable the vpn to partial with the next request. Given we set a proxy in that case, the request would have a small delay.
Or we check before disconnecting if there is an active web-extension connection. however then we rely on the port continuesly beeing open.

@@ -122,6 +137,10 @@ QJsonObject WebExtensionAdapter::serializeStatus() {

{
Controller::State state = vpn->controller()->state();
if (state == Controller::StateOnPartial) {
state = Controller::StateOn; // Old extensions like MAC dont know and
// dont need to know about this state.
Copy link
Member

Choose a reason for hiding this comment

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

We can always update MAC to handle this if we for some reason need to

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Let's do that, we probably should start thinking about versioning the api too.

tests/functional/helper.js Outdated Show resolved Hide resolved
tests/functional/helper.js Show resolved Hide resolved
sock.destroy();
});

it('A Webextension can NOT deactivate the VPN if it was activated in Client',
Copy link
Member

Choose a reason for hiding this comment

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

Related to other comment: Eventually we will allow deactivating the vpn for Firefox in this situation right? This may be a terrible idea but I'm almost wondering if we'll want another state machine for the extension to make keeping track of situations like client is on but Firefox VPN is off a bit easier. Otherwise if we do allow the user to remove Firefox traffic from the tunnel when the vpn was activated from the client, but tell the extension that the VPN is 'on', how will the extension know that Firefox is excluded/"off"?

Copy link
Collaborator Author

@strseb strseb Jun 20, 2024

Choose a reason for hiding this comment

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

The Webextension state machine is going to be diffrent from the client.
If full device protection is enabled, the extension can use the localproxy to "exlude firefox"
If it's in partialOn we can just not use a proxy.

Thinking about this more, i think we might need to tell the extension actually if it is partially or full-device on.
But in no situation we need the extension to downgrade from full device protection :)

logger.debug() << "Deactivation" << m_state;
if (m_initiator > user) {
Copy link
Member

Choose a reason for hiding this comment

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

Eventually we want to embellish this to allow deactivating the VPN for Firefox from the extension in this situation though right?

Copy link
Collaborator Author

@strseb strseb Jun 20, 2024

Choose a reason for hiding this comment

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

probably not, given:
We cannot know that whatever is talking using the web-extension api really is firefox. could be a malicous actor.

We don't need to disable the vpn for firefox to not use the vpn connection see #9676

src/controller.cpp Show resolved Hide resolved
strseb and others added 5 commits June 20, 2024 21:33
Co-authored-by: Lesley Norton <lesley@mozilla.com>
Co-authored-by: Lesley Norton <lesley@mozilla.com>
@strseb strseb merged commit c34e159 into main Jun 24, 2024
119 checks passed
@strseb strseb deleted the basti/ext_act branch June 24, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants