{"record":{"id":"7de5d306c627fd18","repo":"JuliusBrussee/caveman","slug":"native-runtime-chmod-socket-w","errorCode":null,"errorMessage":"native runtime chmod socket: %w","messagePattern":"native runtime chmod socket: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/internal/nativeruntime/server_unix.go","lineNumber":61,"sourceCode":"\t\tconn, dialErr := net.DialTimeout(\"unix\", path, 50*time.Millisecond)\n\t\tif dialErr == nil {\n\t\t\t_ = conn.Close()\n\t\t\treturn errors.New(\"native runtime: socket already active\")\n\t\t}\n\t\tif err := os.Remove(path); err != nil {\n\t\t\treturn fmt.Errorf(\"native runtime remove stale socket: %w\", err)\n\t\t}\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"native runtime inspect socket: %w\", err)\n\t}\n\tlistener, err := net.Listen(\"unix\", path)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"native runtime listen: %w\", err)\n\t}\n\tdefer listener.Close()\n\tdefer os.Remove(path)\n\tif err := os.Chmod(path, 0o600); err != nil {\n\t\treturn fmt.Errorf(\"native runtime chmod socket: %w\", err)\n\t}\n\tgo func() {\n\t\t<-ctx.Done()\n\t\t_ = listener.Close()\n\t}()\n\tfor {\n\t\tconn, err := listener.Accept()\n\t\tif err != nil {\n\t\t\tif ctx.Err() != nil {\n\t\t\t\treturn nil\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"native runtime accept: %w\", err)\n\t\t}\n\t\tgo serveConn(ctx, conn, runtime)\n\t}\n}\n","sourceCodeStart":43,"sourceCodeEnd":78,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/proxy/internal/nativeruntime/server_unix.go#L43-L78","documentation":"Once listening, ServeUnix Chmods the socket file to 0600 so only the owner can connect. If that chmod fails, the listener is torn down via defers and \"native runtime chmod socket\" is returned. This enforces per-user access to the runtime endpoint.","triggerScenarios":"os.Chmod(path, 0o600) fails on the freshly bound socket: filesystem does not support it (network/9p mounts), ownership mismatch, or a race replacing the socket file.","commonSituations":"Sockets placed on tmpfs variants or mounted shares with odd permission semantics; security software resetting ownership; running the server as a different uid than expected.","solutions":["Move the socket to a local filesystem (e.g. /tmp or the user's home) that supports chmod","Ensure the process user owns the socket path directory","Check for security/AV software interfering with socket file permissions"],"exampleFix":"// before\nServeUnix(ctx, \"/mnt/nfs-share/rt.sock\", rt) // chmod unsupported\n// after\nServeUnix(ctx, \"/tmp/rt.sock\", rt)","handlingStrategy":"try-catch","validationCode":"// verify the target filesystem supports chmod before binding\nprobe := filepath.Dir(socketPath)\nif err := os.Chmod(probe, 0o700); err != nil {\n\treturn fmt.Errorf(\"filesystem does not support chmod: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := nativeruntime.ServeUnix(ctx, path, rt); err != nil {\n\tif strings.Contains(err.Error(), \"chmod socket\") {\n\t\t// fall back to a local filesystem path\n\t\treturn nativeruntime.ServeUnix(ctx, \"/tmp/nativeruntime.sock\", rt)\n\t}\n\treturn err\n}","preventionTips":["Place sockets on local filesystems only","Run the runtime under the expected uid","Audit security software that may rewrite socket permissions"],"tags":["filesystem","permissions","socket"],"backgroundTag":"permission-denied","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}