{"record":{"id":"10d0809658a7db4b","repo":"projectdiscovery/nuclei","slug":"could-not-write-to-temp-secrets-file-w","errorCode":null,"errorMessage":"could not write to temp secrets file: %w","messagePattern":"could not write to temp secrets file: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/nuclei/main.go","lineNumber":913,"sourceCode":"\t}\n\n\ttempDir := filepath.Join(os.TempDir(), \"nuclei-secrets\")\n\tif err := os.MkdirAll(tempDir, 0700); err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not create temp directory: %w\", err)\n\t}\n\n\ttempFile, err := os.CreateTemp(tempDir, \"inline-secrets-*.yaml\")\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"could not create temp secrets file: %w\", err)\n\t}\n\tdefer func() {\n\t\t_ = tempFile.Close()\n\t}()\n\n\tif _, err := tempFile.Write(secretsData); err != nil {\n\t\t_ = tempFile.Close()\n\t\t_ = os.Remove(tempFile.Name())\n\t\treturn \"\", fmt.Errorf(\"could not write to temp secrets file: %w\", err)\n\t}\n\n\toptions.SecretsFile = append(options.SecretsFile, tempFile.Name())\n\treturn tempFile.Name(), nil\n}\n","sourceCodeStart":895,"sourceCodeEnd":919,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/cmd/nuclei/main.go#L895-L919","documentation":"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.","triggerScenarios":"/tmp (often tmpfs) exhausted by large scans or other processes; per-user disk quota hit; container writable layer too small.","commonSituations":"Disk-full CI runners; containers with a small tmpfs /tmp; long scans with inline profile secrets on space-constrained boxes.","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"],"exampleFix":"# before\ndf -h /tmp   # 100% used\n\n# after\nTMPDIR=/data/tmp nuclei -profile scan.yaml","handlingStrategy":"try-catch","validationCode":"// pre-flight: verify writable space on the temp filesystem\nvar st syscall.Statfs_t\nif err := syscall.Statfs(tempDir, &st); err == nil && st.Bavail*uint64(st.Bsize) < uint64(len(secretsData))*4 {\n    return errors.New(\"insufficient space in temp dir for secrets file\")\n}","typeGuard":null,"tryCatchPattern":"if _, err := tempFile.Write(secretsData); err != nil {\n    _ = os.Remove(tempFile.Name())\n    return fmt.Errorf(\"writing secrets to %s failed (disk full/quota?): %w\", tempFile.Name(), err)\n}","preventionTips":["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"],"tags":["go","nuclei","filesystem","disk-full","tmpdir"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}