Skip to content

feat(gateway): revoke unlisted authorizations upon init#9896

Merged
thomaseizinger merged 5 commits into
mainfrom
feat/gw-discard-unauthorized-flows
Jul 17, 2025
Merged

feat(gateway): revoke unlisted authorizations upon init#9896
thomaseizinger merged 5 commits into
mainfrom
feat/gw-discard-unauthorized-flows

Conversation

@thomaseizinger

Copy link
Copy Markdown
Member

When receiving an init message from the portal, we will now revoke all authorizations not listed in the authorizations list of the init message.

We (partly) test this by introducing a new transition in our proptests that de-authorizes a certain resource whilst the Gateway is simulated to be partitioned. It is difficult to test that we cannot make a connection once that has happened because we would have to simulate a malicious client that knows about resources / connections or ignores the "remove resource" message.

Testing this is deferred to a dedicated task. We do test that we hit the code path of revoking the resource authorization and because the other resources keep working, we also test that we are at least not revoking the wrong ones.

Resolves: #9892

@thomaseizinger
thomaseizinger requested a review from jamilbk July 17, 2025 12:21
@vercel

vercel Bot commented Jul 17, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 17, 2025 0:48am

@thomaseizinger
thomaseizinger enabled auto-merge July 17, 2025 12:21
.resources
.extract_if(|resource, _| !authorization.contains(resource))
{
tracing::info!(%resource, "Revoking resource authorization");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
tracing::info!(%resource, "Revoking resource authorization");
tracing::debug!(%resource, "Revoking resource authorization");

This could be quite noisy (thousands of messages) if the Gateway hasn't connected in a while, or connects after a major access change such as an IdP deletion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it is still a major state change of the system so INFO seems to be justified.

/// In this case, we won't receive a `relays_presence` but instead we will receive relays with the same ID yet different credentials.
RebootRelaysWhilePartitioned(BTreeMap<RelayId, Host<u64>>),

/// De-authorize access to a resource whilst the Gateway is network-partitioned from the portal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Out of curiosity, what does this test? That we respect the expiration timestamp of an authorization even while partitioned?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Did you read the PR description? I tried to explain there what do test and what we don't test:

We (partly) test this by introducing a new transition in our proptests that de-authorizes a certain resource whilst the Gateway is simulated to be partitioned. It is difficult to test that we cannot make a connection once that has happened because we would have to simulate a malicious client that knows about resources / connections or ignores the "remove resource" message.

Testing this is deferred to a dedicated task. We do test that we hit the code path of revoking the resource authorization and because the other resources keep working, we also test that we are at least not revoking the wrong ones.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This transition essentially simulates a re-connect to the portal and receiving a list of authorizations that contains all but the above resource.

This will be easier to understand once I get around to do #9895.

</ChangeItem>
<ChangeItem pull="9896">
Fixes a security issue where resource authorizations would not get
revoked if the Gateway was disconnected from the portal.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
revoked if the Gateway was disconnected from the portal.
revoked if the Gateway was disconnected from the portal while access was removed.

establish.
</ChangeItem>
<ChangeItem pull="9896">
Fixes a security issue where resource authorizations would not get

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Fixes a security issue where resource authorizations would not get
Fixes a potential security issue where prior resource authorizations would not get

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just want to be clear / explicit here

@thomaseizinger
thomaseizinger added this pull request to the merge queue Jul 17, 2025
Merged via the queue into main with commit 3e71a91 Jul 17, 2025
118 checks passed
github-merge-queue Bot pushed a commit that referenced this pull request Jul 18, 2025
Feedback from the PR. It merged before I could work in the changes.
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.

Gateway should receive authorizations in init and remove expired ones

2 participants