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

Discord Bot Token Reset Due to Potential Abuse #1260

Closed
hamoid opened this issue Oct 15, 2020 · 3 comments
Closed

Discord Bot Token Reset Due to Potential Abuse #1260

hamoid opened this issue Oct 15, 2020 · 3 comments
Labels

Comments

@hamoid
Copy link

hamoid commented Oct 15, 2020

Describe the bug
My server was down for 25 hours. Now that it's back, Discord is resetting the bot token after I turn Matterbridge on, so matterbridge can't sync Mattermost & Discord.

To Reproduce
I can only "reproduce" on my server: I get a new Discord token, restart Matterbridge and after a while the Token is reset.

Expected behavior
I'm not sure if it's due to the down time nor if it really is a bug in Matterbridge. I'm wondering if many messages have queued somewhere due to the downtime and now when I restart the system it's too much for Discord to handle.
The expected behavior is that it continues to work as it has during the last year.

Screenshots/debug logs
Are there details I can provide to help figure it out?

Environment (please complete the following information):

  • OS: Ubuntu Linux server
  • Matterbridge version: version: 1.18.3 8b26e42

Additional context

[general]
RemoteNickFormat="{NICK}: "

[mattermost.mymattermost]
Server="chat.xxx.org:443"

Team="ccb"

Login="bot"
Password="......."

PrefixMessagesWithNick=true

[telegram.mytelegram]
Token="..."

[discord.mydiscord]
Token="..."
Server="CCB" # picked from guilds the bot is connected to

[[gateway]]
name="general"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="town-square"

  [[gateway.inout]]
  account="telegram.mytelegram"
  channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="unity"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="unity"

  #[[gateway.inout]]
  #account="telegram.mytelegram"
  #channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="events"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="events"

  [[gateway.inout]]
  account="telegram.mytelegram"
  channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="shaders"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="shaders"

  #[[gateway.inout]]
  #account="telegram.mytelegram"
  #channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="collaborations"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="collaborations"

  #[[gateway.inout]]
  #account="telegram.mytelegram"
  #channel="-..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="inspiration"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="inspirations"

  #[[gateway.inout]]
  #account="telegram.mytelegram"
  #channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discordapp.com/api/webhooks/.../..."


[[gateway]]
name="jam"
enable=true

  [[gateway.inout]]
  account="mattermost.mymattermost"
  channel="jam"

  #[[gateway.inout]]
  #account="telegram.mytelegram"
  #channel="-100..."

  [[gateway.inout]]
  account="discord.mydiscord"
  channel="ID:..."
  [gateway.inout.options]
  WebhookURL="https://discord.com/api/webhooks/.../..."
@hamoid hamoid added the bug label Oct 15, 2020
@haykam821
Copy link
Contributor

Could you provide logs? It seems like you have a process manager that's restarting Matterbridge even though it is crashing due to some issue.

@hamoid
Copy link
Author

hamoid commented Oct 16, 2020

Thank you, I should have looked into the logs. You are right, it shows this over and over 1000 times:

-- Logs begin at Wed 2019-10-23 11:29:09 CEST, end at Fri 2020-10-16 09:14:33 CEST. --
Oct 15 18:21:01 m.xxx.org systemd[1]: Started Matterbridge to bridge chats.
Oct 15 18:21:04 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Running version 1.18.3 8b26e42a" prefix=main
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway unity" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway events" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway shaders" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway collaborations" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway inspiration" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway jam" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Parsing gateway general" prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Starting bridge: mattermost.mymattermost " prefix=router
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Connecting using login/password (sending and receiving)" prefix=mattermost
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=info msg="Connecting b0t (team: creativecodebln) on chat.xxx.org:443" prefix=mattermost
Oct 15 18:21:09 m.xxx.org matterbridge-1.18.3-linux-64bit[1546]: time="2020-10-15T18:21:04+02:00" level=fatal msg="Starting gateway failed: Bridge mattermost.mymattermost failed to start: "https://chat.xxx.org:443/api/v4/users/logout: model.client.connecting.app_error, Post \"https://chat.xxx.org:443/api/v4/users/logout\": dial tcp x.x.x.x:443: connect: connection refused"" prefix=main
Oct 15 18:21:04 m.xxx.org systemd[1]: matterbridge.service: Main process exited, code=exited, status=1/FAILURE
Oct 15 18:21:04 m.xxx.org systemd[1]: matterbridge.service: Failed with result 'exit-code'.
Oct 15 18:21:05 m.xxx.org systemd[1]: matterbridge.service: Service hold-off time over, scheduling restart.
Oct 15 18:21:05 m.xxx.org systemd[1]: matterbridge.service: Scheduled restart job, restart counter is at 1.

I'll try to figure out why that connection refused is happening. In the Mattemost System Console I see a Revoke Sessions for my bot user. Could that be useful?

Feel free to close the issue if it's obviously not an issue with Matterbridge.

@hamoid
Copy link
Author

hamoid commented Oct 19, 2020

Solved. First I changed a bunch of settings in Mattermost, with the goal of enabling the use of tokens, which do not expire. I suspect the log in in mattermost had expired. I commented out Login and Password, used Token instead.

It still did not start. I was then having this issue #1263 which I solved by changing the bot settings in discordapp.
I enabled two settings, one of them allows reading the list of users.

@hamoid hamoid closed this as completed Oct 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants