-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Description
Current Status
The hyperledger/fabric-lib-go library's health check mechanism, specifically the RunChecks function in healthz/checker.go, directly exposes the err.Error() string in the /healthz endpoint's JSON response. This design lacks a sanitization or abstraction layer, creating a risk of sensitive information disclosure if a developer inadvertently includes such details in a custom HealthChecker error message. While no current Fabric health checkers are known to leak sensitive data, the design itself represents a latent vulnerability, as demonstrated by a proof-of-concept (PoC) where a custom checker leaks credentials.
This issue was initially reported on HackerOne (Report #[improfessor
poc_scripts.zip
vulnerability_report.pdf
]), where it was agreed that while not currently an exploitable vulnerability in existing Fabric checkers, it is a valuable design enhancement that aligns with defense-in-depth principles.
Expected
Upon successful implementation of the proposed enhancements, the hyperledger/fabric-lib-go library is expected to provide a robust and resilient health check mechanism that inherently prevents the inadvertent exposure of sensitive information through error messages. The primary expectation is a significant reduction in the risk of data leakage, even in scenarios where developers might unintentionally embed sensitive details within custom HealthChecker error outputs. This will elevate the library's security posture, align it more closely with defense-in-depth principles, and offer developers a safer framework for building secure applications on Hyperledger Fabric, minimizing the potential for human error to compromise sensitive data. The current design, while not yet demonstrated to be exploitable in existing Fabric health checks, represents a critical security oversight that, if left unaddressed, poses a substantial risk of sensitive information disclosure in future or custom implementations. This potential for inadvertent exposure of critical data, such as credentials or internal system details, is a severe security concern that warrants immediate attention and remediation to prevent future classification as a Common Vulnerabilities and Exposures (CVE) due to real-world exploitation.
Solution
To effectively address the potential for sensitive information disclosure via health check errors, the following multi-layered defense-in-depth strategies should be considered for implementation within the hyperledger/fabric-lib-go library. This design flaw directly contributes to weaknesses such as CWE-200 (Exposure of Sensitive Information to an Unauthorized Actor: https://cwe.mitre.org/data/definitions/200.html ) and CWE-532 (Inclusion of Sensitive Information in Log Files: https://cwe.mitre.org/data/definitions/532.html ), which are critical security concerns.
A. Error Message Abstraction and Structuring:
Implement a SecureHealthCheckError Interface: Define a new interface (e.g., SecureHealthCheckError) that HealthChecker implementations would return instead of a raw error. This interface would have two distinct methods:
PublicMessage() string: Returns a generic, non-sensitive message suitable for external display (e.g., "Database connection check failed").
InternalDetails() string: Returns detailed, potentially sensitive information intended only for internal logging and debugging, never exposed directly via the /healthz endpoint.
Modify RunChecks: The RunChecks function would then extract the PublicMessage() for the /healthz JSON response and InternalDetails() for internal logging.
B. Automated Sanitization and Redaction Layer:
Pre-serialization Filtering: Introduce a mandatory processing step before serializing the health check response to JSON. This step would actively scan the PublicMessage() (or any error string if abstraction is not fully adopted) for common patterns of sensitive data.
Pattern Matching and Redaction: Implement regular expressions or string matching algorithms to identify and redact (replace with [REDACTED] or similar) sensitive information such as:
API keys, tokens, and secrets (e.g., api_key=, token=, secret=).
Database connection strings or credentials (e.g., user=, password=, db_host=).
Private IP addresses or internal hostnames.
Stack traces or excessive debug information that could reveal system architecture.
Configurable Redaction Rules: Allow for configurable redaction rules, enabling administrators to define custom patterns for sensitive data specific to their deployments.
C. Configurable Verbosity Control (Secure by Default):
Environment-Driven Detail Levels: Implement a mechanism (e.g., an environment variable like FABRIC_HEALTHCHECK_VERBOSITY=production|development|debug) that controls the level of detail in health check error messages.
production (Default): Only generic, non-sensitive messages are exposed. All internal details are suppressed or heavily redacted.
development: Allows for slightly more detail, but still redacts highly sensitive information.
debug: Exposes full error messages and internal details (with a strong warning about its use in non-secure environments).
Fail-Safe Default: The default setting for verbosity should always be production (least verbose, most secure) to ensure that the library is secure out-of-the-box.
These implementations would add critical layers of security, making the library more resilient to developer errors and enhancing its trustworthiness in sensitive deployments.
Please let us know if you plan to work on this.
No response