{"record":{"id":"202815aa4e90343a","repo":"projectdiscovery/nuclei","slug":"tree-listing-exceeded-max-entries-d","errorCode":null,"errorMessage":"tree listing exceeded max entries (%d)","messagePattern":"tree listing exceeded max entries \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"pkg/js/libs/smbsession/session.go","lineNumber":277,"sourceCode":"\tif maxDepth <= 0 {\n\t\tmaxDepth = DefaultMaxTreeDepth\n\t}\n\tif maxEntries <= 0 {\n\t\tmaxEntries = DefaultMaxTreeEntries\n\t}\n\tnormalized, err := NormalizeSharePath(root)\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\n\tvar out []Entry\n\tvar walk func(rel string, depth int) error\n\twalk = func(rel string, depth int) error {\n\t\tif len(out) >= maxEntries {\n\t\t\treturn fmt.Errorf(\"tree listing exceeded max entries (%d)\", maxEntries)\n\t\t}\n\t\tinfos, err := ops.Ls(rel)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tfor _, fi := range infos {\n\t\t\tname := fi.Name()\n\t\t\tif name == \".\" || name == \"..\" {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tchildRel := name\n\t\t\tif rel != \".\" && rel != \"\" {\n\t\t\t\tchildRel = path.Join(rel, name)\n\t\t\t}\n\t\t\tentry := fileInfoToEntry(fi)\n\t\t\tentry.Name = childRel\n\t\t\tout = append(out, entry)\n\t\t\tif len(out) >= maxEntries {","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/libs/smbsession/session.go#L259-L295","documentation":"Thrown by the recursive walk in listTree when the entry budget is reached: before listing any directory, walk() checks len(out) >= maxEntries and aborts once the accumulated entry count equals the cap. maxEntries defaults to DefaultMaxTreeEntries (1024) when the caller passes 0 or a negative value. Note that on this error listTree returns the entries collected so far alongside the error, so partial results are available.","triggerScenarios":"Walking a deep/wide share root (e.g. '/') with defaults on a file server with thousands of entries; passing a small explicit maxEntries like 50 for a busy directory; recursive trees where breadth multiplies fast (maxDepth defaults to 8).","commonSituations":"Templates enumerating whole shares for keyword searches; CIFS shares with huge directory counts hitting the 1024 default cap mid-walk.","solutions":["Pass a larger explicit maxEntries (fourth ListTree argument) sized to the target share","Narrow the root to a specific subdirectory instead of walking from '/'","Use the partial entries returned with the error when completeness is not required"],"exampleFix":"// before\nconst tree = client.ListTree('C$', '/', 4, 0); // default 1024 entries\n\n// after\nconst tree = client.ListTree('C$', '/inetpub', 4, 10000);","handlingStrategy":"fallback","validationCode":"// size the budget before walking: default cap is 1024 entries\nclient.ListTree('pub', '/', 8, 8192);","typeGuard":null,"tryCatchPattern":"let tree; try { tree = client.ListTree(s, '/', d, cap); } catch (e) { if (String(e).includes('max entries')) { /* partial tree returned with error: use it */ } else { throw e; } }","preventionTips":["Pass explicit maxEntries proportional to the share size","Walk narrow roots, not '/'","Design logic to accept truncated listings"],"tags":["smb","javascript","nuclei","resource-limits"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}