{"record":{"id":"95472b4bda5b70a8","repo":"projectdiscovery/nuclei","slug":"share-name-must-not-contain-path-separators-q","errorCode":null,"errorMessage":"share name must not contain path separators: %q","messagePattern":"share name must not contain path separators: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/js/libs/smbsession/path.go","lineNumber":57,"sourceCode":"\tclean := path.Clean(p)\n\tclean = strings.TrimPrefix(clean, \"/\")\n\tif clean == \"..\" || strings.HasPrefix(clean, \"../\") {\n\t\treturn \"\", fmt.Errorf(\"share path escapes share root: %q\", p)\n\t}\n\tif clean == \".\" {\n\t\treturn \".\", nil\n\t}\n\treturn clean, nil\n}\n\n// RequireShareName validates a share name (no path separators).\nfunc RequireShareName(share string) error {\n\tshare = strings.TrimSpace(share)\n\tif share == \"\" {\n\t\treturn fmt.Errorf(\"share name cannot be empty\")\n\t}\n\tif strings.ContainsAny(share, `/\\`) {\n\t\treturn fmt.Errorf(\"share name must not contain path separators: %q\", share)\n\t}\n\tif strings.ContainsRune(share, 0) {\n\t\treturn fmt.Errorf(\"share name contains NUL\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":39,"sourceCodeEnd":64,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/smbsession/path.go#L39-L64","documentation":"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.","triggerScenarios":"Calling s.ListDir('C$/Windows', '.') or s.ReadFile('\\\\\\\\dc01\\\\C$\\\\file.txt', '', 0) — paths pasted whole into the share parameter.","commonSituations":"UNC strings copied from Windows Explorer into templates; the share/path split forgotten when porting a script that used smbclient-style URIs.","solutions":["Split the string: share 'C$', path 'Windows/temp', instead of 'C$/Windows'","For UNC inputs, parse scheme-free: smb://host/share/path maps to Dial(host) + ListDir('share','path')","Validate share names contain no separators before the call when building from user input"],"exampleFix":"// before\ns.ListDir('C$/Windows', '.'); // share name must not contain path separators\n\n// after\ns.ListDir('C$', 'Windows');","handlingStrategy":"validation","validationCode":"if strings.ContainsAny(share, \"/\\\\\") {\n    return errors.New(\"split share and path into separate arguments\")\n}","typeGuard":"func isBareShareName(s string) bool {\n    return !strings.ContainsAny(s, \"/\\\\\") && strings.TrimSpace(s) != \"\"\n}","tryCatchPattern":"if err := smbsession.RequireShareName(share); err != nil {\n    if strings.ContainsAny(share, \"/\\\\\") {\n        i := strings.IndexAny(share, \"/\\\\\")\n        share, rel = share[:i], share[i+1:] // split and retry with both args\n    }\n}","preventionTips":["Always pass share and path as two separate arguments","Parse UNC/smb:// URIs into (host, share, path) before calling","Validate share names as single labels at input boundaries"],"tags":["validation","input","smb","path"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}