{"record":{"id":"87967c733a7ece52","repo":"projectdiscovery/nuclei","slug":"invalid-goexec-method-arguments","errorCode":null,"errorMessage":"invalid goexec method arguments","messagePattern":"invalid goexec method arguments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/libs/goexec/errors.go","lineNumber":16,"sourceCode":"package goexec\n\nimport \"errors\"\n\nvar (\n\tErrMissingAuth             = errors.New(\"goexec auth is required\")\n\tErrMissingUsername         = errors.New(\"goexec username is required for this auth mode\")\n\tErrMultipleCredentialModes = errors.New(\"goexec auth selects multiple primary credential modes\")\n\tErrMissingTarget           = errors.New(\"goexec target is required\")\n\tErrMissingCommand          = errors.New(\"goexec command is required\")\n\tErrMissingExecutable       = errors.New(\"goexec executable is required\")\n\tErrUnsupportedModule       = errors.New(\"unsupported goexec module\")\n\tErrUnsupportedMethod       = errors.New(\"unsupported goexec method\")\n\tErrUnsupportedOutputMethod = errors.New(\"unsupported goexec output method\")\n\tErrNetworkPolicyDenied     = errors.New(\"target denied by network policy\")\n\tErrInvalidMethodArguments  = errors.New(\"invalid goexec method arguments\")\n\tErrDomainControllerDenied  = errors.New(\"domain controller denied by network policy\")\n\tErrProxyDenied             = errors.New(\"proxy denied by network policy\")\n\tErrEndpointDenied          = errors.New(\"endpoint denied by network policy\")\n)\n","sourceCodeStart":1,"sourceCodeEnd":21,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/goexec/errors.go#L1-L21","documentation":"Sentinel error from the goexec helper, raised only on the wmi module's 'call' branch. Two conditions produce it (adapter_goexec.go:109-128): (a) method-args is non-empty but fails json.Unmarshal, in which case the sentinel is wrapped with the underlying JSON error via fmt.Errorf(\"%w: %w\"); (b) the WMI class-name or method-name field is empty.","triggerScenarios":"goexec call with method-args: '{bad json'; goexec call with class-name or method-name omitted or left as an empty string.","commonSituations":"Hand-written JSON in method-args with a trailing comma or single quotes; template fills class-name from an extractor that returned empty; author assumes method-name is optional.","solutions":["Fix the method-args JSON so it unmarshals into map[string]any (double quotes, no trailing commas)","Always provide non-empty class-name and method-name when using the wmi call method","If args are unnecessary, leave method-args empty rather than passing malformed JSON"],"exampleFix":"// before\n{module: 'wmi', method: 'call', 'method-args': '{Query: \"SELECT * FROM Win32_Process\"}'}\n// after\n{module: 'wmi', method: 'call', 'class-name': 'Win32_Process', 'method-name': 'Create', 'method-args': '{CommandLine: \"whoami\"}'}","handlingStrategy":"validation","validationCode":"if req.Method == \"call\" {\n    if req.ClassName == \"\" || req.MethodName == \"\" {\n        return errors.New(\"wmi call needs class-name and method-name\")\n    }\n    if req.MethodArgsJSON != \"\" {\n        if !json.Valid([]byte(req.MethodArgsJSON)) {\n            return errors.New(\"method-args is not valid JSON\")\n        }\n    }\n}","typeGuard":"func isInvalidMethodArguments(err error) bool { return errors.Is(err, goexec.ErrInvalidMethodArguments) }","tryCatchPattern":null,"preventionTips":["Generate method-args with a JSON encoder instead of string concatenation","Assert extractors returned non-empty before feeding class-name/method-name"],"tags":["goexec","wmi","json","validation"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}