Skip to content
This repository was archived by the owner on Jan 22, 2026. It is now read-only.

Verify Slack webhook tokens - #776

Open
tadzik wants to merge 6 commits into
matrix-org:developfrom
tadzik:tadzik/webhook-verification
Open

Verify Slack webhook tokens#776
tadzik wants to merge 6 commits into
matrix-org:developfrom
tadzik:tadzik/webhook-verification

Conversation

@tadzik

@tadzik tadzik commented Mar 28, 2024

Copy link
Copy Markdown
Contributor

This will unfortunately require relinking all existing channels that use webhooks.

I pondered making this optional, but in the spirit of being secure by default, it's probably best if we mandate this.

Existing rooms will have to be unlinked and linked again (or have their database entries updated manually).

This also increases SlackHookHandler's test coverage by ~18% (from 9.39% to 27.51%) :)

tadzik added 2 commits March 28, 2024 14:25
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Signed-off-by: Tadeusz „tadzik” Sośnierz <tadeusz@sosnierz.com>
Comment thread src/SlackHookHandler.ts Outdated
}

private onRequest(req: IncomingMessage, res: ServerResponse) {
public _onRequest(req: IncomingMessage, res: ServerResponse) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This seems quite cheeky. If you're mocking stuff, why not hookHandler["onRequest"] to get around the public/private check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Getting around the check seems dirtier to me, to be honest. I won't fight for it though, I'm fine with either.

Comment thread src/SlackHookHandler.ts Outdated
}
return new Promise<void>((resolve, reject) => {
const srv = createServer(this.onRequest.bind(this));
const srv = createServer(this._onRequest.bind(this));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not a huge fan of the underscore prefix, smells like snakes

@tadzik tadzik Jun 5, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comment thread tests/integration/WebhookTest.ts Outdated
let room = new BridgedRoom(harness.main as unknown as Main, {
matrix_room_id: '!foo:bar.baz',
inbound_id: randomstring.generate(32),
slack_webhook_token: randomstring.generate(24),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What about no token at all :). Or null, or true etc etc :)

@tadzik tadzik Jun 5, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a few more in tadzik@4d312a3?diff=unified&w=1 :)

Comment thread changelog.d/776.bugfix
@@ -0,0 +1 @@
Verify Slack webhook tokens.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I figured bugfix is the closest this comes to, since it was arguably a bug that we never did this before.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants