-
Notifications
You must be signed in to change notification settings - Fork 15.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: cap sendInputEvent text length at n-1 #27827
Conversation
This comment has been minimized.
This comment has been minimized.
Release Notes Persisted
|
I have automatically backported this PR to "11-x-y", please check out #27853 |
I have automatically backported this PR to "10-x-y", please check out #27854 |
I have automatically backported this PR to "12-x-y", please check out #27855 |
@nornagon Does '2' as described represent a security risk? |
@attritionorg technically I suppose yes, but I'd rank it as very difficult or impossible to exploit, as the OOB access is only a couple of bytes wide, and into other data on the stack that is not very interesting. Further, this is only in the main process, which is ostensibly trusted code. |
@nornagon Great, thank you for confirming! |
Description of Change
This fixes two bugs with
sendInputEvent
, detected by ASan.memset
was not clearing the full buffer, as the size of eachelement of the array is 2 bytes, not 1.
pointer, which causes the length of the string to be computed by seeking for
a null terminator. However, this results in an out-of-bounds access as we
often fill all 4 characters of both
text
andunmodified_text
withnon-null values.
It looks like this code was inspired by
BuildCharEvent
in content/renderer/pepper/event_conversion.cc, so I've updated this to be a
little closer to that code. I think the upstream code also has this issue but
gets away with it because it doesn't set
unmodified_text
, so there's always a\0
aftertext
due to the struct layout.I'm not sure if we actually need
unmodified_text
---the pepper converter doesnot fill it in.
Further, we fill
text
fromkeyCode
, which is a bit of an odd choice. Thevalue is supposed to represent the text that should be inserted, which for the
key code
Escape
is not"Esca"
. It's not clear to me what the "right" pathforward is here, but this at least prevents the OOB access.
Checklist
npm test
passesRelease Notes
Notes: Fixed an out-of-bounds access in
WebContents.sendInputEvent
.