{"record":{"id":"ffb8f9c226aa31d3","repo":"projectdiscovery/nuclei","slug":"mount-share-q-w","errorCode":null,"errorMessage":"mount share %q: %w","messagePattern":"mount share %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/libs/smbsession/session.go","lineNumber":193,"sourceCode":"// ListTree walks share directories up to maxDepth / maxEntries.\nfunc (s *Session) ListTree(share, root string, maxDepth, maxEntries int) ([]Entry, error) {\n\tops := s.ops()\n\tif ops == nil {\n\t\treturn nil, fmt.Errorf(\"smb session not connected\")\n\t}\n\treturn listTree(ops, share, root, maxDepth, maxEntries)\n}\n\nfunc listDir(ops shareBackend, share, dir string) ([]Entry, error) {\n\tif err := RequireShareName(share); err != nil {\n\t\treturn nil, err\n\t}\n\tnormalized, err := NormalizeSharePath(dir)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif err := ops.UseShare(share); err != nil {\n\t\treturn nil, fmt.Errorf(\"mount share %q: %w\", share, err)\n\t}\n\tinfos, err := ops.Ls(normalized)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tout := make([]Entry, 0, len(infos))\n\tfor _, fi := range infos {\n\t\tname := fi.Name()\n\t\tif name == \".\" || name == \"..\" {\n\t\t\tcontinue\n\t\t}\n\t\tout = append(out, fileInfoToEntry(fi))\n\t}\n\treturn out, nil\n}\n\nfunc readFile(ops shareBackend, share, filePath string, maxBytes int64) (string, error) {\n\tif err := RequireShareName(share); err != nil {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/smbsession/session.go#L175-L211","documentation":"Returned by listDir in the smbsession library when ops.UseShare(share) fails while mounting the SMB share (tree connect). The share name passed RequireShareName's syntax check, but the server refused to connect the client to that share — typically because it does not exist or the authenticated user lacks access. The underlying SMB error is wrapped with the share name for context.","triggerScenarios":"Passing a share name that does not exist on the server (e.g. 'D$' on a host with no D: drive); connecting with a guest/low-privilege user to an administrative share (C$, ADMIN$); typos like 'c$' vs 'C$' depending on server case handling; shares that are hidden or disabled by the administrator.","commonSituations":"Hardcoded share names in templates that assume a default Windows layout; credentials valid for authentication but without rights to the requested share; non-Windows Samba servers where share names are case-sensitive.","solutions":["Enumerate the server's shares first (e.g. ListShares) and use an exact existing name","Verify credentials have permission on the target share; try a normal user share instead of an admin share","Double-check spelling and case of the share name against the server configuration"],"exampleFix":"// before\nconst entries = client.ListTree('D$', '/', 2, 100);\n\n// after\nconst shares = client.ListShares();\n// pick a share that actually exists, then list it\nconst entries = client.ListTree(shares[0].Name, '/', 2, 100);","handlingStrategy":"try-catch","validationCode":"const shares = client.ListShares().map(s => s.Name.toLowerCase());\nif (shares.includes(wantedShare.toLowerCase())) {\n  const entries = client.ListDir(wantedShare, '/');\n}","typeGuard":null,"tryCatchPattern":"try { client.ListDir(share, dir) } catch (e) { if (String(e).startsWith('mount share')) { /* share missing or denied: skip */ } else { throw e; } }","preventionTips":["Enumerate shares before mounting them","Prefer exact share names reported by the server","Prefer non-administrative shares unless creds are admin"],"tags":["smb","javascript","nuclei","permissions"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}