Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
fix: address security review feedback on console cookies, timing attacks, and E2E assertions
Antonio Ojead23951965988
diff --git a/internal/console/server.go b/internal/console/server.goindex 77a4b596..4346c758 100644--- a/internal/console/server.go+++ b/internal/console/server.go@@ -166,7 +166,7 @@ func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request) {Path: "/",MaxAge: 300,HttpOnly: true,- Secure: false,+ Secure: scheme == "https",SameSite: http.SameSiteLaxMode,})@@ -176,7 +176,7 @@ func (s *Server) HandleLogin(w http.ResponseWriter, r *http.Request) {Path: "/",MaxAge: 300,HttpOnly: true,- Secure: false,+ Secure: scheme == "https",SameSite: http.SameSiteLaxMode,})@@ -250,7 +250,7 @@ func (s *Server) HandleCallback(w http.ResponseWriter, r *http.Request) {Path: "/",MaxAge: 24 * 3600,HttpOnly: true,- Secure: false,+ Secure: scheme == "https",SameSite: http.SameSiteLaxMode,})diff --git a/internal/controlplane/server.go b/internal/controlplane/server.goindex bad3999e..d26be642 100644--- a/internal/controlplane/server.go+++ b/internal/controlplane/server.go@@ -19,6 +19,7 @@ import ("crypto/ed25519""crypto/rand""crypto/sha256"+ "crypto/subtle""crypto/tls""encoding/base64""encoding/hex"@@ -1087,13 +1088,17 @@ func (s *Server) authenticateUser(r *http.Request) (*storage.User, error) {}// 1. Check root admin token backdoor- if s.config.AdminToken != "" && tokenStr == s.config.AdminToken {- return &storage.User{- ID: "root-admin",- Email: "[email protected]",- Role: "admin",- CreatedAt: time.Now(),- }, nil+ if s.config.AdminToken != "" {+ tokenHash := sha256.Sum256([]byte(tokenStr))+ adminHash := sha256.Sum256([]byte(s.config.AdminToken))+ if subtle.ConstantTimeCompare(tokenHash[:], adminHash[:]) == 1 {+ return &storage.User{+ ID: "root-admin",+ Email: "[email protected]",+ Role: "admin",+ CreatedAt: time.Now(),+ }, nil+ }}// 2. Validate OIDC tokendiff --git a/tests/e2e/console.bats b/tests/e2e/console.batsindex 43056a3a..6a15cc3e 100644--- a/tests/e2e/console.bats+++ b/tests/e2e/console.bats@@ -40,7 +40,7 @@ teardown() {[[ "$output" == *"<title>SAM Console</title>"* ]]# Test proxy to control plane /admin/status (mapped under /api/)- run docker run --rm --network "${MESH_NETWORK}" curlimages/curl -s -f "http://${console_name}:8081/api/admin/status"+ run docker run --rm --network "${MESH_NETWORK}" curlimages/curl -s -f -H "Authorization: Bearer super-secret-admin-token" "http://${console_name}:8081/api/admin/status"[[ "$status" -eq 0 ]][[ "$output" == *"active_routers"* ]]}