JuliusBrussee/caveman · error

dot segments are not allowed in path

Error message

dot segments are not allowed in path

What it means

Path hardening in validatePathComponents: a . or .. segment appears in the path. Dot segments could resolve to a different route after normalization, so they are rejected outright.

Source

Thrown at proxy/providers/openaicompat/openaicompat.go:322

		return nil
	}
	if err := validatePathComponents(path, rawPath); err != nil {
		return fmt.Errorf("compat route path rejected: %w", err)
	}
	return nil
}

func validatePathComponents(path, rawPath string) error {
	if strings.Contains(path, `\`) {
		return fmt.Errorf("backslash is not allowed in path")
	}
	segments := strings.Split(path, "/")
	for i, segment := range segments {
		if segment == "" && i > 0 && i < len(segments)-1 {
			return fmt.Errorf("repeated path separators are not allowed")
		}
		if segment == "." || segment == ".." {
			return fmt.Errorf("dot segments are not allowed in path")
		}
	}
	// URL.Path is decoded by net/url while RawPath retains a valid escaped
	// spelling. Reject separators, backslashes, and dot bytes in either form so
	// a path cannot change route identity after another decoder or proxy hop.
	for _, escape := range []string{"%2f", "%5c", "%2e"} {
		if strings.Contains(strings.ToLower(path), escape) || strings.Contains(strings.ToLower(rawPath), escape) {
			return fmt.Errorf("ambiguous escaped path sequence %s", escape)
		}
	}
	return nil
}

func parseBaseURL(raw, provider string) (*url.URL, error) {
	if strings.TrimSpace(raw) == "" {
		return nil, fmt.Errorf("provider %q has no configured upstream URL", provider)
	}
	u, err := url.Parse(strings.TrimSpace(raw))

View on GitHub (pinned to 5184b3d11a)

Solutions

  1. Send fully resolved paths without . or .. segments
  2. Pre-normalize the URL client-side before requesting
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at proxy/providers/openaicompat/openaicompat.go:279 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of JuliusBrussee/caveman@5184b3d11a (2026-08-18). Data as JSON: /api/errors/9cbfe6c55e4457cc. Report an issue: GitHub.