Skip to content

nightshift/security: add CSRF state to Slack and GitHub OAuth#17

Open
perandre wants to merge 1 commit intomainfrom
nightshift/security-2026-04-13
Open

nightshift/security: add CSRF state to Slack and GitHub OAuth#17
perandre wants to merge 1 commit intomainfrom
nightshift/security-2026-04-13

Conversation

@perandre
Copy link
Copy Markdown
Owner

Summary

The Slack and GitHub OAuth flows were missing CSRF state parameter validation — an attacker could craft a link that forces a logged-in user to connect an attacker-controlled Slack or GitHub account (OWASP A5: Broken Access Control). HubSpot and Jira already had proper state validation; Slack and GitHub did not.

Risk

An attacker could trick a user into linking an attacker-controlled Slack workspace or GitHub account, potentially exposing the user's worklog data to the attacker's integrations.

Fix

  • /api/auth/slack/route.ts: generates a crypto.randomUUID() state token, stores it in an httpOnly cookie, and passes it to Slack's authorize URL.
  • /api/auth/slack/callback/route.ts: validates the returned state param against the cookie before exchanging the code. Rejects with state_mismatch on failure.
  • /api/auth/github/route.ts: same pattern — generates state, stores in cookie, passes to GitHub.
  • /api/auth/github/callback/route.ts: validates state before code exchange.
  • Removed duplicate await cookies() calls in both callbacks.

Verification

Build passes. The fix follows the exact same pattern already used by the HubSpot and Jira OAuth flows in this codebase.

The Slack and GitHub OAuth callbacks lacked state parameter validation,
making them vulnerable to CSRF attacks (OWASP A5). An attacker could
trick a logged-in user into connecting an attacker-controlled Slack or
GitHub account. Both flows now generate a random state token stored in
an httpOnly cookie, and the callback verifies it before exchanging the
authorization code.

https://claude.ai/code/session_01EG1HcH5DWijTkARenutW5N
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 13, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
activity Ready Ready Preview, Comment Apr 13, 2026 3:18am
worklog-xeqe Ready Ready Preview, Comment Apr 13, 2026 3:18am

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants