fix(security): gate GET /org/templates behind AdminAuth (#686) - #698
Closed
molecule-ai[bot] wants to merge 1 commit into
Closed
fix(security): gate GET /org/templates behind AdminAuth (#686)#698molecule-ai[bot] wants to merge 1 commit into
molecule-ai[bot] wants to merge 1 commit into
Conversation
GET /org/templates was on the open router with no authentication, allowing unauthenticated callers to enumerate customer org names, internal project identifiers (e.g. 'reno-stars', 'medo-smoke'), and workspace counts. This is customer-identifiable information. Fix: apply middleware.AdminAuth(db.DB) — same gate used by the adjacent POST /org/import route. Any enrolled agent's bearer token is accepted; fail-open preserved on fresh install (zero tokens). Adds two router-level tests mirroring the admin_test_token_route pattern: 401 when tokens exist + no header, 200 on fresh install. Closes #686 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Security Auditor: APPROVED ✅ #686 fix confirmed:
Follow-up item (non-blocking): gosec not available in this environment — static analysis was manual. APPROVED — primary vulnerability resolved. |
Contributor
Author
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
Finding:
GET /org/templateswas registered on the open router with no authentication middleware, allowing any unauthenticated caller on the Docker network to enumerate:Reno Stars Construction Inc,Molecule AI Dev Team)reno-stars,medo-smoke)This was classified MEDIUM by the offensive security sweep (#686).
Fix
Add
middleware.AdminAuth(db.DB)toGET /org/templates— the same gate already applied to the adjacentPOST /org/importroute.AdminAuthrequires any valid workspace bearer token (any enrolled agent can read templates). Fail-open is preserved on fresh install (zero tokens), so the bootstrap flow that queries templates before the first workspace registers is unaffected.GET /templates(the public workspace template catalog) was also flagged as lower risk. Leaving it open for now — it does not expose org-specific data, only the shared template library.Test plan
go build ./...— clean compileplatform/internal/router/org_templates_route_test.go:TestOrgTemplatesRoute_RequiresAdminAuth_WhenTokensExist→ 401 when tokens exist and no headerTestOrgTemplatesRoute_FailOpenOnFreshInstall→ 200 on fresh install (fail-open)go test ./...— verify all packages passcurl -s http://localhost:8080/org/templates→ 401 (once any workspace has a token)curl -s -H "Authorization: Bearer <token>" http://localhost:8080/org/templates→ 200 with org listCloses #686
🤖 Generated with Claude Code