alibaba/nacos · critical · SecurityException

Absolute path not allowed: {path}

Error message

Absolute path not allowed: {path}

What it means

Thrown by SkillUtils.validatePathSafety as a SecurityException when the supplied path starts with '/' or '\\'. The method is a hard security gate used to validate ZIP entry names and skill resource paths before they are written to disk, blocking absolute paths that could write outside the intended skill directory.

Source

Thrown at api/src/main/java/com/alibaba/nacos/api/ai/model/skills/SkillUtils.java:176

        validatePathSafety(entryPath);
        return entryPath;
    }
    
    /**
     * Validate that a path does not contain path traversal sequences or absolute path indicators.
     *
     * @param path the path to validate
     * @throws SecurityException if path contains unsafe sequences
     */
    public static void validatePathSafety(String path) {
        if (path == null) {
            return;
        }
        if (path.contains(PATH_TRAVERSAL_SEQUENCE)) {
            throw new SecurityException("Path traversal detected: " + path);
        }
        if (path.startsWith("/") || path.startsWith("\\")) {
            throw new SecurityException("Absolute path not allowed: " + path);
        }
    }
    
    /**
     * Validate that a resolved path stays within the expected base directory.
     *
     * @param baseDir the base directory that must contain the target
     * @param target  the resolved target path
     * @throws SecurityException if target escapes baseDir
     */
    public static void validatePathContainment(Path baseDir, Path target) {
        if (!target.normalize().startsWith(baseDir.normalize())) {
            throw new SecurityException(
                "Path escapes target directory: " + target + " is outside " + baseDir);
        }
    }
    
    /**

View on GitHub (pinned to 9b989acdf1)

Solutions

  1. Strip leading '/' or '\\' from the path/entry name before calling validatePathSafety or before creating the ZIP.
  2. If you control the ZIP producer, use relative entry names only (e.g. 'skillName/SKILL.md', never '/skillName/SKILL.md').
  3. Reject the offending skill bundle at the source and re-export it with relative paths.

Example fix

// before
String entryPath = "/skillName/SKILL.md";
SkillUtils.validatePathSafety(entryPath); // throws

// after
String entryPath = "skillName/SKILL.md";
SkillUtils.validatePathSafety(entryPath); // ok
Defensive patterns

Strategy: validation

Validate before calling

// Sanitize before calling validatePathSafety
static String safeRelative(String path) {
    if (path == null) return null;
    String p = path;
    while (p.startsWith("/") || p.startsWith("\\")) p = p.substring(1);
    if (p.contains("..")) throw new IllegalArgumentException("Refusing unsafe path: " + path);
    return p;
}
String clean = safeRelative(entryPath);
SkillUtils.validatePathSafety(clean);

Type guard

static boolean isSafeRelativePath(String p) {
    return p != null && !p.startsWith("/") && !p.startsWith("\\") && !p.contains("..");
}

Try / catch

try {
    SkillUtils.validatePathSafety(entryPath);
} catch (SecurityException e) {
    log.warn("Rejecting unsafe entry path: {}", entryPath);
    throw e;
}

Prevention

When it happens

Trigger: Calling SkillUtils.validatePathSafety(path) where path begins with a forward slash or backslash, or feeding validateZipEntryPaths a ZIP whose entry name is absolute (e.g. "/etc/passwd" or "\\windows\\system32").

Common situations: A skill bundle downloaded from the server contains a malicious or malformed entry with an absolute name; a client constructs a SkillResource whose path field was accidentally prefixed with '/'; a ZIP built by a third-party tool stored entries with leading slashes.

Related errors


AI-assisted analysis of alibaba/nacos@9b989acdf1 (2026-08-14). Data as JSON: /api/errors/bc757e8b0ad1d95f. Report an issue: GitHub.