High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.
security: make routes.Core an immutable function returning a copy
Boschf5ead3656133
diff --git a/docs/reference/sessions.md b/docs/reference/sessions.mdindex 24662768..a6398a23 100644--- a/docs/reference/sessions.md+++ b/docs/reference/sessions.md@@ -50,6 +50,8 @@ In `config.json`:- Each session bound to a specific agentId for activity tracking> **⚠️ Trusted environment only.** The session management API (`/api/sessions`) has no per-agent authorization scoping. Any caller authenticated with the server bearer token or a valid dashboard cookie can create, list, rotate, and revoke sessions for any agent. Do not expose these endpoints to untrusted networks or the public internet. If you need multi-tenant isolation, run separate PinchTab instances per tenant.+>+> In untrusted or shared environments where agent sessions are not needed, disable them entirely by setting `"enabled": false` or `"mode": "off"` in your config to reduce the auth surface.## CLI Usagediff --git a/internal/config/config_load.go b/internal/config/config_load.goindex 357b4d59..161ff118 100644--- a/internal/config/config_load.go+++ b/internal/config/config_load.go@@ -99,17 +99,6 @@ func Load() *RuntimeConfig {},// Session defaults- // NOTE: Agent sessions are enabled by default with mode "preferred".- // This means every instance accepts Authorization: Session tokens out of the box.- // Creating a session requires bearer auth first, but the default-on posture adds- // an auth surface that users may not be aware of. Consider setting Enabled: false- // if agent sessions are not needed.- //- // There is currently no per-agent authorization scoping on session management:- // any authenticated caller can create/list/revoke/rotate sessions for any agentId.- // This is acceptable in trusted single-operator environments but should be- // restricted (e.g. bearer-only or agent-scoped permissions) for multi-agent setups- // where one compromised agent could disrupt others.Sessions: SessionsRuntimeConfig{Agent: AgentSessionRuntimeConfig{Enabled: true,diff --git a/internal/dashboard/agent_session_api.go b/internal/dashboard/agent_session_api.goindex c66a021a..bb73ba55 100644--- a/internal/dashboard/agent_session_api.go+++ b/internal/dashboard/agent_session_api.go@@ -11,12 +11,6 @@ import ()// AgentSessionAPI handles CRUD operations for agent sessions.-//-// SECURITY NOTE: There is no per-agent authorization scoping. Any authenticated-// caller (bearer or cookie) can create sessions for any agentId, list all sessions,-// revoke any agent's session, and rotate any agent's token. This is by design for-// trusted single-operator environments. For multi-agent setups, consider restricting-// session management to bearer-only auth or adding agent-scoped permissions.type AgentSessionAPI struct {store *agentsession.Store}diff --git a/internal/orchestrator/handlers.go b/internal/orchestrator/handlers.goindex ff1d508c..0df8cf1f 100644--- a/internal/orchestrator/handlers.go+++ b/internal/orchestrator/handlers.go@@ -61,7 +61,7 @@ func (o *Orchestrator) registerHandlers(mux *http.ServeMux, skipLaunch bool) {mux.HandleFunc("POST /tabs/{id}/close", o.handleTabClose)// Tab operations - generic proxy (all route to the appropriate instance).- // Sourced from routes.Core catalogue to stay in sync with bridge and strategy.+ // Sourced from routes.Core() catalogue to stay in sync with bridge and strategy.for _, route := range routes.TabScopedRoutes() {mux.HandleFunc(route, o.proxyTabRequest)}diff --git a/internal/routes/routes.go b/internal/routes/routes.goindex 476a6153..4fbd0043 100644--- a/internal/routes/routes.go+++ b/internal/routes/routes.go@@ -41,9 +41,8 @@ func (e Endpoint) TabRoute() string {return e.Method + " /tabs/{id}" + e.Path}-// Core is the canonical list of API endpoints. Every proxied shorthand-// route and every bridge handler should correspond to an entry here.-var Core = []Endpoint{+// coreEndpoints is the canonical list of API endpoints.+var coreEndpoints = []Endpoint{// Navigation{"POST", "/navigate", "Navigate to URL", CapNone, true},{"POST", "/back", "Go back", CapNone, true},@@ -118,11 +117,18 @@ var Core = []Endpoint{{"GET", "/screencast/tabs", "List tabs available for screencast", CapScreencast, false},}+// Core returns a copy of the canonical endpoint list.+func Core() []Endpoint {+ out := make([]Endpoint, len(coreEndpoints))+ copy(out, coreEndpoints)+ return out+}+// ShorthandRoutes returns all non-capability-gated shorthand routes// as "METHOD /path" strings, suitable for mux registration.func ShorthandRoutes() []string {var routes []string- for _, ep := range Core {+ for _, ep := range coreEndpoints {if ep.Capability == CapNone {routes = append(routes, ep.Route())}@@ -133,7 +139,7 @@ func ShorthandRoutes() []string {// CapabilityEndpoints returns endpoints grouped by their capability gate.func CapabilityEndpoints() map[Capability][]Endpoint {m := make(map[Capability][]Endpoint)- for _, ep := range Core {+ for _, ep := range coreEndpoints {if ep.Capability != CapNone {m[ep.Capability] = append(m[ep.Capability], ep)}@@ -145,7 +151,7 @@ func CapabilityEndpoints() map[Capability][]Endpoint {// endpoints that are NOT capability-gated (those need separate handling).func TabScopedRoutes() []string {var routes []string- for _, ep := range Core {+ for _, ep := range coreEndpoints {if ep.TabScoped && ep.Capability == CapNone {routes = append(routes, ep.TabRoute())}@@ -156,7 +162,7 @@ func TabScopedRoutes() []string {// TabScopedCapabilityRoutes returns tab-scoped capability-gated endpoints.func TabScopedCapabilityRoutes() map[Capability][]Endpoint {m := make(map[Capability][]Endpoint)- for _, ep := range Core {+ for _, ep := range coreEndpoints {if ep.TabScoped && ep.Capability != CapNone {m[ep.Capability] = append(m[ep.Capability], ep)}diff --git a/internal/routes/routes_test.go b/internal/routes/routes_test.goindex 9691c705..6e5bd06d 100644--- a/internal/routes/routes_test.go+++ b/internal/routes/routes_test.go@@ -7,7 +7,7 @@ import (func TestNoDuplicateRoutes(t *testing.T) {seen := make(map[string]bool)- for _, ep := range Core {+ for _, ep := range Core() {key := ep.Route()if seen[key] {t.Errorf("duplicate route: %s", key)@@ -18,7 +18,7 @@ func TestNoDuplicateRoutes(t *testing.T) {func TestShorthandRoutesExcludeCapabilityGated(t *testing.T) {for _, r := range ShorthandRoutes() {- for _, ep := range Core {+ for _, ep := range Core() {if ep.Route() == r && ep.Capability != CapNone {t.Errorf("ShorthandRoutes() includes capability-gated route: %s", r)}@@ -59,7 +59,7 @@ func TestCapabilityEndpointsGrouping(t *testing.T) {}func TestAllEndpointsHaveMethodAndPath(t *testing.T) {- for _, ep := range Core {+ for _, ep := range Core() {if ep.Method == "" {t.Errorf("endpoint with empty method: %+v", ep)}diff --git a/internal/strategy/routes.go b/internal/strategy/routes.goindex eece9993..b7090465 100644--- a/internal/strategy/routes.go+++ b/internal/strategy/routes.go@@ -48,7 +48,7 @@ func capabilitySetting(cap routes.Capability) (feature, setting, code string) {// routes (evaluate, download, upload, screencast, macro) using the// orchestrator's security settings.//-// Routes are sourced from the shared routes.Core catalogue.+// Routes are sourced from the shared routes.Core() catalogue.func RegisterShorthandRoutes(mux *http.ServeMux, orch *orchestrator.Orchestrator, handler http.HandlerFunc) {for _, route := range routes.ShorthandRoutes() {mux.HandleFunc(route, handler)