{"record":{"id":"0cf14f22fcc88b98","repo":"projectdiscovery/katana","slug":"invalid-user-id","errorCode":null,"errorMessage":"invalid user ID","messagePattern":"invalid user ID","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/engine/headless/browser/browser.go","lineNumber":392,"sourceCode":"\tvar tempDir string\n\tshouldCleanupTempDir := false\n\n\tif l.opts.ChromeWSUrl == \"\" {\n\t\tif l.opts.UserDataDir != \"\" {\n\t\t\t// Use user-provided data directory (preserve sessions/cookies)\n\t\t\ttempDir = l.opts.UserDataDir\n\t\t\tshouldCleanupTempDir = false\n\t\t} else if l.opts.ChromeUser != nil {\n\t\t\tvar err error\n\t\t\ttempDir, err = os.MkdirTemp(l.opts.ChromeUser.HomeDir, \"chrome-data-*\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"could not create temporary chrome data directory\")\n\t\t\t}\n\n\t\t\tuid, err := strconv.Atoi(l.opts.ChromeUser.Uid)\n\t\t\tif err != nil {\n\t\t\t\t_ = os.RemoveAll(tempDir)\n\t\t\t\treturn nil, errors.Wrap(err, \"invalid user ID\")\n\t\t\t}\n\t\t\tgid, err := strconv.Atoi(l.opts.ChromeUser.Gid)\n\t\t\tif err != nil {\n\t\t\t\t_ = os.RemoveAll(tempDir)\n\t\t\t\treturn nil, errors.Wrap(err, \"invalid group ID\")\n\t\t\t}\n\t\t\tif err := os.Chown(tempDir, uid, gid); err != nil {\n\t\t\t\t_ = os.RemoveAll(tempDir)\n\t\t\t\treturn nil, errors.Wrap(err, \"could not change ownership of chrome data directory\")\n\t\t\t}\n\t\t\tshouldCleanupTempDir = true\n\t\t} else {\n\t\t\tvar err error\n\t\t\ttempDir, err = os.MkdirTemp(\"\", \"katana-chrome-data-*\")\n\t\t\tif err != nil {\n\t\t\t\treturn nil, errors.Wrap(err, \"could not create temporary chrome data directory\")\n\t\t\t}\n\t\t\tshouldCleanupTempDir = true","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/projectdiscovery/katana/blob/e3e742739c3746f085943ce918fb4e2b8daf6fe6/pkg/engine/headless/browser/browser.go#L374-L410","documentation":"Thrown when strconv.Atoi fails to parse ChromeUser.Uid. Katana needs the UID as an integer to os.Chown the freshly created temp chrome data directory. The temp dir is removed before returning to avoid leaking stale profile data.","triggerScenarios":"ChromeUser.Uid is not a valid decimal integer string — empty (\"\") or non-numeric — typically when the *user.User struct was constructed manually or came from a directory service that did not populate Uid.","commonSituations":"Hand-built user.User{Username: \"chrome\"} without Uid; LDAP/SSSD/NSS lookups returning incomplete entries; populating Uid with a username instead of a number; unusual passwd formats.","solutions":["Populate ChromeUser via user.Lookup(\"chrome\"), which fills Uid as a decimal string, instead of building the struct by hand.","Validate before use: if _, err := strconv.Atoi(u.Uid); err != nil fall back to ChromeUser=nil.","Check /etc/passwd (or the NSS backend) that the account has a numeric UID; fix the directory service entry if empty.","If no ownership change is needed, leave ChromeUser nil so katana uses the default temp dir path."],"exampleFix":"// before\nopts.ChromeUser = &user.User{Username: \"chrome\", HomeDir: \"/home/chrome\"} // Uid empty\n// after\nu, err := user.Lookup(\"chrome\")\nif err != nil {\n    return err\n}\nopts.ChromeUser = u","handlingStrategy":"validation","validationCode":"if opts.ChromeUser != nil {\n    if _, err := strconv.Atoi(opts.ChromeUser.Uid); err != nil {\n        return fmt.Errorf(\"ChromeUser.Uid %q is not numeric\", opts.ChromeUser.Uid)\n    }\n}","typeGuard":"func hasNumericID(u *user.User) bool {\n    _, uidErr := strconv.Atoi(u.Uid)\n    _, gidErr := strconv.Atoi(u.Gid)\n    return uidErr == nil && gidErr == nil\n}","tryCatchPattern":"page, err := l.createBrowserPageFunc(...)\nif err != nil && strings.Contains(err.Error(), \"invalid user ID\") {\n    l.opts.ChromeUser = nil // retry without dedicated chrome user\n    page, err = l.createBrowserPageFunc(...)\n}","preventionTips":["Always populate ChromeUser via os/user Lookup rather than hand-built structs.","Validate Uid/Gid with strconv.Atoi immediately after lookup.","Guard against directory services (LDAP/SSSD) returning empty numeric IDs.","Default to ChromeUser=nil when ownership isolation is not needed."],"tags":["configuration","parsing","chrome","user-accounts"],"backgroundTag":"invalid-uid-gid","analyzedSha":"e3e742739c3746f085943ce918fb4e2b8daf6fe6","analyzedAt":"2026-09-03T14:55:13.248Z","contentChangedAt":"2026-09-03T14:55:13.248Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}