[PR #9604] [MERGED] Add a Fuzzing configuration and a version of conhost that can be fuzzed #27650

Open
opened 2026-01-31 09:23:17 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/9604
Author: @DHowett
Created: 3/24/2021
Status: Merged
Merged: 3/29/2021
Merged by: @undefined

Base: mainHead: dev/duhowett/fuzzywuzzy


📝 Commits (10+)

  • ddff90d Add a Fuzzing configuration and a version of conhost that can be fuzzed
  • 7c3ebfe Clean up the fuzzing configs
  • 4d48c08 Fuzz: disable in all build configs except Fuzzing
  • 2868fc5 This is simply necessary
  • fac2d92 Speelboot
  • 521cf13 Let VS fix the invalid solution configs
  • dc13013 Let VS fix the invalid solution configs II
  • 4ac0a57 link fuzzer only for the EXE & only in fuzzing config
  • d63a3b4 Lock the console so we don't explode it
  • 886b4b6 Address CR feedback, elide locks

📊 Changes

7 files changed (+907 additions, -4 deletions)

View changed files

📝 .github/actions/spelling/expect/expect.txt (+4 -0)
📝 OpenConsole.sln (+630 -0)
📝 src/common.build.pre.props (+32 -2)
src/host/ft_fuzzer/Host.FuzzWrapper.vcxproj (+86 -0)
src/host/ft_fuzzer/fuzzmain.cpp (+149 -0)
📝 src/host/globals.h (+1 -1)
📝 src/host/srvinit.cpp (+5 -1)

📄 Description

This commit introduces a new build configuration, "Fuzzing", which
enables the new address sanitizer (shipped in VS 16.9) and code
coverage over the entire solution. Only a small subset of projects
(those comprising original conhost, right now) are selected to build in
this configuration, and even then only in Fuzzing|x64.

It also adds a fuzzing-adapted build of conhost, which makes no server
connections and handles no client applications. To do this, I've
replicated a bit of the console startup routine into fuzzmain.cpp and
made up some fake data. This is the bare minimum required to boot up
Win32 interactivity (or VT interactivity!) and pretend that a process
has connected.

If we don't pretend that a process has connected, "conhost" will exit
immediately. If we don't forge the process list, conhost will exit. If
we can't provide a server handle, we can't provide a "device comm".

Minor changes were necessary to server/host such that they would accept
a preexisting "device comm". We use this new behavior to provide a
"null" one that only hangs up threads and otherwise responds to requests
successfully.

This fuzzing-adapted build links LLVM's libFuzzer, which is an excellent
coverage-based fuzzer that will produce a corpus of inputs that exercise
unique codepaths. Eventually, we can use this to generate known-"good"
inputs for anything.

I've gone ahead and added a fuzz function that yeets bytes directly into
WriteCharsLegacy, which was the original reason I went down this path.

The implementation of LLVMFuzzerTestOneInput should be replaced with
whatever you want to fuzz.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/9604 **Author:** [@DHowett](https://github.com/DHowett) **Created:** 3/24/2021 **Status:** ✅ Merged **Merged:** 3/29/2021 **Merged by:** [@undefined](undefined) **Base:** `main` ← **Head:** `dev/duhowett/fuzzywuzzy` --- ### 📝 Commits (10+) - [`ddff90d`](https://github.com/microsoft/terminal/commit/ddff90dedecc30d6a184b34ee25fb4fdd0e89e53) Add a Fuzzing configuration and a version of conhost that can be fuzzed - [`7c3ebfe`](https://github.com/microsoft/terminal/commit/7c3ebfe8ab81427ffe7ca2ac8b7f4a11c546f30d) Clean up the fuzzing configs - [`4d48c08`](https://github.com/microsoft/terminal/commit/4d48c085fdcf8e1790950d184f27940d6ae2b4d8) Fuzz: disable in all build configs except Fuzzing - [`2868fc5`](https://github.com/microsoft/terminal/commit/2868fc51c9ecf9e44a8628168ce8e838b784632c) This is simply necessary - [`fac2d92`](https://github.com/microsoft/terminal/commit/fac2d921339310ef6a15795077c9c0486ad5db2b) Speelboot - [`521cf13`](https://github.com/microsoft/terminal/commit/521cf1302b25c51f24941a024c5f843b6fcb1f2f) Let VS fix the invalid solution configs - [`dc13013`](https://github.com/microsoft/terminal/commit/dc130137164f2ab571292b54852d97b7c315a168) Let VS fix the invalid solution configs II - [`4ac0a57`](https://github.com/microsoft/terminal/commit/4ac0a57792bb9061c788cc2adda511d65f467751) link fuzzer only for the EXE & only in fuzzing config - [`d63a3b4`](https://github.com/microsoft/terminal/commit/d63a3b48d146d559c5f1a098f7cf8edae6105abe) Lock the console so we don't explode it - [`886b4b6`](https://github.com/microsoft/terminal/commit/886b4b61d45f00899cc6da76a77c92c27e425543) Address CR feedback, elide locks ### 📊 Changes **7 files changed** (+907 additions, -4 deletions) <details> <summary>View changed files</summary> 📝 `.github/actions/spelling/expect/expect.txt` (+4 -0) 📝 `OpenConsole.sln` (+630 -0) 📝 `src/common.build.pre.props` (+32 -2) ➕ `src/host/ft_fuzzer/Host.FuzzWrapper.vcxproj` (+86 -0) ➕ `src/host/ft_fuzzer/fuzzmain.cpp` (+149 -0) 📝 `src/host/globals.h` (+1 -1) 📝 `src/host/srvinit.cpp` (+5 -1) </details> ### 📄 Description This commit introduces a new build configuration, "Fuzzing", which enables the new address sanitizer (shipped in VS 16.9) and code coverage over the entire solution. Only a small subset of projects (those comprising original conhost, right now) are selected to build in this configuration, and even then only in Fuzzing|x64. It also adds a fuzzing-adapted build of conhost, which makes no server connections and handles no client applications. To do this, I've replicated a bit of the console startup routine into fuzzmain.cpp and made up some fake data. This is the bare minimum required to boot up Win32 interactivity (or VT interactivity!) and pretend that a process has connected. If we don't pretend that a process has connected, "conhost" will exit immediately. If we don't forge the process list, conhost will exit. If we can't provide a server handle, we can't provide a "device comm". Minor changes were necessary to server/host such that they would accept a preexisting "device comm". We use this new behavior to provide a "null" one that only hangs up threads and otherwise responds to requests successfully. This fuzzing-adapted build links LLVM's libFuzzer, which is an excellent coverage-based fuzzer that will produce a corpus of inputs that exercise unique codepaths. Eventually, we can use this to generate known-"good" inputs for anything. I've gone ahead and added a fuzz function that yeets bytes directly into WriteCharsLegacy, which was the original reason I went down this path. The implementation of LLVMFuzzerTestOneInput should be replaced with whatever you want to fuzz. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:23:17 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#27650