Skip to content

fix: SSRF, OOM, terminal injection, and IPv6 handling#1

Merged
dyaa merged 1 commit into
mainfrom
feat/hardening
Apr 6, 2026
Merged

fix: SSRF, OOM, terminal injection, and IPv6 handling#1
dyaa merged 1 commit into
mainfrom
feat/hardening

Conversation

@dyaa

@dyaa dyaa commented Apr 6, 2026

Copy link
Copy Markdown
Owner

Production hardening: context.Context, structured errors, godoc, security tests

  • Add context.Context as first parameter to all public API functions

  • Thread context through services to all network I/O (TLS dial, OCSP, CRL, HSTS, grading probes) using DialContext + HandshakeContext

  • Add signal-aware CLI context (graceful Ctrl+C via signal.NotifyContext)

  • Context-aware semaphore in CheckBatch (respects cancellation)

  • Define 8 structured error types (ErrConnection, ErrTLSHandshake, ErrCertificateInvalid, ErrCANotFound, ErrCAExists, ErrFileRead, ErrInvalidPEM, ErrUnsupportedProtocol) with Unwrap support

  • Export error types from pkg/tlsc for errors.As usage

  • Replace fmt.Errorf with structured errors at 12 call sites

  • Add godoc comments to all exported symbols (types, functions, constants, vars) across public API, domain models, and CA service

  • Add security control tests: isPrivateIP (20 cases), isSafeURL (7), validateURLScheme (7), ReadLimited (5), sanitize (11)

  • Block IPv6 tunnel addresses (6to4 2002::/16, Teredo 2001:0::/32) and all multicast in SSRF protection

  • Cap file reads at 1 MB via fileutil.ReadLimited (prevents OOM)

  • Fix PostgreSQL STARTTLS partial read (conn.Read → io.ReadFull)

  • Add omitempty to ValidationError JSON tag

@dyaa dyaa merged commit a1375f5 into main Apr 6, 2026
6 checks passed
@dyaa dyaa deleted the feat/hardening branch April 6, 2026 19:04
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