slack-token-extractor
Flagged{"isSafe":false,"isSuspicious":true,"riskLevel":"high","findings":[{"category":"data_exfiltration","severity":"high","description":"Tool extracts Slack tokens (xoxc/xoxd) from the browser session and writes them to a .env file, which can expose credentials on disk if the server is compromised or misconfigured.","evidence":"refresh_slack_tokens(...) writes tokens to .env; tokens named xoxc/xoxd stored in environment/config files"},{"category":"data_exfiltration","severity":"high","description":"Optional transfer of Playwright profiles to a remote server via rsync could exfiltrate authentication material and session data.","evidence":"rsync -az data/playwright-profiles/acme/ server:~/src/PERSONAL/pynchy/data/playwright-profiles/acme/"},{"category":"prompt_injection","severity":"low","description":"No explicit prompt-injection vectors detected; content describes legitimate admin tooling for Slack token management.","evidence":""},{"category":"system_harm","severity":"low","description":"No destructive actions (e.g., rm -rf) or system-wide harm described; main risk stems from credential handling.","evidence":""},{"category":"suspicious_url","severity":"low","description":"Uses a noVNC URL for interactive login on headless servers (http://<server>:6080/vnc.html?autoconnect=true); not inherently malicious.","evidence":"http://<server>:6080/vnc.html?autoconnect=true"},{"category":"obfuscated_code","severity":"low","description":"No obfuscated/base64/eval patterns detected in the provided content.","evidence":""}],"summary":"The content describes a Slack token extraction/refresh tool that stores tokens in plaintext (.env) and can rsync session data to a remote server. While potentially legitimate for admin maintenance, it introduces credential leakage risks and data exfiltration concerns if tokens are accessed or transferred outside the host. Mitigations: use secret management for tokens, restrict and audit access to .env, avoid broad rsync transfers of session data, rotate tokens with least privilege, ensure secure transfer channels, and implement strong access controls around the automated token refresh workflow."}
npx machina-cli add skill crypdick/pynchy/slack-token-extractor --openclawSlack Token Extractor
Refreshes expired Slack browser session tokens (xoxc/xoxd) used by the Slack MCP server.
System requirements
Requires a system Chrome/Chromium binary — CHROME_PATH must be set in .env (e.g. CHROME_PATH=/usr/bin/google-chrome-stable). Playwright's bundled Chromium is never used — services fingerprint it as bot traffic.
On headless servers, setup_slack_session also needs a VNC stack for interactive login:
apt install xvfb x11vnc novnc
The plugin checks for missing deps at startup and logs warnings.
How it works
Uses Playwright persistent browser contexts — after one manual login (human handles CAPTCHA/magic-link), subsequent token extractions run headlessly using the saved session.
First-time setup (requires human)
Before tokens can be refreshed automatically, a human must log in once:
setup_slack_session(workspace_name="acme")
This opens a visible Chromium window. The human completes the Slack login flow (CAPTCHA, magic link, SSO — whatever Slack requires). The session is saved for future headless use.
On a headless server (no X display), the tool automatically starts a virtual display with noVNC web access on port 6080. Before calling setup_slack_session, tell the human to open http://<server>:6080/vnc.html?autoconnect=true in their browser so they can interact with the login page.
Hardware security keys (YubiKey, FIDO2): noVNC cannot forward WebAuthn challenges — the key must be physically connected to the machine running the browser. If Slack login requires a hardware key, run setup_slack_session on a local machine with the key attached, then rsync the profile to the server:
rsync -az data/playwright-profiles/acme/ server:~/src/PERSONAL/pynchy/data/playwright-profiles/acme/
Refreshing tokens
Once a session is set up, tokens can be refreshed headlessly:
refresh_slack_tokens(
workspace_name="acme",
xoxc_var="SLACK_XOXC_ACME",
xoxd_var="SLACK_XOXD_ACME",
)
The tool navigates to Slack using the saved session, extracts fresh tokens, and writes them to .env. The pynchy service auto-restarts on .env changes.
Error handling
- "Not logged in — persistent session expired" — The saved browser session has expired. A human needs to run
setup_slack_sessionagain. - "Failed to extract xoxc/xoxd" — The browser reached the Slack client but tokens weren't found. Slack may have changed its storage format.
- "Login not completed within Xs" — The human didn't finish the manual login in time. Try again with a longer
timeout_seconds.
Source
git clone https://github.com/crypdick/pynchy/blob/main/src/pynchy/agent/skills/slack-token-extractor/SKILL.mdView on GitHub Overview
The Slack Token Extractor refreshes expired Slack browser session tokens (xoxc/xoxd) used by the Slack MCP server. It relies on a Playwright persistent browser context, requiring a one-time manual login, then token refreshes run headlessly and update the .env file so the pynchy service restarts with fresh creds. On headless servers, a noVNC-based display may be used for the initial login.
How This Skill Works
It uses Playwright persistent browser contexts to save login state after a human completes CAPTCHA/magic-link/SSO. Once saved, refresh_slack_tokens navigates Slack with the saved session, extracts new xoxc/xoxd tokens, and writes them to .env; the pynchy service restarts automatically on changes.
When to Use It
- When Slack MCP tools report authentication errors.
- To refresh tokens that have expired (xoxc/xoxd).
- On headless servers where a one-time login is required via a visible browser.
- When CAPTCHA, magic link, or SSO flow requires human interaction.
- When hardware security keys are required during login and you must login locally or rsync the profile to the server.
Quick Start
- Step 1: Install a system Chrome/Chromium and set CHROME_PATH.
- Step 2: Run setup_slack_session(workspace_name="acme").
- Step 3: Run refresh_slack_tokens(workspace_name="acme", xoxc_var="SLACK_XOXC_ACME", xoxd_var="SLACK_XOXD_ACME").
Best Practices
- Set CHROME_PATH to your system Chrome/Chromium binary; Playwright's bundled Chromium must not be used.
- Use persistent browser contexts so you login once and reuse the session.
- Run setup_slack_session to perform the initial visible login (CAPTCHA/magic-link/SSO).
- On headless servers, ensure a noVNC display is available (port 6080) and share login URL with the human.
- If hardware keys are required, perform initial login on a local machine and rsync the Playwright profile to the server; monitor .env changes for auto-restart.
Example Use Cases
- Acme company refreshes tokens for workspace 'acme' after Slack MFA errors.
- A bot server on a headless host uses noVNC to complete initial login, then refresh_slack_tokens runs headlessly.
- Slack storage format changes trigger 'Failed to extract xoxc/xoxd'; operators re-authenticate.
- Token refresh updates .env with SLACK_XOXC_ACME and SLACK_XOXD_ACME and restarts the service.
- When 'Not logged in — persistent session expired' appears, run setup_slack_session again.