fix(security): enforce signature verification for Kafka, MongoDB, and Redis proxy actions - #142
fix(security): enforce signature verification for Kafka, MongoDB, and Redis proxy actions#142blue4209211 wants to merge 4 commits into
Conversation
… stripping in discovery
…milyByID for immutability
… Redis proxy actions
There was a problem hiding this comment.
Code Review
This pull request introduces performance optimizations and security enhancements across the proxy and WebSocket handler. Specifically, it replaces a static map literal with a switch statement in osFamily to achieve zero-allocation lookups, optimizes signature line parsing in ParseAndVerify, and significantly expands the signedActions map to enforce signature verification across 21 previously omitted Kafka, MongoDB, and Redis proxy actions. Additionally, signature verification is now enforced globally when enabled as a defense-in-depth measure. Feedback on the changes focuses on improving test robustness in pkg/ws/handler_test.go by explicitly checking errors returned from secrets.NewCloudPushStore and json.Unmarshal instead of ignoring them.
Summary
This PR fixes an authorization and signature verification bypass vulnerability in
pkg/ws/handler.gowhere proxy actions across Kafka, MongoDB, and Redis were missing fromsignedActions, allowing unauthenticated / unsigned messages from the WebSocket relay to be dispatched without cryptographic signature verification.Key Changes
signedActions:kafka_consumer_lag,kafka_consumer_groups,kafka_consumer_group_describe,kafka_topics,kafka_topic_describe,kafka_brokers,kafka_topic_offsetsmongo_server_status,mongo_repl_status,mongo_collection_stats,mongo_current_ops,mongo_db_stats,mongo_list_databases,mongo_list_collectionsredis_info,redis_info_section,redis_slowlog,redis_client_list,redis_memory_stats,redis_cluster_info,redis_keyspace_statsHandleMessageinpkg/ws/handler.goto enforce verification whenever signing is enabled (h.verifier.Enabled()), ensuring unknown or unlisted actions cannot fail open.pkg/ws/handler_test.go(TestHandler_SignatureEnforcement) verifying rejection (HTTP 403) for unsigned messages and acceptance (HTTP 200) for validly signed messages across Kafka, MongoDB, and Redis.pkg/ws/discovery_wire_test.go(TestActionsThatTouchRemoteSystemsAreSigned) to assert that all actions require signatures..jules/sentinel.md.Verification
make lintpasses with 0 issues.go test -count=1 ./...passes all test suites.