Harden launcher: enable CFG/CET, restrict DLL search path, verify ConEmu before launch
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 65/100
Research direction
The work is in launcher/src/CmderLauncher.cpp and launcher/CmderLauncher.vcxproj. Start by building the launcher to understand the project structure. Review the specific lines mentioned for the undefined behavior with swprintf_s and the ConEmu launch path. The verification step uses dumpbin to check security flags after building.
Written by the indexing model from the issue text.
Description
Summary
The launcher (launcher/src/CmderLauncher.cpp) is built with the MSVC defaults only, and it starts ConEmu without checking the file first. This issue collects some low-cost hardening. It's a follow-up to #3116.
Proposed changes
-
Turn on Control Flow Guard and CET shadow stacks.
launcher/CmderLauncher.vcxprojsets neither, so both are off. ASLR and DEP are already on by default. Add to the Release configurations:<ControlFlowGuard>Guard</ControlFlowGuard>(compile)<CETCompat>true</CETCompat>(link)
-
Restrict the DLL search path. Call
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_SYSTEM32)at the start ofwWinMain, or link with/DEPENDENTLOADFLAG:0x800. That way a DLL planted next toCmder.exeisn't picked up. This matters most for installs in admin-only locations (e.g. global Scoop or Chocolatey installs). -
Check ConEmu before launching it.
StartCmderpassesvendor\conemu-maximus5\ConEmu64.exe(orConEmu.exe) toCreateProcesswithout checking it (CmderLauncher.cpp#L422-L426, #L481). Portable installs are user-writable, so a replaced binary would run under Cmder's name. Options:WinVerifyTrustagainst the expected publisher, if upstream ConEmu binaries are signed; or- compare against a SHA-256 recorded at build time (see #3116).
-
Stop reading and writing the same buffer in
swprintf_s. The ConEmu command line is built withswprintf_s(args, L"%s ...", args, ...)(#L429-L461). Because the source and destination are the same buffer, the result is undefined behaviour. It works with MSVC today, but building the string withstd::wstringwould be simpler and safe.
Verifying
On a Windows runner, after building:
dumpbin /headers Cmder.exe | Select-String "Dynamic base|NX compatible|High Entropy|Guard|CET"
This could be added as a CI step so the flags don't regress.
- Dominant language
- PowerShell
- Stars
- 27k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from cmderdev/cmder
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
-
Difficulty 3/5 1-2 days Newbie friendliness 40/100
-
Difficulty 3/5 1-2 days Newbie friendliness 65/100
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
stephrobert/dsoxlab#238 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
sublimehq/package_control#1779 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
nwg-piotr/nwg-displays#145 ·
-
Bob Shell support Openenhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100