detect

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 21, 2026 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Package detect inspects one file's bytes and reports facts about it.

Every finding is a fact the user can re-check by hand:

  • a certificate in the file carries a tracked key (exact public-key match), or an elliptic-curve key whose private scalar is tiny (proved by k·G);
  • the raw bytes of a tracked public key appear in the file (exact match), which catches stores that keep keys outside PEM, such as JKS keystores, Rust's webpki-roots and DER files;
  • the file is a Go binary that links crypto/x509 certificate verification and was built with a Go release that predates the blocklist for these keys.

Nothing is reported from a certificate's name alone.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GoHasBlocklist

func GoHasBlocklist(v string) (fixed bool, known bool)

GoHasBlocklist reports whether a Go release string such as "go1.27.2" or "go1.26.10 X:boringcrypto" includes the blocklist. known is false for development builds, release candidates and anything it cannot parse.

Types

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector holds the loaded knowledge base.

func New

func New() (*Detector, error)

New loads and verifies the knowledge base.

func (*Detector) Chain

func (d *Detector) Chain(where string, certs []*x509.Certificate) []Finding

Chain checks the certificates a TLS server presented. It reports any certificate that carries a tracked or weak key, and any certificate whose signature verifies under a compromised key, which means it was issued by a compromised CA and must be replaced. where names the server, for example "example.com:443".

func (*Detector) HasBlocklist

func (d *Detector) HasBlocklist(data []byte) bool

HasBlocklist reports whether data contains the raw SHA-256 SPKI hash of all eight compromised keys, the form Node.js compiles in (kBlockedSPKIs). Go binaries are checked by the symbol of Go's blocklist check instead (see goBlocklistSym), so a data file that merely lists the hashes in text does not count.

func (*Detector) Scan

func (d *Detector) Scan(path string, data []byte) []Finding

Scan reports every finding in data, which is the full content of the file at path.

func (*Detector) ScanAll

func (d *Detector) ScanAll(path string, data []byte) ([]Finding, []Skip)

ScanAll is Scan plus the parts of the file that were recognised but could not be checked (for example a keystore whose password is unknown). A scan must report those, so a file is never counted as clean when it was not really read.

type Finding

type Finding struct {
	Kind     Kind   `json:"kind"`
	Path     string `json:"path"`
	Subject  string `json:"subject,omitempty"`     // certificate CN, or the tracked key's name
	SPKI     string `json:"spki_sha256,omitempty"` // key that matched
	CertHash string `json:"cert_sha256,omitempty"` // certificate that matched, when one was parsed
	Method   string `json:"method"`                // how it was found: pem, der, pkcs12, raw-key, go-buildinfo
	Detail   string `json:"detail"`                // the exact fact, in words
	Scalar   uint32 `json:"private_scalar,omitempty"`
	// Trust is what the file itself says about the certificate: "" (plain entry),
	// "distrusted" (p11-kit x-distrusted), or "no-usable-purpose" (OpenSSL trust
	// settings allow none of the purposes the compromised intermediates can issue for).
	Trust string `json:"file_trust,omitempty"`
	// Blocklisted is true when the same file also contains all eight compromised
	// SPKI hashes, the form Go (go1.26.10, go1.27.3) and Node.js use for their
	// compiled-in blocklists. Software built that way rejects the compromised
	// chains even though it carries the roots.
	Blocklisted bool `json:"file_has_blocklist,omitempty"`
	// Purposes, when the file's own trust settings restrict the certificate, lists
	// the purposes it is trusted for that a compromised intermediate can also issue
	// for (TLS server, TLS client, code signing). Empty with Trust "no-usable-purpose"
	// means none overlap.
	Purposes []string `json:"exposed_purposes,omitempty"`
	// Binary is the executable format for unpatched-go findings: "elf", "macho" or "pe".
	Binary string `json:"binary,omitempty"`
}

Finding is one fact about one file.

type Kind

type Kind string

Kind of finding.

const (
	// TrustsCompromisedKey: the file contains a certificate (or the raw key) of one of
	// the eight compromised intermediates. Any software that treats the file as a
	// trust store trusts a key anyone can forge with.
	TrustsCompromisedKey Kind = "compromised-key"
	// TrustsPathRoot: the file contains a CA that issued or cross-signed the
	// compromised intermediates. Software that trusts it and does not block the
	// intermediates accepts certificates forged with the compromised keys.
	TrustsPathRoot Kind = "path-root"
	// WeakKey: a certificate in the file has an elliptic-curve key whose private
	// scalar is below 2^16 (or its negation is). Its private key is public knowledge.
	WeakKey Kind = "weak-key"
	// UnpatchedGo: a Go binary that links crypto/x509 chain verification and was
	// built with a Go release without the CVE-2026-111943 blocklist.
	UnpatchedGo Kind = "unpatched-go"
)
const IssuedByCompromised Kind = "issued-by-compromised-ca"

IssuedByCompromised is the finding kind for a certificate a server presents that was signed by one of the compromised keys.

type Skip

type Skip struct {
	Path   string
	Reason string
}

Skip records content that was recognised but could not be checked.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL