Skip to content

CPP: Windows leaked handles #827

Closed
Closed
@bananabr

Description

@bananabr

Query PR

github/codeql#16618

Language

C/C++

CVE(s) ID list

CWE

CWE-403: Exposure of File Descriptor to Unintended Control Sphere ('File Descriptor Leak')

Report

What is the vulnerability?
The vulnerability is the potential leakage of a privileged handle to a child process through the CreateProcessAsUser call with handle inheritance enabled.

How does the vulnerability work?
If a handle to a process, thread, or file is opened with specific permissions and not properly closed before creating a new process with handle inheritance enabled, the handle may be inherited by the child process, leading to possible privilege escalation.

What strategy do you use in your query to find the vulnerability?
The query identifies calls to CreateProcessAsUser with handle inheritance enabled that are preceded by handle opening calls (such as OpenProcess, OpenThread, or CreateFile) with specific permissions and checks if these handles are not closed before the CreateProcessAsUser call.

How have you reduced the number of false positives?
The query limits itself to a single function scope, simplifying its implementation and using the code line numbers to check for the order the target calls hapen.

Are you planning to discuss this vulnerability submission publicly? (Blog Post, social networks, etc).

  • Yes
  • No

Blog post link

No response

Metadata

Metadata

Labels

All For OneSubmissions to the All for One, One for All bounty

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions