Skip to content

feat(security): P0 pentest modules (api, mcp, gossip) + prod profile#9

Draft
DJLougen wants to merge 1 commit into
mainfrom
cursor/pentest-p0-modules-a4a9
Draft

feat(security): P0 pentest modules (api, mcp, gossip) + prod profile#9
DJLougen wants to merge 1 commit into
mainfrom
cursor/pentest-p0-modules-a4a9

Conversation

@DJLougen

@DJLougen DJLougen commented Jun 4, 2026

Copy link
Copy Markdown
Owner

Summary

Expands the modular pentest suite and adds minimal hardening so production deployments can enforce auth on new HTTP/MCP/gossip surfaces.

Pentest (37 checks)

Module Checks
api localhost default, JWT middleware, prod hooks, HTTP 413 on oversized compress, active TestClient
mcp SSE localhost bind, JWT middleware on SSE, tool surface, stdio trust boundary
gossip http(s) peers only, HIVE_GOSSIP_SECRET on receive, prod hooks

CLI

python scripts/hive_pentest.py --profile prod --fail-on-skip --active
  • --profile dev (default): informational passes for optional auth
  • --profile prod: requires production security hooks to exist
  • --active: FastAPI TestClient checks on REST API (/health, compress limits, HIVE_REQUIRE_AUTH)

Hardening

  • hive/http_auth.py: HIVE_REQUIRE_AUTH + bearer JWT via existing JWTValidator
  • scripts/hive_api_server.py: auth middleware, 413 on oversized compress
  • scripts/hive_mcp_server.py: auth middleware on SSE; HIVE_MCP_BIND default 127.0.0.1
  • hive/gossip.py: validate peers at init; optional HIVE_GOSSIP_SECRET on receive()

CI

  • PR job: bandit on hive/ + API/MCP scripts, pip-audit, pentest hive+api+mcp+gossip --active
  • Full-stack job: --profile prod --fail-on-skip --active + pip-audit

Tests

  • tests/test_http_auth.py, tests/test_gossip_security.py, tests/test_pentest_extended.py
  • 188 passed locally

Production env vars

Variable Purpose
HIVE_REQUIRE_AUTH=true REST API + MCP SSE require Bearer JWT
HIVE_JWKS_URL / HIVE_JWT_PUBLIC_KEY JWT validation
HIVE_GOSSIP_SECRET Shared secret for gossip receive()

Slack Thread

Open in Web Open in Cursor 

- Add pentest modules for REST API, MCP SSE, and gossip protocol
- Introduce --profile dev|prod and --active FastAPI TestClient checks
- Add hive.http_auth with HIVE_REQUIRE_AUTH for API and MCP SSE
- Harden gossip: http(s) peers only, optional HIVE_GOSSIP_SECRET on receive
- Map oversized compress to HTTP 413 on API server
- CI: bandit on scripts, pip-audit, prod pentest on full stack
- Tests and SECURITY.md / USAGE.md updates

Co-authored-by: Daniel <DJLougen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants