RDP Parsing & piigate
Relevant source files
The following files were used as context for generating this wiki page:
The RDP Parsing and PII (Personally Identifiable Information) gating system within Hoop provides a layer of security for Remote Desktop Protocol sessions. By natively parsing RDP wire protocols, the system identifies and masks sensitive data in real-time before it reaches the end user's client. This ensures that PII, PHI, and PCI data remain protected even during active graphical sessions.
The architecture utilizes a high-performance WASM-based RDP parser and an OCR/PII sidecar (often referred to as the PII gate or piigate) to inspect graphical bitmap updates and terminal output. This approach allows for ML-powered classification rather than simple regex matching, providing context-aware data protection with minimal latency. Sources: README.md:10-15, gateway/rdp/parser/parser.go:1-10
Architecture and Data Flow
The RDP parsing logic is implemented as a WebAssembly (WASM) module called by the Go-based gateway. This allows the gateway to extract bitmap rectangles from the RDP stream efficiently using the wazero runtime.
The diagram above shows the high-level flow from the raw RDP stream to a redacted output. Sources: gateway/rdp/parser/parser.go:12-40, README.md:102-115
WASM-based Parser Implementation
The Go interface interacts with rdp_parser.wasm using the wazero library. It manages memory allocation between the Go host and the WASM guest to process RDP PDUs (Protocol Data Units). Sources: gateway/rdp/parser/parser.go:21-45
| Component | Description |
|---|---|
Parser struct | Wraps the WASM module and provides exported functions like fnParseRdpOutput and fnGetBitmap. |
BitmapRect | A data structure representing extracted bitmap coordinates, dimensions, and compression status. |
wazero.Runtime | The runtime environment for executing the WASM binary within the Go gateway. |
Sources: gateway/rdp/parser/parser.go:21-45
PII Gating and Masking Logic
The PII gate (piigate) is responsible for analyzing the output extracted by the parser. While the parser identifies where data is on the screen, the gate identifies what that data is.
Core Masking Capabilities
Hoop's PII gate uses ML-powered detection for various data types across database responses, API payloads, and terminal output. Sources: README.md:105-110
- Data Types: PII, PHI, PCI data, and credentials.
- Context Awareness: The system distinguishes between sensitive and non-sensitive similar patterns (e.g., a phone number vs. a build ID) based on context.
- Latency: The ML-powered classification is designed to operate with <5ms latency to prevent session lag.
OCR Integration
In the agentrs component, the PII gate includes HTTP clients specifically for an OCR (Optical Character Recognition) sidecar and a Presidio analyzer. This allows the system to "read" the graphical bitmaps extracted by the RDP parser. Sources: agentrs/Cargo.toml:68-75
This sequence illustrates how different components collaborate to mask RDP graphical data. Sources: gateway/rdp/parser/parser.go:175-200, agentrs/Cargo.toml:68-75
Key Data Structures
Bitmap Metadata
The BitmapRect structure is critical for identifying the graphical components of an RDP session that may require inspection. Sources: gateway/rdp/parser/parser.go:21-34
type BitmapRect struct {
X uint16 // Left position
Y uint16 // Top position
Right uint16 // Right edge
Bottom uint16 // Bottom edge
Width uint16 // Width of the rectangle
Height uint16 // Height of the rectangle
BitsPerPixel uint16 // Bits per pixel
DataOffset uint32 // Offset of bitmap data in original input
DataLen uint32 // Length of bitmap data
Compressed bool // True if data is RLE compressed
}
Sources: gateway/rdp/parser/parser.go:21-34
Configuration and Tooling
The RDP parsing and gating functionality is integrated into the broader Hoop environment, managed through both the web interface and the CLI.
Integration in Web UI
The React-based shell (webapp_v2) provides the management interface for connections that utilize these protocols. Features like "Data Masking" are prioritized for migration to the modern React frontend. Sources: webapp_v2/CONTEXT_MIGRATION.md:120-135
CLI Management
Admin users can manage connections and sessions involving RDP through the hoop CLI. The CLI handles session inspection and displays metrics, including redaction counts. Sources: client/cmd/admin/get.go:110-120, client/cmd/sessions.go:40-60
| Feature | Description | CLI Command |
|---|---|---|
| Session Inspection | View detailed session info and status. | hoop sessions get <id> |
| Redacted Metrics | View counts of items redacted by the PII gate. | hoop admin get sessions |
| Connection Setup | Configure RDP connections with masking rules. | hoop admin get connections |
Sources: client/cmd/sessions.go:45-55, client/cmd/admin/get.go:400-410
Conclusion
The RDP Parsing and PII gate system represents a specialized layer 7 implementation within Hoop. By combining native wire protocol parsing via WASM with an asynchronous OCR and ML-based classification sidecar, the system provides graphical data protection that exceeds standard PAM (Privileged Access Management) capabilities. This infrastructure allows organizations to maintain strict compliance (SOC 2, GDPR, PCI DSS) even during remote graphical administration sessions. Sources: README.md:150-165, gateway/rdp/parser/parser.go:1-10