crowdsecurity/crowdsec · error
too many levels of symbolic links
Error message
too many levels of symbolic links
What it means
resolveSymlink walks a path resolving symlinks with an iteration cap; if it exceeds the maximum number of link levels without reaching a real file it returns 'too many levels of symbolic links'. This guards against symlink loops during plugin/hub item installation.
Source
Thrown at pkg/cwhub/path.go:42
if fi.Mode()&os.ModeSymlink == 0 {
// found the target
return cur, nil
}
target, err := os.Readlink(cur)
if err != nil {
return "", err
}
// relative to the link's directory?
if !filepath.IsAbs(target) {
target = filepath.Join(filepath.Dir(cur), target)
}
cur = target
}
return "", errors.New("too many levels of symbolic links")
}
// isPathInside checks if a path is inside the given directory
func isPathInside(path, dir string) (bool, error) {
absFile, err := filepath.Abs(path)
if err != nil {
return false, err
}
absDir, err := filepath.Abs(dir)
if err != nil {
return false, err
}
rel, err := filepath.Rel(absDir, absFile)
if err != nil {
return false, err
}View on GitHub (pinned to 909b515798)
Solutions
- Find and remove the symlink cycle: 'find /path/to/hub -type l -exec ls -l {} \;' and delete the looping link
- Replace the circular symlink with the real file or a direct path
- Reinstall the affected hub item ('cscli hub item reinstall <item>')
Example fix
// before ln -s /etc/crowdsec/hub/parsers/syslog /etc/crowdsec/hub/parsers/syslog // after ln -s /etc/crowdsec/hub/parsers/syslog/remote_syslog.yaml /etc/crowdsec/hub/parsers/syslog-current
Defensive patterns
Strategy: validation
Validate before calling
// detect symlink loops before installing items
resolved, err := filepath.EvalSymlinks(targetPath)
if err != nil { return fmt.Errorf("bad symlink at %s: %w", targetPath, err) } Type guard
func isSymlinkLoop(p string) bool { _, err := filepath.EvalSymlinks(p); return err != nil } Try / catch
spec, err := cwhub newItemSpec(...)
if err != nil && strings.Contains(err.Error(), "too many levels of symbolic links") {
return fmt.Errorf("symlink loop in hub item path %s", path)
} Prevention
- Never create symlinks pointing at their own parent directory inside hub dirs
- Audit hub directories for circular links after restores or manual edits
- Reinstall items via cscli rather than hand-symlinking
When it happens
Trigger: newItemSpec resolving an item path whose symlink chain loops (A -> B -> A) or is longer than the iteration limit; called during item loading and exercised by TestResolveSymlink_Relative.
Common situations: Hand-made symlink cycles in the hub directory; a user symlinked a data dir onto itself via bind mounts or misconfigured dotfiles; restoring a backup that recreated circular links.
Related errors
- while creating symlink from %s to %s: %w
- unable to symlink scenario '%s' to '%s': %w
- while creating %s: %w
- unable to read index file: %w
- %s is already installed at %s
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/a5d1b4cc092c5c5f.
Report an issue: GitHub.