Skip to content

Conversation

mjankowski
Copy link
Contributor

Not quite a full revert of #13820 - but close to it. Sort of a first pass which removes the bulk of what I think can safely be removed. There were a few areas where the underlying code changed a bit (ie, a straight revert wasn't possible) which may have room for more future refactor/cleanup after the initial attempt here.

This feature is the largest chunk of untested unused code in the app, I suspect - and (as far as I can tell) there's not an imminent plan to enable/activate it. I know there is separate work being done to formalize an AP-protocol-level E2EE standard, which we would presumably adopt if that is realized, so this is in some way prep/clean-out work in advance of that.

If I'm wrong about this and there IS a plan to enable this feature using the current impl, there's a lot of coverage we should add in advance of that.

@mjankowski mjankowski added javascript Pull requests that update Javascript code ruby Pull requests that update Ruby code performance Runtime performance security Security issues and fixes, vulnerabilities labels Jul 29, 2024
@shleeable
Copy link
Contributor

The mantra wins again.

cossack-labs-dont-roll-your-crypto-gdpr-blockchain

@ThisIsMissEm
Copy link
Contributor

We will need to either keep the crypto scope or do the database migration to quietly remove that scope from any applications, access tokens or access grants. If we remove the scope without the database migration, then I think we'll get 500 errors if we attempt to access an application using that scope.

@mjankowski
Copy link
Contributor Author

RE: the crypto scope (configured via doorkeeper) - given the commented-out and disabled nature of the feature, it seems unlikely that there are purposefully created records with that scope, doesn't it? Is the concern that since it was a configured scope and there hypothetically could have been requests for that scope which were processed and saved that way, we should be conservative about handling that edge case via migration or other mitigation ... or am I missing something about the creation path and it's actually more likely to have some records?

@ThisIsMissEm
Copy link
Contributor

We thought the same about the read:me scope which had only recently been merged, but in the month between there were many applications already using it. The crypto scope has existed for years, so, I'd expect there'd be at least some applications registered with it. Using the post migration should be enough:

    Doorkeeper::Application.where("scopes LIKE '%crypto%'").in_batches do |applications|
      applications.update_all("scopes = replace(scopes, 'crypto', '')")
    end

    Doorkeeper::AccessToken.where("scopes LIKE '%crypto%'").in_batches do |access_tokens|
      access_tokens.update_all("scopes = replace(scopes, 'crypto', '')")
    end

Should be sufficient. Arguably we should trim whitespace, but the whitespace isn't meaningfully important.

I don't generally suggest doing AccessGrants just because they're highly ephemeral, and the risk of breakage is very very minimal.

@mjankowski mjankowski force-pushed the remove-unused-e2ee-messages branch from 8df1888 to 51424a8 Compare August 13, 2024 14:10
@mjankowski mjankowski force-pushed the remove-unused-e2ee-messages branch 2 times, most recently from d249338 to b30f7f0 Compare August 27, 2024 13:56
Copy link
Contributor

github-actions bot commented Sep 2, 2024

This pull request has merge conflicts that must be resolved before it can be merged.

Copy link
Contributor

github-actions bot commented Sep 2, 2024

This pull request has resolved merge conflicts and is ready for review.

@mjankowski mjankowski force-pushed the remove-unused-e2ee-messages branch from 9ab7f82 to bf0f09e Compare September 3, 2024 18:15
Copy link
Contributor

github-actions bot commented Sep 4, 2024

This pull request has merge conflicts that must be resolved before it can be merged.

Copy link
Contributor

github-actions bot commented Sep 4, 2024

This pull request has resolved merge conflicts and is ready for review.

Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@mjankowski mjankowski force-pushed the remove-unused-e2ee-messages branch from 2b56d11 to c617299 Compare September 10, 2024 13:38
Copy link
Contributor

This pull request has resolved merge conflicts and is ready for review.

Copy link
Member

@renchap renchap left a comment

Choose a reason for hiding this comment

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

We decided to remove the unused E2EE code for now, as this code is unused and untested.

Adding E2EE to Mastodon is still something we could like some day, but this implementatin attempt was never conclusive. We will be following the various projects working on adding E2EE to ActivityPub, like https://github.com/swicg/activitypub-e2ee

If they end up with something that we can implement, we will see if it makes sense to add back this code for the new implementation.

@ThisIsMissEm
Copy link
Contributor

@renchap fantastic news! The one thing this still absolutely needs is the migration to drop the OAuth Scopes for crypto, otherwise we'll be having errors & breakages: #31193 (comment)

@mjankowski
Copy link
Contributor Author

Sorry, just saw this...

We thought the same about the read:me scope which had only recently been merged, but in the month between there were many applications already using it. The crypto scope has existed for years, so, I'd expect there'd be at least some applications registered with it.

Are those cases the same though? In the case of the read:me scope, it was active and deployed in nightlies and running places ... so while it's reasonable to not expect it to have been super widely used, there's at least a viable path for it to have been used by whatever audience of nightly-running instances there is. Whereas in the crypto scope case, to the best of my understanding is has never actually been enabled anywhere? (or at least, in default unchanged non-forked deployment)

I'll add a migration here or as followup if necessary, but I still don't understand the path where it could have been used.

@ThisIsMissEm
Copy link
Contributor

@mjankowski it existed in the UI when creating an application, was documented and was accepted when creating an application via API; it should likely be silently dropped & future applications should not be able to be created with it.

Just dropping the scope & the locales without rewriting the records will potentially result in applications that when viewed result in a 500

@ThisIsMissEm
Copy link
Contributor

IMG_8150

@mjankowski
Copy link
Contributor Author

Ah, I see ... I was thinking totally about the inbound permissions checking from the commented-out routes and couldnt see how they'd have created anything. Noted on that pathway/exposure.

I can work on that migration and either add here or as followup if this merges first.

Separately...

  • That view could use a responsive once over at narrow width?
  • I wonder if the "this application has a scope which the locales dont know about" could be handled more gracefully?

@renchap renchap added this pull request to the merge queue Sep 18, 2024
Merged via the queue into mastodon:main with commit 5405bdd Sep 18, 2024
33 checks passed
@mjankowski mjankowski deleted the remove-unused-e2ee-messages branch September 18, 2024 12:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
javascript Pull requests that update Javascript code performance Runtime performance ruby Pull requests that update Ruby code security Security issues and fixes, vulnerabilities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants