Skip to content

Close anti-debug syscall side channels - #103

Open
mrexodia wants to merge 9 commits into
masterfrom
debugobject-leak
Open

Close anti-debug syscall side channels#103
mrexodia wants to merge 9 commits into
masterfrom
debugobject-leak

Conversation

@mrexodia

@mrexodia mrexodia commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Match native anti-debug syscall behavior so malformed calls, thread lifecycle transitions, and overlapping output pointers cannot distinguish TitanHide's emulation from native state, without ever applying a delayed one-way thread-hide request.

Confirmed side channels

Live testing and hook-path auditing identified these observable differences:

  1. ProcessDebugObjectHandle checked process access before output alignment. A restricted process handle plus a misaligned output returned STATUS_ACCESS_DENIED; native Windows returns STATUS_DATATYPE_MISALIGNMENT.
  2. ThreadHideFromDebugger queries always returned TRUE, including for fresh threads that never requested hiding.
  3. Existing hidden threads and threads created with THREAD_CREATE_FLAGS_HIDE_FROM_DEBUGGER lost their observable hide state after TitanHide physically stripped the bit.
  4. Failed NtGetContextThread calls still zeroed debug-register fields; native Windows leaves failed output untouched.
  5. ObjectTypesInformation traversal trusted overwriteable UNICODE_STRING fields. Legal ReturnLength overlap could fault or skip DebugObject count filtering.
  6. Internal kernel-mode Zw* calls could enter user-mode filtering paths and expose different statuses or corrupt kernel buffers.
  7. Concurrent hide/unhide updates could race and corrupt virtual hide state.

Changes

  • Reproduce ProcessDebugObjectHandle length, four-byte alignment, access, probing, output, and overlap order.
  • Track successful virtual ThreadHideFromDebugger state by referenced thread object.
  • Seed state when stripping preexisting flags and after successful hide-on-create calls.
  • Retain exited-thread state until unhide/unload so queries through surviving handles remain native-compatible.
  • Never restore or fall back to the physical one-way flag for intercepted set/create requests; table exhaustion remains fail-closed and preferentially evicts exited entries.
  • Roll back a DKOM clear immediately only when a preexisting physical flag cannot be virtualized.
  • Preserve context output when native NtGetContextThread fails, including WOW64.
  • Parse ObjectTypesInformation through bounded inline layout and a cached fixed DebugObject type signature, independent of any single field overwritten by ReturnLength, and stop at the native returned-byte/count bounds.
  • Preserve the reference-free active DebugObject accounting added in 35eaa4a.
  • Bypass filtering for kernel-mode callers.
  • Serialize hide table reads and updates.
  • Add x86/WOW64 and x64 live-system contract tests for all user-visible contracts.

Verification

The native contract suite covers unattached and actively debugged processes, restricted process/thread handles, malformed lengths, null and misaligned outputs, fresh/set/create/exited hidden threads, failed context queries, and overlaps with pointers, lengths, inline names, and type indexes, plus an oversized-buffer tail sentinel.

Runtime validation with TitanHide enabled still requires dedicated Windows 7/10/11 VMs with PatchGuard and DSE disabled.

@mrexodia mrexodia changed the title Match ProcessDebugObjectHandle validation behavior Close anti-debug syscall side channels Jul 18, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b13a71ca7a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread TitanHide/hooks.cpp Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e5aa6152da

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread TitanHide/hooks.cpp Outdated
Comment thread TitanHide/threadhidefromdbg.cpp
@mrexodia

Copy link
Copy Markdown
Owner Author

Live VM diagnosis for 35eaa4a:

  • Clean boot, driver stopped: DebugObject objects=0 handles=0.
  • x64dbg/headless debugging a hidden loop with the previous implementation: active state was 1/1; after terminating debugger and debuggee it remained 1/0.
  • The orphan was caused by repeatedly querying ProcessDebugObjectHandle from QueryDebugObjectContribution, which retained object references after all handles closed.
  • The replacement reads the active pointer with PsGetProcessDebugPort and counts matching entries from SystemExtendedHandleInformation, without opening the debug object.
  • With the replacement loaded: the hidden process saw 0/0 while debugged, and global state returned to 0/0 after debugger termination.

The VS2019/WDK 19041 x86+x64 workflow also passes: https://github.com/mrexodia/TitanHide/actions/runs/29643206017

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 35eaa4a93b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread TitanHide/hooks.cpp Outdated
@mrexodia

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 75c43c4775

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread TitanHide/hooks.cpp Outdated
Comment thread TitanHide/hooks.cpp Outdated
@mrexodia

Copy link
Copy Markdown
Owner Author

@codex review

@mrexodia

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 701c2cbead

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread TitanHide/hooks.cpp Outdated
@mrexodia

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 1731ac0ae9

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant