The Object Manager: Objects, Handles and Access Rights
How the Windows Object Manager represents and names kernel objects: the OBJECT_ATTRIBUTES passed at creation, the object header and object types, reference counting, per-process handle tables, and the access check that turns a requested access mask into the granted rights of a handle, including the security consequences of inheritance, duplication and leaks, with the telemetry and hardening relevant to a defender.
Introduction
The Object Manager is the executive component of the Windows kernel that manages every kernel object in the system: processes, threads, files, registry keys, events, mutexes, sections, tokens and many more. It gives all of them a common set of services:1
- a single namespace, so that objects can be named and found;
- security, through a security descriptor attached to every object;
- lifetime management, through reference counting;
- handles, the only way user-mode code can refer to a kernel object.
Because every resource access goes through the Object Manager, it is also where Windows checks permissions, and where a defender can observe which process opens what.
Creating an object
OBJECT_ATTRIBUTES
Every native API that creates or opens a named object receives an
OBJECT_ATTRIBUTES structure, which describes the object to the Object
Manager:2
| Field | Content |
|---|---|
Length |
Size of the structure |
RootDirectory |
Optional handle to a directory; ObjectName is then relative to it |
ObjectName |
UNICODE_STRING with the name of the object in the object namespace |
Attributes |
Flags such as OBJ_CASE_INSENSITIVE, OBJ_INHERIT, OBJ_OPENIF, OBJ_KERNEL_HANDLE |
SecurityDescriptor |
Optional security descriptor: who can access the object, and how |
SecurityQualityOfService |
Optional impersonation settings, used for example by named pipes and ALPC |
The structure is normally filled with the InitializeObjectAttributes macro
and passed, together with the desired access, to the creation function:
1
2
3
4
5
6
7
8
9
10
11
12
UNICODE_STRING name;
OBJECT_ATTRIBUTES objAttr;
IO_STATUS_BLOCK ioStatus;
HANDLE handle;
RtlInitUnicodeString(&name, L"\\??\\C:\\Temp\\example.txt");
InitializeObjectAttributes(&objAttr, &name, OBJ_CASE_INSENSITIVE, NULL, NULL);
NTSTATUS status = NtCreateFile(&handle, GENERIC_READ | SYNCHRONIZE, &objAttr,
&ioStatus, NULL, FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ, FILE_OPEN,
FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0);
Win32 functions such as CreateFileW build the same structure internally:
they convert the DOS path into an NT path (\??\C:\...) and call
NtCreateFile.3 If no security descriptor is supplied, the
object receives a default one derived from the creator’s token or from the
parent container.
The object namespace
Named objects live in a hierarchical namespace rooted at \, separate from
the file system. Some well-known directories are:4
| Directory | Content |
|---|---|
\Device |
Device objects created by drivers, such as \Device\HarddiskVolume1 |
\Driver, \FileSystem |
Driver objects |
\ObjectTypes |
One entry per object type |
\GLOBAL?? |
DOS device names (C:, PhysicalDrive0) as symbolic links to \Device |
\BaseNamedObjects |
Global named objects (events, mutexes, sections) |
\Sessions\n\BaseNamedObjects |
Named objects local to terminal session n |
\KnownDlls |
Section objects of the system’s known DLLs |
Experiment: browsing the object namespace
The Sysinternals tool WinObj shows the object namespace, the type of every object and, from its properties, the security descriptor and the handle and reference counts.5
The kernel view of an object
The object header
In kernel memory every object is made of an object header, managed by
the Object Manager, followed by the object body, the type-specific
structure (for example EPROCESS for a process or FILE_OBJECT for a file).
The header is represented by the OBJECT_HEADER structure. It is not part of
the documented API and its layout changes between releases, but its main
fields are stable:6
flowchart LR
subgraph OBJ["Kernel object"]
direction TB
OPT["Optional headers<br/>name, handle, quota, creator info"]
subgraph HDR["OBJECT_HEADER"]
direction TB
PC["PointerCount"]
HC["HandleCount"]
TI["TypeIndex"]
SD["SecurityDescriptor"]
FL["InfoMask, Flags"]
end
BODY["Object body<br/>EPROCESS, FILE_OBJECT, ..."]
OPT --- HDR --- BODY
end
TI -->|"index into the type table"| OT["OBJECT_TYPE<br/>name, procedures, access mapping"]
Figure 1. Layout of a kernel object.
| Field | Meaning |
|---|---|
PointerCount |
Number of references to the object, from handles and from kernel code |
HandleCount |
Number of open handles to the object, across all processes |
TypeIndex |
Index of the object’s type in the type table (in older versions, a direct Type pointer) |
SecurityDescriptor |
Pointer to the object’s security descriptor |
InfoMask |
Which optional headers precede the header: name, handle, quota, creator information |
Object types
Each kind of object is described by an OBJECT_TYPE. It holds the type’s
name (Process, Thread, File, Key, Mutant, Section, Token and
others), statistics such as the number of objects and handles of that type,
the valid access mask and generic mapping of the type, and the
type procedures (open, close, delete, parse, security) that the Object
Manager calls at the corresponding points of the object’s life.6
The \ObjectTypes directory lists every type registered on the system.
Reference counting and lifetime
An object stays alive as long as its PointerCount is greater than zero.
Each handle counts as a reference, and kernel components that use an object
add their own references, for example with ObReferenceObjectByHandle, and
release them with ObDereferenceObject.7 When the last
handle is closed, a temporary named object loses its name and can no longer be
opened. When the last reference is released, the Object Manager calls the
type’s delete procedure and frees the memory.
Handles
The handle table
A handle is an index into the handle table of a process. Each entry
of the table points to an object header and stores the access mask granted
to that handle, together with a few flags (inheritable, protected from close,
audit on close).6 Handles of a process are meaningful only in
that process. Handles created with OBJ_KERNEL_HANDLE go into the kernel
handle table, owned by the System process, and are not accessible from user
mode.
The same object can be referenced by several handles in different
processes (Figure 2), each with its own granted access. This happens when a
second process opens the same named object, when a handle is inherited by a
child process, or when it is copied with DuplicateHandle.8
flowchart LR
subgraph PA["Process A: handle table"]
direction TB
A1["0x4: Key"]
A2["0x8: Event, SYNCHRONIZE"]
end
subgraph PB["Process B: handle table"]
direction TB
B1["0x10: Event, EVENT_ALL_ACCESS"]
end
A2 --> EV["Event object<br/>HandleCount = 2"]
B1 --> EV
A1 --> K["Key object"]
Figure 2. Two processes holding handles with different rights to the same object.
Experiment: listing the handles of a process
In Process Explorer, select a process and open the lower pane in Handles view (
Ctrl+H). For acmd.exethe list includes registry keys (HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion), named mutexes and semaphores under\Sessions\n\BaseNamedObjects, a handle to one of its own threads and theWinSta0window station. Adding the Access column shows the granted access mask of each handle.9The command-line equivalent is the Sysinternals Handle tool:10
1 2 handle.exe -a -p cmd.exe # all handle types of cmd.exe handle.exe -s -p cmd.exe # summary by object type
Access rights
The access check happens at open time
When a process creates or opens an object, it specifies a desired access
mask. The Object Manager asks the Security Reference Monitor to compare that
mask with the object’s security descriptor, using the caller’s access
token (see
Logon Sessions and Access Tokens).
If the check succeeds, the handle is created with exactly the granted
access. If any requested right is denied, the call fails with
STATUS_ACCESS_DENIED.11
Subsequent operations on the handle do not repeat the full check: the kernel only verifies that the operation is covered by the access mask stored in the handle entry. This is what makes handle-based access fast, and it is also why the rights requested at open time matter: they define what the holder of the handle will be able to do for the whole lifetime of the handle.
flowchart TB
R1["OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION)"] --> C{"Access check:<br/>token vs security descriptor"}
R2["OpenProcess(PROCESS_ALL_ACCESS)"] --> C
C -->|"granted"| H1["Handle with limited rights"]
C -->|"granted only to principals<br/>with full access"| H2["Handle with full rights"]
C -->|"denied"| F["STATUS_ACCESS_DENIED"]
Figure 3. The access mask requested at open time determines the rights of the handle.
Structure of an access mask
An access mask is a 32-bit value made of several groups of rights:12
| Bits | Group | Examples |
|---|---|---|
| 0–15 | Specific rights, defined by each object type | PROCESS_VM_READ, PROCESS_TERMINATE, KEY_SET_VALUE |
| 16–23 | Standard rights, common to all types | DELETE, READ_CONTROL, WRITE_DAC, WRITE_OWNER, SYNCHRONIZE |
| 24 | ACCESS_SYSTEM_SECURITY |
Access to the SACL; requires SeSecurityPrivilege |
| 28–31 | Generic rights | GENERIC_READ, GENERIC_WRITE, GENERIC_EXECUTE, GENERIC_ALL |
Generic rights are translated into specific and standard rights through the generic mapping of the object type before the check is made.
Beyond the DACL
The security descriptor is not the only factor in the decision:
- Privileges can override the DACL for specific operations. A token with
SeDebugPrivilegeenabled can open any process or thread with any access, regardless of the DACL;SeBackupPrivilegeandSeRestorePrivilegegrant read and write access to files for backup purposes.13 - Mandatory integrity control prevents a lower-integrity caller from obtaining write access to a higher-integrity object.14
- Process protection limits the rights that can be granted on protected
processes, even to callers with
SeDebugPrivilege(see PP and PPL). - Kernel callbacks registered with
ObRegisterCallbackscan remove rights from process, thread and desktop handles as they are created or duplicated.15
Security consequences of handle sharing
An open handle is a capability: it combines a reference to an object with the rights that the Security Reference Monitor already granted. Code that receives the handle can exercise those rights without repeating the original DACL check. Handle inheritance and duplication are legitimate ways to pass a capability between processes; they become vulnerabilities when a more trusted process transfers more authority than the receiver needs.
Handle inheritance
Windows does not copy every parent handle into every child. Generic handle inheritance requires two separate decisions (Figure 4):8
- the individual handle must carry the inherit flag, set when it is
created or later through
SetHandleInformation; and - the process-creation call must set
bInheritHandles = TRUE.
flowchart LR
O["Parent creates or opens an object"]
I["Handle marked inheritable<br/>SECURITY_ATTRIBUTES or SetHandleInformation"]
C["CreateProcess<br/>bInheritHandles = TRUE"]
L{"Explicit<br/>HANDLE_LIST?"}
A["Only allowlisted handles"]
G["All inheritable handles"]
H["Child handle-table entry<br/>same object and access rights"]
U["Child uses the capability<br/>no new object DACL check"]
O --> I --> C --> L
L -->|"yes"| A --> H
L -->|"no"| G --> H
H --> U
Figure 4. Both the handle and the process-creation operation must permit inheritance.
For OpenProcess, the second argument controls whether the returned process
handle is inheritable; it does not mean that inheritance happens immediately.
The handle moves only when a later child is created with inheritance enabled.
An inherited handle refers to the same object and has the same access mask as
the parent’s handle. For CreateProcess, Windows also preserves its numeric
value in the child, although code should treat handle values as opaque.16
This is dangerous when a privileged service or broker launches a lower-trust or attacker-controlled child. A leaked process, token, file, section or pipe handle may let the child perform operations that its own token could not have opened directly. The child is not elevated automatically; it has received one pre-authorized capability whose impact is determined by the object type and granted access.
The legacy model is also broad: bInheritHandles = TRUE normally transfers
all handles whose inherit bit is set. In a multithreaded parent, another
thread can create an inheritable handle just before process creation and leak
it unintentionally. STARTUPINFOEX with
PROC_THREAD_ATTRIBUTE_HANDLE_LIST restricts the transfer to an explicit
allowlist and removes that ambiguity.17
Not every value that looks like a handle participates. Pseudo handles such as
GetCurrentProcess(), GDI/USER handles and module handles are not generic
inheritable kernel handles. Generic inheritance is also blocked when a PPL
creates a non-PPL process, because the required protected-process handle
relationship is not permitted.16
Handle duplication
DuplicateHandle and the native NtDuplicateObject create a new handle-table
entry that refers to an object already opened elsewhere (Figure 5). The caller
needs process handles with PROCESS_DUP_HANDLE for the source and destination
processes. That prerequisite is itself protected by the normal process DACL,
PPL rules, integrity policy and any registered Object Manager callbacks.18
flowchart LR
A["Caller obtains PROCESS_DUP_HANDLE<br/>to source and target processes"]
S["Source process table<br/>handle H, granted access X"]
D["DuplicateHandle / NtDuplicateObject"]
R{"Requested rights"}
E["Same rights X<br/>DUPLICATE_SAME_ACCESS"]
F["Explicit dwDesiredAccess<br/>result is object-type dependent"]
T["Target process table<br/>new handle H2"]
O["Same kernel object"]
A --> D
S --> D --> R
R --> E --> T
R --> F --> T
T --> O
S --> O
Figure 5. Duplication creates another reference to the same object; its access is copied or selected through an object-type-dependent mask.
DUPLICATE_SAME_ACCESS copies the source mask. Otherwise dwDesiredAccess
requests a mask valid for that object type. The relationship with the source
mask is type-dependent: Microsoft documents that some duplicated handles can
receive different or even broader rights, while others cannot. A read-only
file handle, for example, cannot be duplicated into a read/write file handle.
Code must therefore not assume either universal amplification or a universal
subset. Some object state is shared as well: duplicated file handles, for
example, share a file position.18
The security problem is capability theft. If a process can obtain
PROCESS_DUP_HANDLE over a privileged service, it may search that service’s
table for a handle to a more sensitive object and copy it into its own table.
This can avoid opening the sensitive object by name, but it does not inherently
bypass PPL: the attacker still needs access to the source process, and protected
process policy can deny that prerequisite. For process and thread handles,
ObRegisterCallbacks also receives duplicate operations and can remove
dangerous rights from the new handle.
Handle leaks and stale handles
A handle leak occurs when code finishes using a handle but omits the matching close. The handle-table entry and the reference it owns remain until the process closes the handle or exits (Figure 6).19
flowchart LR
O["Privileged component opens an object<br/>with rights X"]
W["Work completes"]
Q{"CloseHandle?"}
C["Reference released<br/>entry removed"]
L["Leaked handle remains<br/>object kept alive"]
P["Process later compromised<br/>or handle duplicated"]
I["Future child inherits it<br/>only if inherit conditions also hold"]
E["Capability abuse or<br/>resource exhaustion"]
O --> W --> Q
Q -->|"yes"| C
Q -->|"no"| L
L --> P --> E
L --> I --> E
Figure 6. A resource leak becomes a capability leak when another security context can reach the unclosed handle.
Forgetting CloseHandle does not by itself make a handle inheritable. The
inherit flag and process-creation conditions from Figure 4 must also be true.
The security risk is nevertheless real in a long-running privileged process:
the unclosed handle widens the time window in which injected code, a later
memory-corruption bug or a handle-duplication flaw can reuse its authority.
Leaks also have availability and correctness consequences. They keep kernel objects and associated resources alive, delay delete-on-close semantics, keep pipe endpoints or files open and can exhaust a process or system handle quota. A related use-after-close bug is different: once a handle is closed, the numeric value may be reused for an unrelated object. Code that retains the stale value can then operate on the wrong object. Double-close and stale-handle failures are precisely the class of bug that the Application Verifier Handles layer is designed to expose during testing.20
Impact by object type
The handle value is not the privilege; the object type and granted access mask are. Typical consequences are:
| Leaked or duplicated handle | High-impact rights | Possible consequence |
|---|---|---|
| Process | PROCESS_VM_READ, PROCESS_VM_WRITE, PROCESS_CREATE_THREAD, PROCESS_DUP_HANDLE |
Memory disclosure, code injection or theft of additional capabilities |
| Thread | THREAD_SET_CONTEXT, THREAD_SUSPEND_RESUME |
Execution redirection or denial of service |
| Token | TOKEN_DUPLICATE, TOKEN_ASSIGN_PRIMARY, TOKEN_IMPERSONATE, TOKEN_ADJUST_PRIVILEGES |
Impersonation or creation of a process under another security context |
| File / registry key | Read, write, delete or DACL-changing rights | Access to data or configuration that the receiver could not open itself |
| Section | Map-read or map-write rights | Disclosure or modification of shared memory and mapped images |
| Pipe / ALPC endpoint | Protocol-specific read, write or impersonation capability | Access to a privileged IPC conversation |
| Event, mutex or semaphore | Modify or synchronize rights | State manipulation, race induction or denial of service |
Telemetry
| Source | Event or metric | Use and limitation |
|---|---|---|
| Security log, Audit Handle Manipulation and object-access subcategories | 4656 handle requested, 4663 access attempted, 4658 handle closed, 4690 duplication attempted2122 |
Generated only for supported objects with matching SACL/audit policy; useful for a targeted object, noisy and incomplete as a system-wide inventory |
| Security log, process creation | 4688 new process23 |
Correlates a privileged parent with a lower-trust child, but does not enumerate the handles inherited by that child |
| Sysmon | Event 10 ProcessAccess24 |
Process handles opened to other processes, with granted access and call trace; particularly useful for sensitive targets |
| Kernel callbacks | ObRegisterCallbacks pre/post create and duplicate operations15 |
Lets EDR drivers observe or filter process, thread and desktop handles (see How an EDR works) |
| Process inventory | Handle count and per-type handle table from Process Explorer, handle.exe or an EDR |
Detects unexpected capabilities and monotonically increasing counts; a snapshot alone does not identify which call site leaked them |
| Application Verifier | Handles and Leak verification layers20 | Development-time detection of invalid, double-closed, stale and unclosed handles, with allocation/open stacks |
The access mask is the most useful field. A handle to another process with
PROCESS_QUERY_LIMITED_INFORMATION is routine; one with PROCESS_VM_READ,
PROCESS_VM_WRITE, PROCESS_CREATE_THREAD or PROCESS_DUP_HANDLE, toward a
sensitive target such as lsass.exe, deserves investigation. For tokens,
TOKEN_DUPLICATE and TOKEN_ASSIGN_PRIMARY are similarly more meaningful
than the mere presence of a token handle.
Detection patterns
Unexpected inheritance. Correlate a high-integrity service or broker
creating a lower-integrity, sandboxed or unusual child with an inventory of
the child’s first handles. Standard event 4688 establishes the process tree
but cannot prove inheritance; that requires endpoint handle telemetry or a
snapshot taken close to process start. A sensitive handle present immediately
in the child, with no corresponding open operation by the child, is the key
observation.
Capability theft by duplication. Look for access to a privileged source
process with PROCESS_DUP_HANDLE, followed by event 4690 or an EDR duplicate
callback and then use of the new capability. Event 4690 is difficult to use
as a broad alert, but becomes useful when scoped to a protected process, token,
high-value file or other known object and correlated through source/target PIDs
and handle IDs.
Handle leak. Track handle count as a rate, not just a threshold. A steady increase in a long-lived service, accompanied by growth in one object type, is stronger than a large but stable baseline. After identifying the type, use Application Verifier in a test environment or debugger handle tracing to recover the open stack. Production response should avoid forcibly closing an unknown handle in another process: the application may still depend on it.
Reuse after close. Crashes or unexpected operations following rapid handle open/close activity may indicate a stale-handle bug. Because both PIDs and handle values are reused, correlate with process-instance identifiers and timestamps rather than treating a numeric handle as globally unique.
Hardening
| Control | Effect |
|---|---|
| Request the minimum access in code | A handle with fewer rights limits the damage if the process is compromised |
Restrict SeDebugPrivilege |
Remove it from accounts that do not need it; by default only Administrators hold it13 |
| Explicit security descriptors on named objects | Prevents other users from opening, or pre-creating, an application’s events, sections and pipes |
Private namespaces (CreatePrivateNamespace) |
Protect named objects from squatting by other processes in the same session25 |
Non-inheritable handles and bInheritHandles = FALSE by default |
Prevents accidental transfer to children; clear HANDLE_FLAG_INHERIT when a temporary handoff ends |
Explicit PROC_THREAD_ATTRIBUTE_HANDLE_LIST |
Replaces inheritance of every flagged handle with a per-child allowlist17 |
| Deliberate rights on duplication | Avoid DUPLICATE_SAME_ACCESS when the receiver needs less authority; request and verify the documented mask for that object type |
| Protect source-process access | Deny unnecessary PROCESS_DUP_HANDLE; use PPL for supported high-value services and EDR callbacks to filter dangerous process/thread handles |
| Deterministic ownership and RAII | Give each handle one clear owner and close it on every success, error and cancellation path; wrapper types make this automatic |
| Close unused ends after handoff | A parent and child should immediately close pipe, file and synchronization handles that belong only to the other side |
| Restricted child identity and broker design | Give untrusted children narrow tokens and expose operations through a validated IPC interface instead of sharing broad handles |
| Application Verifier and static analysis in CI | Finds leaks, invalid closes and missing cleanup paths before deployment; compiler warning C6335 catches unclosed process/thread handles2026 |
HANDLE_FLAG_PROTECT_FROM_CLOSE is not a substitute for ownership discipline.
It prevents an ordinary close while the flag is set, which can protect a
framework-owned handle from accidental closure, but misuse can turn a cleanup
bug into a persistent leak.
Summary
The Object Manager gives every kernel object a common structure: an
OBJECT_HEADER with reference and handle counts, a type index pointing to
an OBJECT_TYPE, and a security descriptor, followed by the type-specific
body. Objects are created and opened through native APIs that take an
OBJECT_ATTRIBUTES structure, with the name, the root directory, the
attributes and the security descriptor. User-mode code refers to objects only
through handles, entries in a per-process handle table that store the
granted access. The access check against the security descriptor happens
once, at open time, and is influenced by privileges, integrity levels,
process protection and kernel callbacks. Inheritance and duplication then
transfer that pre-authorized capability without repeating the object’s DACL
check: inheritance needs both an inheritable handle and a process creation that
permits it, while duplication needs PROCESS_DUP_HANDLE over the participating
processes and creates a type-dependent access mask, or an exact copy when
DUPLICATE_SAME_ACCESS is used.
An unclosed handle keeps both its object reference and its authority alive. It becomes a security issue when a less-trusted child, injected code or a duplication flaw can reach it, and a reliability issue when objects or quotas are exhausted. Defenders should combine targeted handle auditing, process access telemetry and handle-count trends; developers should default to non-inheritance, explicit per-child allowlists, least access, deterministic RAII cleanup and Application Verifier testing.
References
-
Microsoft Learn, Managing Kernel Objects. ↩︎
-
Microsoft Learn, OBJECT_ATTRIBUTES structure (ntdef.h). ↩︎
-
Microsoft Learn, NtCreateFile function (winternl.h). ↩︎
-
Microsoft Learn, Object Names. ↩︎
-
P. Yosifovich, A. Ionescu, M. Russinovich, D. Solomon, Windows Internals, Part 1, 7th edition, Microsoft Press, 2017, chapter 8 (Object Manager). ↩︎ ↩︎2 ↩︎3
-
Microsoft Learn, ObReferenceObjectByHandle function (wdm.h). ↩︎
-
Microsoft Learn, Handle Inheritance. ↩︎ ↩︎2
-
Microsoft Learn, Process Explorer. ↩︎
-
Microsoft Learn, How DACLs Control Access to an Object. ↩︎
-
Microsoft Learn, ACCESS_MASK. ↩︎
-
Microsoft Learn, Privileges. ↩︎ ↩︎2
-
Microsoft Learn, Mandatory Integrity Control. ↩︎
-
Microsoft Learn, ObRegisterCallbacks function (wdm.h). ↩︎ ↩︎2
-
Microsoft Learn, CreateProcessW function (processthreadsapi.h). ↩︎ ↩︎2
-
Microsoft Learn, UpdateProcThreadAttribute function (processthreadsapi.h). ↩︎ ↩︎2
-
Microsoft Learn, DuplicateHandle function (handleapi.h). ↩︎ ↩︎2
-
Microsoft Learn, CloseHandle function (handleapi.h). ↩︎
-
Microsoft Learn, Application Verifier. ↩︎ ↩︎2 ↩︎3
-
Microsoft Learn, 4656(S, F): A handle to an object was requested. ↩︎
-
Microsoft Learn, 4690(S): An attempt was made to duplicate a handle to an object. ↩︎
-
Microsoft Learn, 4688(S): A new process has been created. ↩︎
-
Microsoft Learn, Object Namespaces. ↩︎
-
Microsoft Learn, Compiler warning C6335. ↩︎