[BUG] OpenAPI input panics on an application/xml request body without an object schema
Is there an existing issue for this?
- I have searched the existing issues.
Current Behavior
Nuclei panics while loading an OpenAPI spec with -im openapi if an operation has an application/xml request body with no schema. A string or array schema on the XML body panics the same way. The XML branch at generator.go:294 assumes the example is a map and doesn't check.
There's a second problem when a body has no schema. The empty schema from generateEmptySchemaValue gets used as the example value itself, so a schema-less application/json body goes out as {"type":"object"}, and a schema-less text/plain or application/octet-stream body as a Go dump of the schema struct.
Expected Behavior
The spec loads and each body gets an example built from its schema. For a body with no schema that means the <?xml version="1.0"?><root/> that generateEmptySchemaValue already sets for XML, and {} for JSON.
Steps To Reproduce
- Save this as
spec.yaml:
openapi: 3.0.0
info: {title: t, version: "1"}
servers: [{url: "http://127.0.0.1:9"}]
paths:
/items:
post:
requestBody:
content:
application/xml: {}
responses:
"200": {description: ok}- Run
nuclei -im openapi -l spec.yaml -t probe.yamlwith any http template asprobe.yaml. It panics while parsing the spec, before any request goes out.
Relevant log output
panic: interface conversion: interface {} is *openapi3.Schema, not map[string]interface {}
goroutine 1 [running]:
github.com/projectdiscovery/nuclei/v3/pkg/input/formats/openapi.generateRequestsFromOp(...)
pkg/input/formats/openapi/generator.go:294 +0x2138
github.com/projectdiscovery/nuclei/v3/pkg/input/formats/openapi.GenerateRequestsFromSchema(...)
pkg/input/formats/openapi/generator.go:95 +0x738
github.com/projectdiscovery/nuclei/v3/pkg/input/formats/openapi.(*OpenAPIFormat).Parse(...)
pkg/input/formats/openapi/openapi.go:40 +0xb0
github.com/projectdiscovery/nuclei/v3/pkg/input/provider/http.NewHttpInputProvider(...)
pkg/input/provider/http/multiformat.go:89 +0x370Environment
- OS: macOS 27 (arm64)
- Nuclei: v3.11.1, built from dev at c5611b9a
- Go: go1.27.1
Anything else?
I have a fix with a test ready and I'll open a PR against dev.
Source: projectdiscovery/nuclei