projectdiscovery/nuclei · error

mount share %q: %w

Error message

mount share %q: %w

What it means

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.

Source

Thrown at pkg/js/libs/smbsession/session.go:193

// ListTree walks share directories up to maxDepth / maxEntries.
func (s *Session) ListTree(share, root string, maxDepth, maxEntries int) ([]Entry, error) {
	ops := s.ops()
	if ops == nil {
		return nil, fmt.Errorf("smb session not connected")
	}
	return listTree(ops, share, root, maxDepth, maxEntries)
}

func listDir(ops shareBackend, share, dir string) ([]Entry, error) {
	if err := RequireShareName(share); err != nil {
		return nil, err
	}
	normalized, err := NormalizeSharePath(dir)
	if err != nil {
		return nil, err
	}
	if err := ops.UseShare(share); err != nil {
		return nil, fmt.Errorf("mount share %q: %w", share, err)
	}
	infos, err := ops.Ls(normalized)
	if err != nil {
		return nil, err
	}
	out := make([]Entry, 0, len(infos))
	for _, fi := range infos {
		name := fi.Name()
		if name == "." || name == ".." {
			continue
		}
		out = append(out, fileInfoToEntry(fi))
	}
	return out, nil
}

func readFile(ops shareBackend, share, filePath string, maxBytes int64) (string, error) {
	if err := RequireShareName(share); err != nil {

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Enumerate the server's shares first (e.g. ListShares) and use an exact existing name
  2. Verify credentials have permission on the target share; try a normal user share instead of an admin share
  3. Double-check spelling and case of the share name against the server configuration

Example fix

// before
const entries = client.ListTree('D$', '/', 2, 100);

// after
const shares = client.ListShares();
// pick a share that actually exists, then list it
const entries = client.ListTree(shares[0].Name, '/', 2, 100);
Defensive patterns

Strategy: try-catch

Validate before calling

const shares = client.ListShares().map(s => s.Name.toLowerCase());
if (shares.includes(wantedShare.toLowerCase())) {
  const entries = client.ListDir(wantedShare, '/');
}

Try / catch

try { client.ListDir(share, dir) } catch (e) { if (String(e).startsWith('mount share')) { /* share missing or denied: skip */ } else { throw e; } }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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