projectdiscovery/nuclei · error
invalid payload type only types defined in ikev module like
Error message
invalid payload type only types defined in ikev module like IKENotification, IKENonce, etc. are allowed
What it means
IKEMessage.AppendPayload only accepts values implementing the IKEPayload interface, i.e. payload structs exported by the ikev2 module itself (IKENotification, IKENonce, IKESAProposal, and similar). A plain JavaScript object literal or primitive does not satisfy the Go interface, so the call is rejected before anything is appended.
Source
Thrown at pkg/js/libs/ikev2/ikev2.go:41
ExchangeType uint8
Flags uint8
payloads []IKEPayload
}
)
// AppendPayload appends a payload to the IKE message
// payload can be any of the payloads like IKENotification, IKENonce, etc.
// @example
// ```javascript
// const ikev2 = require('nuclei/ikev2');
// const message = new ikev2.IKEMessage();
// const nonce = new ikev2.IKENonce();
// nonce.NonceData = [1, 2, 3];
// message.AppendPayload(nonce);
// ```
func (m *IKEMessage) AppendPayload(payload any) error {
if _, ok := payload.(IKEPayload); !ok {
return fmt.Errorf("invalid payload type only types defined in ikev module like IKENotification, IKENonce, etc. are allowed")
}
m.payloads = append(m.payloads, payload.(IKEPayload))
return nil
}
// Encode encodes the final IKE message
// @example
// ```javascript
// const ikev2 = require('nuclei/ikev2');
// const message = new ikev2.IKEMessage();
// const nonce = new ikev2.IKENonce();
// nonce.NonceData = [1, 2, 3];
// message.AppendPayload(nonce);
// log(message.Encode());
// ```
func (m *IKEMessage) Encode() ([]byte, error) {
var payloads message.IKEPayloadContainer
for _, payload := range m.payloads {View on GitHub (pinned to 265b3a3dec)
Solutions
- Construct payloads with the module constructors: const nonce = new ikev2.IKENonce(); then message.AppendPayload(nonce)
- Map deserialized JSON definitions onto real constructor instances before appending
- Ensure exactly one require('nuclei/ikev2') instance is used so instanceof checks stay consistent
Example fix
// before
message.AppendPayload({NonceData: [1, 2, 3]});
// after
const nonce = new ikev2.IKENonce();
nonce.NonceData = [1, 2, 3];
message.AppendPayload(nonce); Defensive patterns
Strategy: type-guard
Validate before calling
const ikev2 = require('nuclei/ikev2');
const payload = new ikev2.IKENonce();
payload.NonceData = [1, 2, 3];
message.AppendPayload(payload); Type guard
function isIKEPayload(p) {
return [ikev2.IKENotification, ikev2.IKENonce, ikev2.IKESAProposal].some(
(ctor) => p instanceof ctor
);
} Try / catch
try {
message.AppendPayload(payload);
} catch (e) {
// payload was not built by an ikev2 constructor; rebuild it with new ikev2.IKENonce() etc.
} Prevention
- Always build payloads with ikev2 constructors, never object literals
- Keep a single require('nuclei/ikev2') reference so instanceof checks are meaningful
When it happens
Trigger: message.AppendPayload({PayloadType: 40, NotificationData: [1,2,3]}) constructing a literal instead of using a constructor; passing null or a string; passing a payload struct obtained from a different require() of the module.
Common situations: Developers porting Python/Scapy IKE scripts where payloads are dicts; JSON-driven templates that deserialize payload definitions and pass them directly; forgetting the 'new' keyword.
Related errors
- panic: %s
- nuclei js runtime: program failed to terminate after interru
- smb connect: %w
- invalid goexec method arguments: %w
- parse target: %w
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/7a0f9f53a774a8c9.
Report an issue: GitHub.