Repository navigation
Fix crashes, hangs and logic bugs found in the v5 engine and plugins - #1
Open
The-Inceptions wants to merge 22 commits into
Open
The-Inceptions wants to merge 22 commits into
The-Inceptions wants to merge 22 commits into
Conversation
sessSemaphore.Acquire held its mutex while blocking on the channel semaphore, and Release needed the same mutex to return a token. Once a session reached its connection limit, every network plugin in that session hung forever. Replace the channel and mutex with a counter and a sync.Cond that is resized in place, so waiters are never stranded on a replaced channel. This also removes a divide-by-zero when NumOfSessions() returns 0 and a permanent hang when more than MaxNetworkConns sessions exist. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Three problems in the pubsub logger combined into a process crash: Publish read the subscriber list without the lock, a full subscriber channel made msgToSubscribers spawn a goroutine that blocked forever, and there was no way to unsubscribe. Once a WebSocket log client disconnected, every log line leaked a goroutine, and when the session ended Close closed the channels under those goroutines, which then panicked with "send on closed channel". The logger now keeps subscribers in a map guarded by its lock, sends without blocking and drops a message for a subscriber that has fallen 1000 messages behind, supports Unsubscribe, and can be closed more than once. The WebSocket handler reads from the connection so pong and close frames are processed, and unsubscribes and closes the connection when the client goes away. Session.Kill also closed its done channel after a non-atomic check, so two concurrent CancelSession calls could close it twice and panic. It now uses sync.Once. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateAsset returns a nil entity with its error, but PutAsset returned entity.ID on that path. PutAssets calls PutAsset from a bare goroutine, so a failed database write during bulk ingest crashed the engine. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The IPVerse handler runs up to 16 instances at once, but it read and wrote its ASN map without synchronization. Concurrent map access is a fatal error in Go, so a scan that found several autonomous systems at the same time could crash the process. Claim the ASN under a mutex before querying, and release the claim if the query fails so a later event can retry it. This also stops concurrent events for the same ASN from sending duplicate requests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…dresses The RDAP netblock and autnum handlers threw away the whole record when the response had no parsable "registration" or "last changed" event, so no IPNetRecord or AutnumRecord was stored and the follow-up handlers never ran for that netblock or ASN. The dates are now set when present and left empty otherwise; asset-db accepts empty dates. The netblock handler also used netip.MustParseAddr on the response's start and end addresses, which panicked on a malformed response. It now skips the record instead. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
matchesOrg and matchesLocation compared a 0-1 similarity score against
a 0-100 confidence, so with any real confidence setting only exact
names ever matched. The fuzzy path only ran when the confidence was 1
or lower (for example, no transformation configured for the type), and
then it accepted almost any name at confidence 0 or 1.
Rather than switch fuzzy matching on, remove it. The Smith-Waterman-
Gotoh similarity is normalized by the shorter string, so a name
contained in a longer one scores as a perfect match ("Apple" vs
"Pineapple Inc"), which would let unrelated organizations widen the
scope. Exact matches behave as before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ClaimNext treats ttl <= 0 as "leases never expire", which every session relies on through SetLeaseTTL(0). It was written as a block-scoped `ttl := 30 * time.Second` that shadowed the parameter, which reads like a bug and was reported as one by code review. "Fixing" the shadow would make entities that take longer than 30s to process get dispatched a second time. Express the same behavior with an explicit flag and a named constant, correct the doc comments on ClaimNext, RequeueExpired and SetLeaseTTL, explain the SetLeaseTTL(0) call, and add a test that pins the behavior down. No functional change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RDAP plugin set InsecureSkipVerify on the transport shared by its bootstrap and RDAP clients. Anyone positioned on the network could then feed forged bootstrap data or registration records into the asset graph. RDAP only talks to IANA and the RIRs, which all present valid certificates, so require verification and TLS 1.2 or later, the same change made to amasshttp.DefaultClient in 6488957. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pagination loop was `for lastid != ""` with lastid starting empty, so its body never ran and the plugin returned nothing even with valid credentials. Its `continue` statements would also have retried a failing request forever once the loop did run. Page like the BinaryEdge plugin: the cursor and a 500-page cap are shared across credentials, a failed request moves on to the next credential from the same page, and paging stops when the API returns an empty or unchanged cursor. The request context is now cancelled after each request instead of piling up deferred cancels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The JARM plugin built its fingerprint targets from the Service entity rather than the FQDN or IP address on the other end of the port edge. support.JARMFingerprint only accepts an FQDN or IP address, so every attempt failed and no JARM hash was ever stored. Because the fix turns on real TLS probing that has never run before, the handler now also returns early unless the session is in active mode, as the HTTP probes do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
LoadAndStartPlugins passed its started list to stopPlugins when a plugin failed to start, but never added anything to that list, so the plugins that had already started were left running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crt.sh plugin's source name was copied from the HackerTarget plugin. Source names drive the "last monitored" markers, so crt.sh, which runs first, marked every FQDN as already checked by HackerTarget, and HackerTarget then skipped those names within its TTL. crt.sh results were also attributed to HackerTarget at confidence 100. Existing databases keep the old tags until their TTL runs out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
reservedAS created the AS 0 entity and then added the source property to the netblock a second time instead of to the new AS, so the AS was stored without its source. Only neo4j is affected in practice, since the sqlite and postgres repositories reject AS number 0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The RDAP autsys handler's lookup() only returns a stored AutnumRecord that carries the plugin's source property, but store() only tagged the registration edge, never the record itself. Within the TTL, lookups of an already-stored record always missed, so the record was never dispatched again to the autnum handler's downstream processing. Tag the record the same way the netblock handler tags IPNetRecords. Records stored before this change stay untagged until their TTL runs out and they are stored again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The employees and funding-rounds handlers declared their page counters outside the API-key loop and used `continue` on HTTP failures. The `continue` advanced the page, so a failure on the first key ended the paging and the post-loop check then left the key loop: backup keys were never tried. Break out of the page loop on HTTP failures instead, so the next key retries the same page. The request contexts are now cancelled after each request instead of piling up deferred cancels. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
additions, deletions and substitutions wrote into the label's own rune slice while generating guesses, so every guess after the first was built from an already-modified label. For "abc", deletions produced "bc" three times instead of "bc", "ac" and "ab", and substitutions left earlier positions replaced. additions had the same problem whenever the rune slice had spare capacity, which is the usual case. Alteration-based brute forcing therefore produced fewer and partly wrong guesses. Build each guess in a new slice, and add tests with exact expected output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
CreateOrgAsset normalized the Organization it was given in place, overwriting Name, Jurisdiction and ID. The TXT record handler passes shared structs from its package-level prefixes map, so after the first match "Google LLC" stayed "google" for the rest of the process, and later sessions lost the real display name claim. The unsynchronized read of that shared struct in the TXT handler was also a data race. Normalize a copy instead, which fixes this for every caller. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
When a DomainRecord's registrant organization or location was in scope, processDomainRecord looked up the registered domain's FQDN but then queued the DomainRecord itself. The FQDN handlers (DNS, brute forcing and the rest) therefore never reviewed the newly in-scope domain. Queue the FQDN, as the organization, location and TLS certificate handlers already do. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The fingerprint add/list/match functions and their imports were committed already commented out and are referenced nowhere. Only the Fingerprint type is used. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Many plugins created a timeout context per request inside a paging or API-key loop but released it with `defer cancel()`, so every context and its timer stayed alive until the whole query returned. Call cancel() as soon as the request returns instead; RequestWebPage reads and closes the response body before it returns, so nothing uses the context afterwards. The JARM probe loop had the same problem and also deferred closing each connection, keeping up to ten sockets open per target. It now cancels the dial context right after dialing and closes each connection after its probe, with the probe exchange moved into a small helper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The banner URL handler stored and dispatched every regex match from a service's response body, and pages routinely repeat the same link many times. Skip URLs already seen in the same banner. The key is the full raw URL, since stringset lowercases its keys and would merge URLs whose paths differ only in case. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The organization and location handlers contained the same block, byte for byte, that walks from a contact record to the registration records and TLS certificates it belongs to and expands the scope from them. Move it into one helper on horizPlugin so a fix to one copy can't miss the other. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Summary
Fixes the confirmed findings from an ultrareview of the
master→mainchanges (engine core, plugin framework andplugins/api, and the other plugins), plus a few related bugs found while checking them. There is one commit per fix.Crashes and hangs
Acquireheld a mutex while blocking andReleaseneeded the same mutex, so once a session reached its connection limit every network plugin hung. It is now a resizable counter with async.Cond.Unsubscribeand an idempotentClose. The WebSocket handler reads control frames and unsubscribes when the client goes away.Session.Killnow usessync.Once.PutAssetnil dereference whenCreateAssetfails. Bulk ingest runs it in a bare goroutine, so this crashed the engine.netip.MustParseAddrpanic on malformed responses.Logic bugs
reservedAStagged the netblock twice instead of tagging the AS.CreateOrgAssetrewrote the caller's Organization struct, which the TXT handler shares across calls.Clarity and cleanup
Behavior changes
Not included
ents[0]inPutAssetanddns/subs.go, and thehttp_probeslen(tags)nit.sendElementOnExitleave backlog items leased forever;engine.godoesn't shut down the dispatcher and session manager when plugin loading fails.Test plan
CGO_ENABLED=0 go build ./...andgo vet ./...CGO_ENABLED=0 go test ./...go test -raceonengine/sessions/...,engine/pubsub,engine/plugins/brute,engine/plugins/scrapeandengine/registryamass enumagainst an authorized domain🤖 Generated with Claude Code