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

Pleroma/Mastodon oauth should require no scopes #2149

Open
tusooa opened this issue May 23, 2022 · 14 comments
Open

Pleroma/Mastodon oauth should require no scopes #2149

tusooa opened this issue May 23, 2022 · 14 comments
Labels
linked accounts integration with other platforms

Comments

@tusooa
Copy link

tusooa commented May 23, 2022

Currently it is requiring "read," but this allows the app to see anything I can see, including any content privately addressed to me. This is too much permission. Here you are just trying to verify the identity, so you should not be allowed to read any private stuff.

@Changaco
Copy link
Member

Liberapay does not request any specific scope when connecting a Mastodon or Pleroma account. I don't know if it's possible to explicitly request access to public information only.

@Changaco Changaco added the linked accounts integration with other platforms label May 26, 2022
@tusooa
Copy link
Author

tusooa commented Jun 2, 2022

read scope is explicitly written when registering an app. When asking for user authorization, if the scope is not given, it defaults to the scope set when registering the app.

https://github.com/liberapay/liberapay.com/blob/master/liberapay/elsewhere/mastodon.py#L62

        data = {
            'client_name': self.app_name,
            'redirect_uris': self.callback_url.format(domain=domain),
            'scopes': 'read',
            'website': self.app_url,
        }

@Changaco Changaco added the blocked issues that can't be fixed yet label Jun 2, 2022
@Changaco
Copy link
Member

Changaco commented Jun 2, 2022

OAuth Scopes - Mastodon documentation

If you do not specify a scope in your authorization request, or a scopes in your app creation request, the resulting access token / app will default to read access.

The set of scopes saved during app creation must include all the scopes that you will request in the authorization request, otherwise authorization will fail.

@Changaco
Copy link
Member

Changaco commented Jun 2, 2022

A possible solution to this issue is to not use OAuth at all and verify ownership in another way (e.g. by asking the user to send a private message to a bot or add a public link to their Liberapay profile in their Mastodon settings).

@tusooa
Copy link
Author

tusooa commented Jun 2, 2022

OAuth Scopes - Mastodon documentation

If you do not specify a scope in your authorization request, or a scopes in your app creation request, the resulting access token / app will default to read access.
The set of scopes saved during app creation must include all the scopes that you will request in the authorization request, otherwise authorization will fail.

Use "scopes": "".

Specifying an empty value is not the same as not specifying.

At least on Pleroma, this works:

] curl -H 'content-type: application/json' https://lm.kazv.moe/api/v1/apps -d'{"client_name": "test", "redirect_uris": "https://gl.lm.kazv.moe/web/", "scopes": ""}'

and then GET /oauth/authorize?client_id=${clientId}&redirect_uri=${REDIRECT_URI}&response_type=code will give you an authorize page with no scopes specified.

@Changaco Changaco added blocked issues that can't be fixed yet and removed blocked issues that can't be fixed yet labels Jun 2, 2022
@Changaco
Copy link
Member

Changaco commented Jun 7, 2022

an authorize page with no scopes specified.

That's true, but the page doesn't actually work. Clicking on the “Approve” button results in an error message being displayed.

@tusooa
Copy link
Author

tusooa commented Jun 9, 2022

Ummm, it turns out you can specify a fake scope

] curl -XPOST -H 'content-type: application/json' https://lm.kazv.moe/api/v1/apps -d'{"client_name": "test", "redirect_uris": "https://gl.lm.kazv.moe/web/", "scopes": "fake"}'

@Changaco Changaco mentioned this issue Jun 9, 2022
@Changaco
Copy link
Member

Changaco commented Jun 9, 2022

0f54c5f reduces the permissions requested from Mastodon to read:accounts, so only data which isn't really sensitive will be accessible. Unfortunately Pleroma doesn't seem to support Mastodon's “granular” scopes, so the scope obtained from Pleroma will continue to be read.

@tusooa
Copy link
Author

tusooa commented Jun 9, 2022

0f54c5f reduces the permissions requested from Mastodon to read:accounts, so only data which isn't really sensitive will be accessible. Unfortunately Pleroma doesn't seem to support Mastodon's “granular” scopes, so the scope obtained from Pleroma will continue to be read.

Pleroma does support read:accounts.

@Changaco
Copy link
Member

After testing again, I've found that Pleroma does support granting the read:accounts scope, but not when the app was registered with scopes="read". This is a bug in Pleroma, and it significantly complicates things.

@Changaco Changaco removed the blocked issues that can't be fixed yet label Jun 10, 2022
@tusooa
Copy link
Author

tusooa commented Jun 10, 2022

The app should be registered with scopes="read:accounts".

@Changaco
Copy link
Member

That would prevent requesting other read sub-scopes in the future if we need them. More importantly, we already have 169 apps registered in Pleroma instances with the read scope, we can't change them, we can't abandon them without losing access to the linked accounts, and in order to use different apps for different linked accounts we would have to make significant changes in our code (hence “it significantly complicates things”).

@tusooa
Copy link
Author

tusooa commented Jun 10, 2022

A possible solution to this issue is to not use OAuth at all and verify ownership in another way (e.g. by asking the user to send a private message to a bot or add a public link to their Liberapay profile in their Mastodon settings).

Then I would say please go with this approach and set OAuth aside

@FediVideos
Copy link

FediVideos commented Oct 5, 2024

A possible solution to this issue is to not use OAuth at all and verify ownership in another way (e.g. by asking the user to send a private message to a bot or add a public link to their Liberapay profile in their Mastodon settings).

Then I would say please go with this approach and set OAuth aside

Yeah, having a rel=me public link to their Liberapay page on their profile seems the sensible way of verifying identity. People are very likely to have that on their accounts anyway.

At the very least could this be offered as an alternative to OAuth?

Speaking personally I'm very nervous of giving full read access to anyone, especially if they don't need it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
linked accounts integration with other platforms
Development

No branches or pull requests

3 participants