Skip to content

draft editor: require a per-session token on the loopback server - #177

Open
benjaminkincses wants to merge 2 commits into
stablyai:mainfrom
benjaminkincses:fix/draft-editor-session-token
Open

benjaminkincses wants to merge 2 commits into
stablyai:mainfrom
benjaminkincses:fix/draft-editor-session-token

Conversation

@benjaminkincses

Copy link
Copy Markdown

The draft editor server binds 127.0.0.1 and serves POST /send, which posts to Slack as the user, with no authentication and no Origin check. Any local process can call it, and a web page that can reach loopback can send a cross-origin POST in the shape of a CORS simple request (JSON parsed regardless of content type). The editor stays open up to 30 minutes.

Fix: generate a random per-session token when the editor starts. The editor page is only served when the URL carries the token, the page sends it back as an X-Draft-Token header on /send and /cancel, and POSTs with a mismatched Origin are rejected. Token comparison is constant time.

Verified locally with a stub onSend: cross-origin POST without the token returns 403 and does not send, GET without the token returns 403, the normal editor flow with the token returns 200 and sends.

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.

1 participant