projectdiscovery/nuclei · warning

share name must not contain path separators: %q

Error message

share name must not contain path separators: %q

What it means

RequireShareName rejects share arguments containing '/' or '\\'. A share name is a single label (C$, NETLOGON); anything with a separator is a share-plus-path mix that belongs in the path argument. Splitting the arguments correctly instead of cramming both into share is the fix.

Source

Thrown at pkg/js/libs/smbsession/path.go:57

	clean := path.Clean(p)
	clean = strings.TrimPrefix(clean, "/")
	if clean == ".." || strings.HasPrefix(clean, "../") {
		return "", fmt.Errorf("share path escapes share root: %q", p)
	}
	if clean == "." {
		return ".", nil
	}
	return clean, nil
}

// RequireShareName validates a share name (no path separators).
func RequireShareName(share string) error {
	share = strings.TrimSpace(share)
	if share == "" {
		return fmt.Errorf("share name cannot be empty")
	}
	if strings.ContainsAny(share, `/\`) {
		return fmt.Errorf("share name must not contain path separators: %q", share)
	}
	if strings.ContainsRune(share, 0) {
		return fmt.Errorf("share name contains NUL")
	}
	return nil
}

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Split the string: share 'C$', path 'Windows/temp', instead of 'C$/Windows'
  2. For UNC inputs, parse scheme-free: smb://host/share/path maps to Dial(host) + ListDir('share','path')
  3. Validate share names contain no separators before the call when building from user input

Example fix

// before
s.ListDir('C$/Windows', '.'); // share name must not contain path separators

// after
s.ListDir('C$', 'Windows');
Defensive patterns

Strategy: validation

Validate before calling

if strings.ContainsAny(share, "/\\") {
    return errors.New("split share and path into separate arguments")
}

Type guard

func isBareShareName(s string) bool {
    return !strings.ContainsAny(s, "/\\") && strings.TrimSpace(s) != ""
}

Try / catch

if err := smbsession.RequireShareName(share); err != nil {
    if strings.ContainsAny(share, "/\\") {
        i := strings.IndexAny(share, "/\\")
        share, rel = share[:i], share[i+1:] // split and retry with both args
    }
}

Prevention

When it happens

Trigger: Calling s.ListDir('C$/Windows', '.') or s.ReadFile('\\\\dc01\\C$\\file.txt', '', 0) — paths pasted whole into the share parameter.

Common situations: UNC strings copied from Windows Explorer into templates; the share/path split forgotten when porting a script that used smbclient-style URIs.

Related errors


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