projectdiscovery/nuclei · warning
tree listing exceeded max entries (%d)
Error message
tree listing exceeded max entries (%d)
What it means
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.
Source
Thrown at pkg/js/libs/smbsession/session.go:277
if maxDepth <= 0 {
maxDepth = DefaultMaxTreeDepth
}
if maxEntries <= 0 {
maxEntries = DefaultMaxTreeEntries
}
normalized, err := NormalizeSharePath(root)
if err != nil {
return nil, err
}
if err := ops.UseShare(share); err != nil {
return nil, fmt.Errorf("mount share %q: %w", share, err)
}
var out []Entry
var walk func(rel string, depth int) error
walk = func(rel string, depth int) error {
if len(out) >= maxEntries {
return fmt.Errorf("tree listing exceeded max entries (%d)", maxEntries)
}
infos, err := ops.Ls(rel)
if err != nil {
return err
}
for _, fi := range infos {
name := fi.Name()
if name == "." || name == ".." {
continue
}
childRel := name
if rel != "." && rel != "" {
childRel = path.Join(rel, name)
}
entry := fileInfoToEntry(fi)
entry.Name = childRel
out = append(out, entry)
if len(out) >= maxEntries {View on GitHub (pinned to 265b3a3dec)
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
Example fix
// before
const tree = client.ListTree('C$', '/', 4, 0); // default 1024 entries
// after
const tree = client.ListTree('C$', '/inetpub', 4, 10000); Defensive patterns
Strategy: fallback
Validate before calling
// size the budget before walking: default cap is 1024 entries
client.ListTree('pub', '/', 8, 8192); Try / catch
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; } } Prevention
- Pass explicit maxEntries proportional to the share size
- Walk narrow roots, not '/'
- Design logic to accept truncated listings
When it happens
Trigger: 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).
Common situations: Templates enumerating whole shares for keyword searches; CIFS shares with huge directory counts hitting the 1024 default cap mid-walk.
Related errors
- file %q exceeds max read size of %d bytes
- mount share %q: %w
- file path cannot be empty
- smb connect: %w
- dialers not initialized for %s
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/202815aa4e90343a.
Report an issue: GitHub.