-
-
Notifications
You must be signed in to change notification settings - Fork 337
[Security] Generic OAuth allows anyone to authenticate as a user if map_user_id is not configured correctly #469
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
Comments
Thanks for the report, @PeterCxy -- this is something we definitely need to fix. To help us replicate and debug this quicker, can you share your generic OAuth config? |
@thebaer Sure. My config is quite basic [oauth.generic]
client_id = <redacted>
client_secret = <redacted>
host = https://sn.angry.im
display_name = Mastodon on SN.Angry.Im
token_endpoint = /oauth/token
inspect_endpoint = /api/v1/accounts/verify_credentials
auth_endpoint = /oauth/authorize
scope = read:accounts
allow_disconnect = false (sn.angry.im is just a Mastodon instance I run) This configuration results in said bug because |
...on the OAuth access token inspection call. This returns an error and privately (via logs) prompts the admin to add a `map_user_id` config value. Fixes #469
Thanks! I configured one of my instances for Mastodon, tested this all out, and fixed this in #474. Now we'll return an error and a helpful log message when there's no |
@thebaer The fix looks good to me. BTW, maybe the admin documentation on writefreely.org should also be updated with those mapping options? |
@PeterCxy yes, I'll open a PR for that on our documentation repo soon. |
Describe the bug
I was attempting to configure Generic OAuth for my WriteFreely instance with my Mastodon instance. Initially, I followed what's described on https://writefreely.org/docs/latest/admin/config, and everything seemed to be working. I could link my Mastodon account on WriteFreely, and I could log into my WriteFreely account with my Mastodon account just fine... until I noticed that everybody that has an account on my Mastodon instance now authenticates as me on the WriteFreely instance.
A close inspection on the database revealed that the
remote_user_id
field in the database was empty (null). This resulted in the single record being matched for every OAuth login request, thus resulting the aforementioned behavior.After digging around in the source code, I realized that Mastodon does not return the user id in the field
user_id
, but instead inid
, and WriteFreely needs a special configurationmap_user_id
for that (and also a few othermap_*
options). These are mentioned nowhere in the documentation.So basically, the issue here is:
remote_user_id
cannot be fetched). There should be some big red error / warning in the logs to notify the administrator of the situation, instead of having to dig around in the source code to find the solution.map_*
options should be included somewhere noticeable in the documentation.Steps to reproduce (if necessary)
map_user_id
Expected behavior
remote_user_id
being null)Version or last commit: 0.13.0
The text was updated successfully, but these errors were encountered: