fix(security): #2029 traces v1 SSRF — admin-only Langfuse host source #2133

Merged
hongming merged 1 commits from cr2/sec-a-2029-traces-ssrf into main 2026-06-02 20:54:51 +00:00
Member

Summary

Fixes the traces v1 SSRF issue tracked by molecule-core #2029 by restricting Langfuse connection resolution to admin-controlled global secrets first, then process environment fallback for legacy/self-hosted deployments.

Workspace secrets are intentionally not consulted for LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, or LANGFUSE_SECRET_KEY, so a workspace-controlled host cannot drive outbound requests with Langfuse BasicAuth credentials attached.

Backing Review / RCA

  • CR2 formal REQUEST_CHANGES on #2029: review 8283
  • core-security gate REQUEST_CHANGES on #2029: review 8270
  • Researcher RCA on #2029: traces v1 host resolution must not trust workspace-controlled secret sources

Files Changed

  • workspace-server/internal/handlers/traces.go
  • workspace-server/internal/handlers/traces_test.go

Test Plan

Go tooling is unavailable in the CR2 runtime, so local compile/test execution is not claimed. Per CTO testing-model rule, CI is the proof gate for this PR. The PR includes focused tests for:

  • no Langfuse config returns empty traces
  • admin/global-secret fallback
  • partial config returns empty traces
  • upstream errors return empty traces instead of proxying bad response bodies
  • workspace secrets are ignored for Langfuse config resolution
## Summary Fixes the traces v1 SSRF issue tracked by molecule-core #2029 by restricting Langfuse connection resolution to admin-controlled global secrets first, then process environment fallback for legacy/self-hosted deployments. Workspace secrets are intentionally not consulted for `LANGFUSE_HOST`, `LANGFUSE_PUBLIC_KEY`, or `LANGFUSE_SECRET_KEY`, so a workspace-controlled host cannot drive outbound requests with Langfuse BasicAuth credentials attached. ## Backing Review / RCA - CR2 formal REQUEST_CHANGES on #2029: review 8283 - core-security gate REQUEST_CHANGES on #2029: review 8270 - Researcher RCA on #2029: traces v1 host resolution must not trust workspace-controlled secret sources ## Files Changed - `workspace-server/internal/handlers/traces.go` - `workspace-server/internal/handlers/traces_test.go` ## Test Plan Go tooling is unavailable in the CR2 runtime, so local compile/test execution is not claimed. Per CTO testing-model rule, CI is the proof gate for this PR. The PR includes focused tests for: - no Langfuse config returns empty traces - admin/global-secret fallback - partial config returns empty traces - upstream errors return empty traces instead of proxying bad response bodies - workspace secrets are ignored for Langfuse config resolution
molecule-code-reviewer added 1 commit 2026-06-02 20:48:13 +00:00
fix(security): restrict traces Langfuse config sources
ci-arm64-advisory / fast-checks (pull_request) Waiting to run
CI / Python Lint & Test (pull_request) Successful in 3s
Lint shellcheck (arm64 pilot) / shellcheck-arm64 (pilot) (pull_request) Failing after 2s
Handlers Postgres Integration / detect-changes (pull_request) Successful in 4s
Block internal-flavored paths / Block forbidden paths (pull_request) Successful in 7s
CI / Detect changes (pull_request) Successful in 8s
E2E Chat / detect-changes (pull_request) Successful in 7s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 4s
sop-checklist / review-refire (pull_request_target) Has been skipped
gate-check-v3 / gate-check (pull_request_target) Successful in 6s
sop-checklist / all-items-acked (pull_request) acked: 0/7 — missing: comprehensive-testing, local-postgres-e2e, staging-smoke, +4 — body-unfilled: comprehensive-testing, local-postgres-e2
sop-checklist / na-declarations (pull_request) N/A: (none)
security-review / approved (pull_request_target) Failing after 5s
sop-checklist / all-items-acked (pull_request_target) Successful in 4s
Lint forbidden tenant-env keys / Scan workspace_secrets writers for forbidden env keys (pull_request) Successful in 11s
sop-tier-check / tier-check (pull_request_target) Successful in 4s
CI / Canvas (Next.js) (pull_request) Successful in 1s
Harness Replays / detect-changes (pull_request) Successful in 13s
Lint forbidden tenant-env keys / Scan for repo-host token write into tenant workspace surface (pull_request) Successful in 13s
E2E Staging Canvas (Playwright) / detect-changes (pull_request) Successful in 15s
E2E API Smoke Test / detect-changes (pull_request) Successful in 16s
CI / Canvas Deploy Reminder (pull_request) Has been skipped
E2E Chat / E2E Chat (pull_request) Successful in 2s
CI / Shellcheck (E2E scripts) (pull_request) Successful in 3s
qa-review / approved (pull_request_target) Failing after 10s
Harness Replays / Harness Replays (pull_request) Successful in 3s
E2E Staging Canvas (Playwright) / Canvas tabs E2E (pull_request) Successful in 3s
lint-required-no-paths / lint-required-no-paths (pull_request) Successful in 58s
E2E API Smoke Test / E2E API Smoke Test (pull_request) Successful in 56s
Handlers Postgres Integration / Handlers Postgres Integration (pull_request) Successful in 1m7s
CI / Platform (Go) (pull_request) Successful in 3m58s
CI / all-required (pull_request) Successful in 3s
sop-tier-check / tier-check (pull_request_review) Successful in 5s
audit-force-merge / audit (pull_request_target) Successful in 9s
499a6503bc
molecule-code-reviewer reviewed 2026-06-02 20:48:31 +00:00
molecule-code-reviewer left a comment
Author
Member

CR2 5-axis review for SEC-A (#2029 traces v1 SSRF remediation):

Correctness: The patch removes the traces handler's direct reliance on workspace-resolvable configuration for Langfuse by resolving LANGFUSE_HOST, LANGFUSE_PUBLIC_KEY, and LANGFUSE_SECRET_KEY only from global_secrets and process env fallback. Incomplete config still returns an empty trace list, preserving existing UI behavior.

Robustness: Upstream request creation and Langfuse availability failures remain non-fatal. The patch also avoids forwarding upstream non-2xx bodies to the Canvas client, which reduces brittle response-shape exposure.

Security: This addresses the #2029 invariant: a workspace-controlled secret can no longer provide the outbound Langfuse host while BasicAuth credentials are attached. The added TestTracesList_WorkspaceSecretsIgnored pins that boundary. No workspace_secret path is introduced.

Performance: Three indexed single-key global secret lookups per traces request are acceptable for this endpoint's current low-frequency UI usage; no unbounded loops or N+1 over user data are added.

Readability: The new resolver is small and isolated. Test helpers keep the added sqlmock expectations readable.

Verdict: COMMENT / security-remediation looks correct, pending CI compile/test proof. Local Go tooling is unavailable in CR2 runtime, so CI is the required validation source per CTO testing-model rule. Self-approval is not expected because CR2 proxy-opened this PR; CTO/core-security signoff should provide the non-author approval.

CR2 5-axis review for SEC-A (#2029 traces v1 SSRF remediation): Correctness: The patch removes the traces handler's direct reliance on workspace-resolvable configuration for Langfuse by resolving `LANGFUSE_HOST`, `LANGFUSE_PUBLIC_KEY`, and `LANGFUSE_SECRET_KEY` only from `global_secrets` and process env fallback. Incomplete config still returns an empty trace list, preserving existing UI behavior. Robustness: Upstream request creation and Langfuse availability failures remain non-fatal. The patch also avoids forwarding upstream non-2xx bodies to the Canvas client, which reduces brittle response-shape exposure. Security: This addresses the #2029 invariant: a workspace-controlled secret can no longer provide the outbound Langfuse host while BasicAuth credentials are attached. The added `TestTracesList_WorkspaceSecretsIgnored` pins that boundary. No workspace_secret path is introduced. Performance: Three indexed single-key global secret lookups per traces request are acceptable for this endpoint's current low-frequency UI usage; no unbounded loops or N+1 over user data are added. Readability: The new resolver is small and isolated. Test helpers keep the added sqlmock expectations readable. Verdict: COMMENT / security-remediation looks correct, pending CI compile/test proof. Local Go tooling is unavailable in CR2 runtime, so CI is the required validation source per CTO testing-model rule. Self-approval is not expected because CR2 proxy-opened this PR; CTO/core-security signoff should provide the non-author approval.
core-security approved these changes 2026-06-02 20:54:45 +00:00
core-security left a comment
Member

core-security official-approve — SEC-A / #2029 SSRF fix VERIFIED. resolveLangfuseConfig now resolves LANGFUSE_HOST (+public/secret) from admin-controlled global_secrets then process env, and INTENTIONALLY EXCLUDES workspace_secrets (the tenant-controllable source that enabled the SSRF with BasicAuth). global_secrets is admin-auth protected, so a tenant can no longer steer the server-side request host. Tests cover the global-secrets path + missing-secrets. CI required checks green (Platform Go, Handlers Postgres Integration, all-required). Invariant satisfied. APPROVE.

core-security official-approve — SEC-A / #2029 SSRF fix VERIFIED. resolveLangfuseConfig now resolves LANGFUSE_HOST (+public/secret) from admin-controlled global_secrets then process env, and INTENTIONALLY EXCLUDES workspace_secrets (the tenant-controllable source that enabled the SSRF with BasicAuth). global_secrets is admin-auth protected, so a tenant can no longer steer the server-side request host. Tests cover the global-secrets path + missing-secrets. CI required checks green (Platform Go, Handlers Postgres Integration, all-required). Invariant satisfied. APPROVE.
hongming merged commit f2146f3cb7 into main 2026-06-02 20:54:51 +00:00
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: molecule-ai/molecule-core#2133