Skip to content

fix(security): address 7 high-priority vulnerabilities from security …#532

Open
liam wants to merge 5 commits intobsv-blockchain:mainfrom
liam:feature/securityAudit
Open

fix(security): address 7 high-priority vulnerabilities from security …#532
liam wants to merge 5 commits intobsv-blockchain:mainfrom
liam:feature/securityAudit

Conversation

@liam
Copy link
Collaborator

@liam liam commented Feb 26, 2026

…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

…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
@github-actions
Copy link
Contributor

github-actions bot commented Feb 26, 2026

🤖 Claude Code Review

Status: Complete

Current Review:
No issues found. All 7 security fixes are well-implemented with appropriate test coverage:

  1. Admin endpoint auth enforcement (FSM POST, block invalidate/revalidate)
  2. Secret redaction in settings export metadata
  3. SSRF protection integrated into HTTP request flow
  4. Plaintext credential logging removed from auth handler
  5. TLS hardening (removed InsecureSkipVerify, added MinVersion TLS 1.2)
  6. Panic recovery in RPC handler goroutines
  7. Division-by-zero guard in subtree validation

History:

  • ✅ Fixed: SSRF validation now properly integrated into executeHTTPRequest (previous inline comment resolved)

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) {
Copy link
Contributor

@github-actions github-actions bot Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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.

liam added 3 commits February 26, 2026 15:04
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.
@sonarqubecloud
Copy link

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.

1 participant