projectdiscovery/nuclei · warning

share name cannot be empty

Error message

share name cannot be empty

What it means

RequireShareName is the first check smbsession helpers run on the share argument. After trimming whitespace, an empty share name is rejected because there is no share to mount (UseShare would fail deeper in the stack with a less clear error). This is purely caller-side input validation.

Source

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

	if strings.ContainsRune(p, 0) {
		return "", fmt.Errorf("share path contains NUL")
	}
	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. Pass a concrete share name such as 'C$', 'IPC$', or 'NETLOGON'
  2. Default the share when the input variable is empty before calling
  3. Filter empty entries out of share lists before iterating

Example fix

// before
let share = '';
s.ListDir(share, 'Windows'); // share name cannot be empty

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

Strategy: validation

Validate before calling

share = strings.TrimSpace(share)
if share == "" { return errors.New("share required") }

Type guard

func validShareName(s string) bool { return strings.TrimSpace(s) != "" }

Try / catch

if err := smbsession.RequireShareName(share); err != nil {
    share = "C$" // sensible default
    if err = smbsession.RequireShareName(share); err != nil { return err }
}

Prevention

When it happens

Trigger: Calling s.ListDir('', 'dir'), s.ReadFile(' ', 'file', 0), or passing a template variable for the share that resolved to an empty string.

Common situations: Optional template inputs interpolated into the share slot; destructuring that misses the share field; iterating over a share list where one entry is blank.

Related errors


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