owasp-amass/amass · error

failed to extract the IPAddress asset

Error message

failed to extract the IPAddress asset

What it means

The ip/netblock plugin's lookup() asserts e.Entity.Asset to *oamnet.IPAddress to process IP-based events. If the asset is any other type the assertion fails and this error is returned. The plugin's event subscription delivered a non-IP entity into the handler.

Source

Thrown at engine/plugins/ip_netblock.go:73

		EventType:    oam.IPAddress,
		Callback:     d.lookup,
	}); err != nil {
		d.log.Error(fmt.Sprintf("Failed to register a handler: %v", err), "handler", name)
		return err
	}

	d.log.Info("Plugin started")
	return nil
}

func (d *ipNetblock) Stop() {
	d.log.Info("Plugin stopped")
}

func (d *ipNetblock) lookup(e *et.Event) error {
	ip, ok := e.Entity.Asset.(*oamnet.IPAddress)
	if !ok {
		return errors.New("failed to extract the IPAddress asset")
	}

	if reserved, cidr := amassnet.IsReservedAddress(ip.Address.String()); reserved {
		prefix, err := netip.ParsePrefix(cidr)
		if err != nil {
			return nil
		}

		netblock := &oamnet.Netblock{
			Type: "IPv4",
			CIDR: prefix,
		}
		if prefix.Addr().Is6() {
			netblock.Type = "IPv6"
		}

		d.reservedAS(e, netblock)
		return nil

View on GitHub (pinned to 79299dce87)

Solutions

  1. In lookup/check, return nil instead of an error when the asset is not *oamnet.IPAddress so mismatched events are ignored
  2. Tighten the event subscription filter so only IPAddress events reach lookup
  3. Confirm upstream emitters set Asset to *oamnet.IPAddress for IP events

Example fix

// before
ip, ok := e.Entity.Asset.(*oamnet.IPAddress)
if !ok {
	return errors.New("failed to extract the IPAddress asset")
}

// after
ip, ok := e.Entity.Asset.(*oamnet.IPAddress)
if !ok {
	return nil
}
Defensive patterns

Strategy: type-guard

Validate before calling

if _, ok := e.Entity.Asset.(*oamnet.IPAddress); !ok {
	return nil
}

Type guard

func asIPAddress(e *et.Event) (*oamnet.IPAddress, bool) {
	ip, ok := e.Entity.Asset.(*oamnet.IPAddress)
	return ip, ok
}

Try / catch

if err := d.lookup(ev); err != nil {
	if strings.Contains(err.Error(), "failed to extract the IPAddress") {
		continue // not an IP event
	}
	log.Error(err)
}

Prevention

When it happens

Trigger: check() subscribes to events where the asset is not *oamnet.IPAddress (e.g. Netblock or FQDN assets) and passes them to lookup.

Common situations: Subscribing to broad event topics that include multiple asset types; custom data sources emitting IP-like data with a different asset struct; refactors renaming the asset type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/079432de003dfbad. Report an issue: GitHub.