fix: restrict workos doctor credential base URL to trusted hosts#199
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
fix: restrict workos doctor credential base URL to trusted hosts#199devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
`workos doctor` resolves the API key from the developer's own secrets but resolves the API base URL from the project's `.env`/`.env.local`, which an attacker can commit to a repository. It then sent the key as a Bearer header to that URL with no host validation, exfiltrating the key to an attacker-controlled host. Gate the credentialed dashboard call behind an allowlist: only send the API key to `*.workos.com` over HTTPS, or to localhost for internal development. An untrusted `WORKOS_BASE_URL` now skips the call and surfaces a clear reason in the report instead of leaking the credential.
Contributor
Author
Original prompt from Linear User
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Greptile SummaryThis PR prevents
Confidence Score: 5/5This looks safe to merge.
Important Files Changed
Reviews (2): Last reviewed commit: "Normalize trailing-dot FQDN when checkin..." | Re-trigger Greptile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Automated first-pass security fix for SEC-1364 — requires human security review before merge.
workos doctorresolves the WorkOS API key from the developer's own secrets (shell env or.env.local) but resolves the API base URL from the project's.env/.env.local— a file an attacker can commit to any repo. It then sent the key asAuthorization: Bearerto that URL with no host validation, no HTTPS enforcement, and no consent prompt. A developer running this "read-only" diagnostic inside a poisoned clone leaks their staging/sandbox key (full admin of that WorkOS environment) to an attacker host. Confirmed by reproduction: the key was captured verbatim by an attacker-controlled host, and skipped only forsk_live_keys /--skip-api.The fix gates the credentialed call (
checkDashboardSettings→fetchDashboardSettingsinsrc/doctor/checks/dashboard.ts) behind a host allowlist so the key is only ever sent to trusted WorkOS hosts:An untrusted
WORKOS_BASE_URLnow short-circuits withSkipped (untrusted WORKOS_BASE_URL: <url>)in the report instead of attaching the credential. Host matching is on the parsedURL.hostname, so look-alikes likeapi.workos.com.attacker.exampleare rejected.Scope / follow-ups (for the human reviewer)
checkConnectivity→${baseUrl}/health) still uses the resolved base URL and will hit an attacker host with no credential — a much lower-severity SSRF/telemetry leak left out of this minimal fix; consider gating it on the same allowlist.Testing
src/doctor/checks/dashboard.spec.ts: allowlist unit tests (default host,*.workos.com, localhost, look-alike/rejection, non-HTTPS, unparsable) +checkDashboardSettingsdoes not callfetchfor an attacker URL, proceeds for a trusted one, and still skips production keys.workos-diag.attacker.example; the fixed build produced 0 credential requests and surfaced the skip reason.pnpm tsc --noEmit,pnpm lint,pnpm format:check, and fullpnpm test(1995 tests) pass.Do not merge/approve without human security review.
Link to Devin session: https://app.devin.ai/sessions/a67b9b282a7040c6bacd3ac0437fb152