{"record":{"id":"2ad2c5636bcca651","repo":"go-delve/delve","slug":"could-not-acquire-debug-privilege-lookupprivileg","errorCode":null,"errorMessage":"could not acquire debug privilege  (LookupPrivilegeValue): %v","messagePattern":"could not acquire debug privilege  \\(LookupPrivilegeValue\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/proc/native/proc_windows.go","lineNumber":207,"sourceCode":"// acquireDebugPrivilege acquires the debug privilege which is needed to\n// debug other user's processes.\n// See:\n//\n//   - https://learn.microsoft.com/en-us/windows-hardware/drivers/debugger/debug-privilege\n//   - https://github.com/go-delve/delve/issues/3136\nfunc acquireDebugPrivilege() error {\n\tvar token sys.Token\n\terr := sys.OpenProcessToken(sys.CurrentProcess(), sys.TOKEN_QUERY|sys.TOKEN_ADJUST_PRIVILEGES, &token)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not acquire debug privilege (OpenCurrentProcessToken): %v\", err)\n\t}\n\tdefer token.Close()\n\n\tprivName, _ := sys.UTF16FromString(\"SeDebugPrivilege\")\n\tvar luid sys.LUID\n\terr = sys.LookupPrivilegeValue(nil, &privName[0], &luid)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not acquire debug privilege  (LookupPrivilegeValue): %v\", err)\n\t}\n\n\tvar tp sys.Tokenprivileges\n\ttp.PrivilegeCount = 1\n\ttp.Privileges[0].Luid = luid\n\ttp.Privileges[0].Attributes = sys.SE_PRIVILEGE_ENABLED\n\n\terr = sys.AdjustTokenPrivileges(token, false, &tp, 0, nil, nil)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not acquire debug privilege (AdjustTokenPrivileges): %v\", err)\n\t}\n\n\treturn nil\n}\n\nfunc waitForSearchProcess(pfx string, seen map[int]struct{}) (int, error) {\n\tlog := logflags.DebuggerLogger()\n\thandle, err := sys.CreateToolhelp32Snapshot(sys.TH32CS_SNAPPROCESS, 0)","sourceCodeStart":189,"sourceCodeEnd":225,"githubUrl":"https://github.com/go-delve/delve/blob/a23773e6c31361e43246bc43a424ee009679b174/pkg/proc/native/proc_windows.go#L189-L225","documentation":"Second step of acquireDebugPrivilege: after opening the process token, Delve resolves the privilege name \"SeDebugPrivilege\" to its LUID using LookupPrivilegeValue. Failure means the privilege name could not be resolved on this system, wrapped in this error (note the double space in the message distinguishes it from the OpenProcessToken variant).","triggerScenarios":"Attach on Windows where LookupPrivilegeValue(nil, \"SeDebugPrivilege\", &luid) returns FALSE — rare, typically system-level policy or token issues.","commonSituations":"Hardened/modified Windows images where privilege lookup is restricted; domain policy stripping privilege metadata; running on non-standard Windows variants (e.g. stripped IoT/SKU builds).","solutions":["Verify SeDebugPrivilege exists: `whoami /priv | findstr SeDebugPrivilege`.","Run on a standard Windows client/server SKU; check for security baseline GPOs that remove debugger privileges.","Run elevated as Administrator and retry.","Check the underlying Win32 error in %v (e.g. ERROR_NO_SUCH_PRIVILEGE) and address that specific condition."],"exampleFix":"// before\nc:> dlv attach 4242\n// could not acquire debug privilege  (LookupPrivilegeValue): ...\n// after\nc:> whoami /priv | findstr SeDebugPrivilege\nc:> # if absent, run elevated or restore the privilege via secpol.msc\n//   Local Security Policy -> User Rights Assignment -> Debug programs","handlingStrategy":"validation","validationCode":"// powershell: verify the privilege is assigned before attach\n$priv = whoami /priv | Select-String SeDebugPrivilege\nif (-not $priv) { Write-Error \"SeDebugPrivilege missing; run elevated or via secpol.msc\" }","typeGuard":null,"tryCatchPattern":"if err := dbg.Attach(pid, nil); err != nil {\n    if strings.Contains(err.Error(), \"LookupPrivilegeValue\") {\n        // restore \"Debug programs\" user right, then retry elevated\n    }\n}","preventionTips":["Keep the default \"Debug programs\" user right intact in security policy.","Run on standard Windows SKUs without stripped privilege metadata.","Always run elevated when attaching cross-user."],"tags":["windows","privileges","token","attach"],"backgroundTag":"debug-privilege-not-enabled","analyzedSha":"a23773e6c31361e43246bc43a424ee009679b174","analyzedAt":"2026-08-31T15:12:45.221Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}