projectdiscovery/nuclei · error
could not write to temp secrets file: %w
Error message
could not write to temp secrets file: %w
What it means
The temp file was created but tempFile.Write(secretsData) failed (cmd/nuclei/main.go:913); the file is closed and removed before returning. Write failures on a freshly created temp file are almost always environmental — ENOSPC (disk/tmpfs full), EDQUOT (quota exceeded), or short writes — since permissions were already exercised at create time.
Source
Thrown at cmd/nuclei/main.go:913
}
tempDir := filepath.Join(os.TempDir(), "nuclei-secrets")
if err := os.MkdirAll(tempDir, 0700); err != nil {
return "", fmt.Errorf("could not create temp directory: %w", err)
}
tempFile, err := os.CreateTemp(tempDir, "inline-secrets-*.yaml")
if err != nil {
return "", fmt.Errorf("could not create temp secrets file: %w", err)
}
defer func() {
_ = tempFile.Close()
}()
if _, err := tempFile.Write(secretsData); err != nil {
_ = tempFile.Close()
_ = os.Remove(tempFile.Name())
return "", fmt.Errorf("could not write to temp secrets file: %w", err)
}
options.SecretsFile = append(options.SecretsFile, tempFile.Name())
return tempFile.Name(), nil
}
View on GitHub (pinned to 265b3a3dec)
Solutions
- Free space on the temp filesystem or point TMPDIR at a larger volume
- Check quotas (`quota -s`) if enforced
- Move inline secrets to a standalone secrets file outside the temp path
- Pre-check free space in automation before launching scans
Example fix
# before df -h /tmp # 100% used # after TMPDIR=/data/tmp nuclei -profile scan.yaml
Defensive patterns
Strategy: try-catch
Validate before calling
// pre-flight: verify writable space on the temp filesystem
var st syscall.Statfs_t
if err := syscall.Statfs(tempDir, &st); err == nil && st.Bavail*uint64(st.Bsize) < uint64(len(secretsData))*4 {
return errors.New("insufficient space in temp dir for secrets file")
} Try / catch
if _, err := tempFile.Write(secretsData); err != nil {
_ = os.Remove(tempFile.Name())
return fmt.Errorf("writing secrets to %s failed (disk full/quota?): %w", tempFile.Name(), err)
} Prevention
- Monitor tmpfs/disk usage before large scans
- Point TMPDIR at a volume with headroom
- Prefer external secrets files over temp-file inline secrets on tight boxes
When it happens
Trigger: /tmp (often tmpfs) exhausted by large scans or other processes; per-user disk quota hit; container writable layer too small.
Common situations: Disk-full CI runners; containers with a small tmpfs /tmp; long scans with inline profile secrets on space-constrained boxes.
Related errors
- could not create temp directory: %w
- could not read profile file: %w
- could not create temp secrets file: %w
- Invalid protocol type: {valueToMap}
- invalid workflow with no templates or tags
AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15).
Data as JSON: /api/errors/10d0809658a7db4b.
Report an issue: GitHub.