Skip to content

Commit

Permalink
Fix Window Title Reporting security issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maximus5 committed Dec 19, 2022
1 parent b57048d commit cd9bb86
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/ConEmuCD/ConAnsiImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,10 +985,11 @@ bool SrvAnsiImpl::ReportString(LPCWSTR asRet)
LPCWSTR pc = asRet;
for (int i = 0; i < nLen; i++, p++, pc++)
{
const char ch = (wcschr(UNSAFE_CONSOLE_REPORT_CHARS, *pc) == nullptr) ? *pc : L' ';
p->EventType = KEY_EVENT;
p->Event.KeyEvent.bKeyDown = TRUE;
p->Event.KeyEvent.wRepeatCount = 1;
p->Event.KeyEvent.uChar.UnicodeChar = *pc;
p->Event.KeyEvent.uChar.UnicodeChar = ch;
}

DumpKnownEscape(asRet, nLen, SrvAnsi::de_Report);
Expand Down
3 changes: 2 additions & 1 deletion src/ConEmuHk/Ansi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2505,10 +2505,11 @@ BOOL CEAnsi::ReportString(LPCWSTR asRet)
LPCWSTR pc = asRet;
for (size_t i = 0; i < nLen; i++, p++, pc++)
{
const char ch = (wcschr(UNSAFE_CONSOLE_REPORT_CHARS, *pc) == nullptr) ? *pc : L' ';
p->EventType = KEY_EVENT;
p->Event.KeyEvent.bKeyDown = TRUE;
p->Event.KeyEvent.wRepeatCount = 1;
p->Event.KeyEvent.uChar.UnicodeChar = *pc;
p->Event.KeyEvent.uChar.UnicodeChar = ch;
}

DumpKnownEscape(asRet, nLen, de_Report);
Expand Down
3 changes: 3 additions & 0 deletions src/common/WConsole.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define DISABLE_NEWLINE_AUTO_RETURN 0x0008
#endif

// These keys should not be reported back to console input
#define UNSAFE_CONSOLE_REPORT_CHARS L"\r\n\t"

struct MY_CONSOLE_SCREEN_BUFFER_INFOEX
{
ULONG cbSize;
Expand Down

1 comment on commit cd9bb86

@DRSDavidSoft
Copy link

Choose a reason for hiding this comment

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

Note: #2536 has proper security

Please sign in to comment.