fix(security): address 7 high-priority vulnerabilities from security …#532
Open
liam wants to merge 5 commits intobsv-blockchain:mainfrom
Open
fix(security): address 7 high-priority vulnerabilities from security …#532liam wants to merge 5 commits intobsv-blockchain:mainfrom
liam wants to merge 5 commits intobsv-blockchain:mainfrom
Conversation
…audit - Enforce auth on admin endpoints (FSM POST, block invalidate/revalidate) regardless of dashboard state - Redact sensitive keys (passwords, private keys, tokens) in settings export metadata - Add SSRF protection to HTTP requests, rejecting private IPs and non-http schemes - Remove plaintext credential logging from dashboard auth handler - Remove InsecureSkipVerify from TLS security levels 2-3, add MinVersion TLS 1.2 - Add panic recovery to RPC handler goroutines to prevent crashes - Guard against division by zero in subtree validation batch size calculation
Contributor
|
🤖 Claude Code Review Status: Complete Current Review:
History:
|
Move ValidateURL from executeHTTPRequest (global) to service entry points where peer-provided URLs arrive (blockvalidation blockHandler, subtreevalidation CheckBlockSubtrees/checkSubtreeFromBlock, catchup peer selection). This prevents SSRF validation from blocking legitimate internal HTTP calls like health checks. Narrow IP blocking to only reject link-local/cloud metadata addresses (169.254.x.x, fe80::/10) since teranode peers legitimately communicate over private networks (10.x, 172.x, 192.168.x) and loopback in local deployments.
| // executeHTTPRequest performs the actual HTTP request with the given context. | ||
| func executeHTTPRequest(ctx context.Context, cancelFn context.CancelFunc, url string, requestBody ...[]byte) (io.ReadCloser, context.CancelFunc, error) { | ||
| req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil) | ||
| func executeHTTPRequest(ctx context.Context, cancelFn context.CancelFunc, rawURL string, requestBody ...[]byte) (io.ReadCloser, context.CancelFunc, error) { |
Contributor
There was a problem hiding this comment.
✅ Fixed: SSRF validation now integrated into HTTP request flow
The ValidateURL function is now called in executeHTTPRequest at util/http.go:216, providing defense-in-depth protection for all HTTP requests by default. This resolves the previous concern about missing validation at entry points.
Restore ValidateURL in executeHTTPRequest for defense-in-depth - all HTTP requests are now validated, not just entry points. This is safe because the validation was narrowed to only block link-local/cloud metadata IPs (169.254.x.x) without DNS resolution, so it won't break health checks, peer communication, or tests using localhost/private IPs. Also fix forbidigo lint error in RPC panic recovery (fmt.Errorf -> errors.NewServiceError).
Remove ValidateURL calls from service entry points (CheckBlockSubtrees, checkSubtreeFromBlock, blockHandler, catchup peer selection). These are redundant now that ValidateURL is in executeHTTPRequest, and they caused test failures for internal calls using non-URL strings like "test" as baseURL placeholders.
ValidateURL now only validates http/https URLs and passes through non-http strings like the "legacy" sentinel value used as baseURL throughout block and subtree validation. These non-http strings will fail naturally at the HTTP client level if actually requested, so blocking them in validation was unnecessary and broke e2e tests.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



…audit