hoop

repository·main·Indexed 20 days ago

https://github.com/hoophq/hoop

An open-source Layer 7 gateway designed to secure infrastructure access for human engineers and AI agents. It features real-time data masking, command blocking (guardrails), and human-in-the-loop approvals. The ecosystem includes the Hoop Rust Agent (agentrs) for RDP functionality and hoop-inspect for deep protocol-aware inspection and PII detection in HTTP and Postgres traffic.

Tokens
139.3K
Snippets
470
Records
638
Agent score
67%

What's inside hoop

  1. Understand the CLJS to React Migration Roadmap

    main

    The webapp_v2 migration follows a structured roadmap to transition the Hoop Web App from ClojureScript (CLJS) to React. The process is divided into three main tracks:

    1. Track A (Dead-CLJS Cleanup): Sequential PRs to prepare for migration by cleaning up dead scaffolding, settings, admin panels, and auth/user/org logic.
    2. Track B (Migration Waves): The core migration effort organized into waves (Wave 1 to Wave 7). Waves move from visible value/tiny pages to complex infrastructure like resource wizards, runners, session details, and finally the Webclient.
    3. Track C (Parity Track): Interleaved tasks to ensure global CLJS behaviors (like Segment tracking, MS Clarity, clipboard blocking, and organization migration dialogs) are replicated in React before the CLJS bundle is removed.

    The migration concludes with the Endgame, which involves removing the bridge, tearing down the build process, and deleting the original webapp/ source.

  2. What is the Hoop Tunnel daemon (hsh-tunneld)?

    main

    The hsh-tunneld is a client-side tunnel daemon that allows developers to access Hoop connections using their names (e.g., psql -h pg-prod.hoop) as if they were on the local network.

    It works by intercepting traffic through a local TUN device (Linux /dev/net/tun or macOS utun) and a gVisor netstack. For every TCP flow, it opens a fresh gRPC bidirectional stream to the existing Hoop gateway using the Transport.Connect RPC. This ensures that all existing security features—such as authentication, audit logs, DLP, and access control—apply to the tunnel traffic automatically.

  3. How hoop works as a Layer 7 Gateway

    main

    hoop acts as a Layer 7 gateway sitting between users (Engineers, AI Agents, Service Accounts) and your infrastructure (Databases, K8s, SSH, APIs).

    Instead of using SDKs or plugins, hoop parses wire protocols in real time. This allows it to perform inline operations without requiring changes to your existing tools or endpoints. The gateway intercepts the traffic at the protocol level to apply masking, block commands, or request approvals before the bytes reach the target infrastructure.

  4. Understand review group states and lifecycle

    main

    Review resources consist of one or more review groups. Each group tracks its own status, the reviewer, and the timestamp of the review.

    Review Group Data Structures

    Initial State (PENDING) When a review is first created, groups are initialized with null for reviewer and date information:

    {
        "id": "aaa257be-5cc9-401d-ae7e-18ae806d366a",
        "group": "banking",
        "status": "PENDING",
        "reviewed_by": null,
        "review_date": null
    }

    Completed State Once a review is processed, the entry is populated with the reviewer's identity and the timestamp:

    {
        "id": "a546dfba-d917-4c2b-bc38-7852a7932573",
        "group": "banking",
        "status": "REJECTED",
        "reviewed_by": {
            "id": "17e4ff1a-104c-482c-be68-3c01bfc7028e",
            "name": "John Doe",
            "email": "john.doe@domain.tld",
            "slack_id": ""
        },
        "review_date": "2025-05-27T16:40:05.519754143Z"
    }
  5. Configure hoopinspect policy with local rules and OPA

    main

    hoopinspect uses a layered policy approach via policy.Chain{local, opa}.

    Local Rules are evaluated first to avoid unnecessary network round-trips. They support protocol-specific matching:

    • SQL: deny_words_list, pattern_match (REVER), operation, table.
    • HTTP: http_resource, http_status.
    • Cross-protocol: pii (for detecting sensitive information).

    OPA (Open Policy Agent) is used for more complex logic. hoopinspect sends an input document to an OPA Data API endpoint. The input document is a strict superset of metadata provided by ext_authz and postgres_proxy and works for both protocols.

    Important: Both evaluators fail closed. If OPA is unreachable or returns an undefined decision, the request is denied. You can set FailOpen to invert this behavior if availability is a higher priority than enforcement.

    policy.NewRules([]policy.Rule{
        {Name: "no-drop", Type: policy.MatchOperation,
         Operations: []hoopinspect.Operation{hoopinspect.OpDrop}},
    
        policy.Rule{Name: "no-admin", Type: policy.MatchHTTPResource}. 
            WithResources("/admin/**"),
    
        policy.Rule{Name: "no-5xx-leak", Type: policy.MatchHTTPStatus}.
            WithStatuses("5xx").
            WithMessage("upstream failure suppressed by policy"),
    })
  6. Supported protocols and connection types

    main

    The tunnel supports specific TCP-style protocols and a proxy mode.

    Supported TCP Protocols:

    • postgres
    • mysql
    • mssql
    • mongodb
    • oracledb
    • tcp
    • httpproxy

    Important Notes:

    • httpproxy: These connections are served on port 80 only. The client speaks plain HTTP to the tunnel (e.g., curl http://api-prod.hoop/path), and the agent terminates TLS at the upstream. Note that https://<name>.hoop will not work because the tunnel does not hold a certificate for *.hoop.
    • Excluded Protocols: SSH, kubernetes, RDP, SSM, and command-line connections are intentionally filtered out of the resolver. For these, use the hoop connect <name> command instead.
    • Access Review: If a connection requires access review, the tunnel will fail fast. You should run hoop connect <name> once to request access out-of-band.
  7. Manage Access Control with Groups

    main

    Groups are used to define which users may access or interact with specific resources. Groups can be managed manually via the Hoop Webapp or automatically propagated from an identity provider via the id_token during user login.

    Groups are used for two primary enforcement features:

    1. Connection Access: When the Access Control feature is enabled, you can define which groups have access to a specific connection.
    2. Execution Approvals: When the Review feature is enabled, you can define which groups are authorized to approve an execution for review resources.
  8. Understand the limitations of hoopinspect inspection

    main

    Before writing policies, be aware of the following technical limits of the inspection engine:

    • Table Detection: Tables identification is best-effort. An empty result means "could not determine," not "touches nothing." For critical protection, use RequireTableMatch: true.
    • Postgres Response Truncation: To protect relay memory, the Postgres codec stops decoding columns after 1000 rows in a single result set. The batch is marked Truncated. Policies must treat a Truncated batch as inconclusive rather than proof that a value is absent.
    • Database Statement Verbs: Database response statements report OpUnknown because the operation is tied to the original request. Key response-side SQL rules on Result instead of Operation.
    • PII Detection: PII detection is pattern-based and not exhaustive. It is not a replacement for table-level access control.
    • HTTP Protocols: Stream decoding is supported for HTTP/1.x only. For HTTP/2 and HTTP/3, use InspectRequest as the framing is handled by the connection terminator.
    • Path Normalization: Normalization is conservative. Numeric, UUID, hex, and long opaque segments are collapsed, but short slugs are not. Policies may be narrower than intended.
    • Transaction Isolation: The gate evaluates each statement independently; there is no cross-statement session state.
  9. Understand the `hsh tunnel` virtual network addressing

    main

    The hsh tunnel provides a dual-stack virtual network to allow seamless access to tunneled resources. It uses a client-side resolver that maps connection names to virtual IP addresses. This approach ensures that multiple connections to the same service (e.g., multiple Postgres instances) can all listen on the same port (e.g., 5432) without local port collisions.

    Addressing Schemes

    • IPv6 (ULA): Uses Unique Local Addresses from the fd00::/8 range. A /48 prefix is determined per tunnel session based on a hash of the Org ID and Tunnel Session ID.
    • IPv4 (CGNAT): Uses the 100.64.0.0/10 range. A /16 prefix is allocated per tunnel session.

    Key Properties

    • Deterministic Mapping: Connection names map to IPs via a stable hash. The same name will resolve to the same IP across tunnel restarts within a single session lifetime.
    • Immutability: IPs are immutable for the duration of a tunnel session. While the connection list can refresh and add new mappings, existing name-to-IP mappings are never reassigned to prevent breaking in-flight TCP connections.
    • Client-Side Resolution: The DNS resolver is owned by the tunnel client and is bound to the tunnel gateway IP (e.g., [fd00:hash:hash:hash::1]:53). It is not recursive; it only resolves names within the .hoop (or overridden) domain.
  10. Handle Clipboard Copy/Cut Blocking in React

    main
    In the legacy CLJS implementation, if disable_clipboard_copy_cut is enabled, document-level copy/cut listeners are installed. To maintain parity in the React shell, you must manually install and remove these listeners keyed on the configuration flag, as React only hides copy buttons by default.
  11. Identify known limitations of hoop-inspect

    main

    When integrating hoop-inspect, be aware of the following constraints:

    • Codecs: Currently only supports postgres and http.
    • Table Matching: The Tables field is best-effort (lexer-based, not a full SQL grammar). Use require_table_match: true on critical rules to mitigate false negatives.
    • PII Detection: Pattern-based detection is neither sound nor complete. It is a defense-in-depth measure, not a replacement for proper access control.
    • HTTP/1.x: Stream decoding is limited to HTTP/1.x. For HTTP/2 or HTTP/3, use InspectRequest at the termination point.
    • Plaintext: The proxy requires plaintext traffic to parse; TLS termination must happen at the caller (e.g., Envoy).
    • Transactions: Statements are inspected individually; there is no cross-statement session state or transaction awareness.
  12. Understand the PGlite WASI runtime artifact

    main

    The pglite-runtime.tar.gz artifact is a pre-compiled PostgreSQL 17.5 environment targeting wasm32-wasi (preview 1). It includes the core postgres.bki module, system SQL, timezone data, the plpgsql extension, and the default password file.

    In the Hoop gateway, this artifact is embedded directly into the binary and is automatically extracted into the configured data directory upon the first boot of the gateway.