projectdiscovery/nuclei · error

case-insensitive flag is supported only for 'word' matchers

Error message

case-insensitive flag is supported only for 'word' matchers (not '%s')

What it means

Template compilation error from Matcher.CompileMatchers (pkg/operators/matchers/compile.go:94). `case-insensitive: true` is only implemented for `type: word` matchers (words are lowercased at compile time); on any other matcher type it is rejected rather than ignored, so the author does not mistakenly believe the flag applies.

Source

Thrown at pkg/operators/matchers/compile.go:94

			return &dsl.CompilationError{DslSignature: dslExpression, WrappedError: err}
		}
		_ = cache.DSL().Set(dslExpression, compiledExpression)
		matcher.dslCompiled = append(matcher.dslCompiled, compiledExpression)
	}

	// Set up the condition type, if any.
	if matcher.Condition != "" {
		matcher.condition, ok = ConditionTypes[matcher.Condition]
		if !ok {
			return fmt.Errorf("unknown condition specified: %s", matcher.Condition)
		}
	} else {
		matcher.condition = ORCondition
	}

	if matcher.CaseInsensitive {
		if matcher.GetType() != WordsMatcher {
			return fmt.Errorf("case-insensitive flag is supported only for 'word' matchers (not '%s')", matcher.Type)
		}
		for i := range matcher.Words {
			matcher.Words[i] = strings.ToLower(matcher.Words[i])
		}
	}
	return nil
}

// GetType returns the condition type of the matcher
// todo: the field should be exposed natively
func (matcher *Matcher) GetCondition() ConditionType {
	return matcher.condition
}

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. For regex matchers, use the inline RE2 flag: '(?i)pattern'
  2. For DSL matchers, normalize with to_lower(...) on both sides
  3. Restrict `case-insensitive: true` to word matchers only
  4. Validate with `nuclei -validate -t template.yaml`

Example fix

# before
matchers:
  - type: regex
    case-insensitive: true
    regex:
      - 'Apache/2\.4'
# after
matchers:
  - type: regex
    regex:
      - '(?i)apache/2\.4'
Defensive patterns

Strategy: validation

Validate before calling

if m.CaseInsensitive && m.GetType() != ma.WordsMatcher {
	return fmt.Errorf("case-insensitive only valid on word matchers, got %v", m.Type)
}

Type guard

func matcherAllowsCaseInsensitive(t string) bool { return strings.ToLower(strings.TrimSpace(t)) == "word" }

Try / catch

if err := m.CompileMatchers(); err != nil && strings.Contains(err.Error(), "case-insensitive flag is supported only for 'word' matchers") {
	// convert to (?i) regex or to_lower() DSL and recompile
}

Prevention

When it happens

Trigger: A matcher with `type: regex`/`binary`/`dsl`/`status`/`size`/`xpath` that also sets `case-insensitive: true`.

Common situations: Copy-pasting a word matcher and switching only the type; attempting case-insensitive regex matching via the flag instead of '(?i)'.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/8ea69a70bab8d8c1. Report an issue: GitHub.