(Repost with correct account)
It's possible to fake keyboard/mouse events to manipulate dom nodes and make the scripts listening the events believe that they are the users intention.
I didn't think it was possible for JavaScript to simulate keyboard events (to prevent impersonation of the user).
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
--
So is there an alternative way to tell if an event is faked or real?
And isn't isTrust readonly? How can it be overridden? How is it implemented in firefox?
Looks interesting, can we do the same thing in chrome?
The mozilla patch looks not very complicated.
--- a/dom/webidl/Event.webidl +++ b/dom/webidl/Event.webidl @@ -25,16 +25,17 @@ interface Event { void stopPropagation(); void stopImmediatePropagation(); readonly attribute boolean bubbles; readonly attribute boolean cancelable; void preventDefault(); readonly attribute boolean defaultPrevented; + [Unforgeable] readonly attribute boolean isTrusted; readonly attribute DOMTimeStamp timeStamp; [Throws] void initEvent(DOMString type, boolean bubbles, boolean cancelable); }; // Mozilla specific legacy stuff.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe: http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
/Daniel
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe: http://groups.google.com/a/chromium.org/group/chromium-dev
The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
2014年1月10日 下午7:42于 "Bernhard Bauer" <bau...@chromium.org>写道:On Fri, Jan 10, 2014 at 11:12 AM, Daniel Bratell <bra...@opera.com> wrote:
On Fri, 10 Jan 2014 06:19:09 +0100, Adam Barth <aba...@chromium.org> wrote:There is a difference between user initiated/created events and script created events though, and that distinction can be interesting to scripts (it's certainly very interesting to C++ code looking at events).
There is no way to tell whether an event is real or fake. There isn't any distinction between real >and fake events. Events are just events.
And assuming browsers/users/pages don't inject malicious scripts into themselves, they can trust the Event.isTrusted attribute.If you control all the code yourself (i.e. nothing gets injected), couldn't you just do the opposite and set an isSynthesized flag on synthesized events? If code does get injected, there's really not much you can do -- the code runs in the same execution context (assuming an XSS like the original email said), and it's indistinguishable from the "real" code.
Bernhard./Daniel
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe: http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
2014年1月10日 下午11:20于 "Torne (Richard Coles)" <to...@chromium.org>写道:
>
> On 10 January 2014 12:20, James Su <su...@chromium.org> wrote:
>>
>> The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
>
> From this description it sounds like the virtual keyboard is being added to the *page's* DOM by the extension. Am I understanding correctly?
>
> If so, then this is insecure anyway, no? If the threat is "the web page contains malicious JS which wants to force a certain sequence of virtual keyboard clicks", then it seems like you can achieve this without generating any "fake" click events at all just by manipulating the DOM something like this:
>
> 1) Find the DOM node corresponding to the virtual keyboard key you want to be clicked next
> 2) Make a visual duplicate of it to leave in place
> 3) Make the original DOM node invisible in some way
> 4) Reposition that node so that it's always right underneath the user's mouse cursor as it moves
>
Interesting idea, but can't the extension avoid it by chrcking the DOM node's positiion and visibility from time to time?
> Now whenever the user clicks on something on the page, they'll click on the virtual keyboard and type something into your iframe. You can add your own onclick handler to the same DOM node and then have *that* handler inject a fake click event on whatever was underneath at that point on the page, so the user doesn't wonder why their clicks aren't doing anything. If you want a plausible reason for the user to click on your page content a lot without navigating away, just make your malicious page a match-three game. :)
>
> It just seems like there's no way for anything inside the page's DOM to ever be secure against the page being malicious. If an extension wants to provide a virtual keyboard securely this would have to be somewhere *outside* the page's DOM (e.g. in a separate window, or extension popup, or whatever)
It's not practical on chrome, because AFAIU, it's not possible for an extension to show a separate window without stealing the keyboard focus. Please let me know if there is a way to do it.
>
>>
>> 2014年1月10日 下午7:42于 "Bernhard Bauer" <bau...@chromium.org>写道:
>>
>>> On Fri, Jan 10, 2014 at 11:12 AM, Daniel Bratell <bra...@opera.com> wrote:
>>>>
>>>> On Fri, 10 Jan 2014 06:19:09 +0100, Adam Barth <aba...@chromium.org> wrote:
>>>>
>>>>> There is no way to tell whether an event is real or fake. There isn't any distinction between real >and fake events. Events are just events.
>>>>
>>>>
>>>> There is a difference between user initiated/created events and script created events though, and that distinction can be interesting to scripts (it's certainly very interesting to C++ code looking at events).
>>>>
>>>> And assuming browsers/users/pages don't inject malicious scripts into themselves, they can trust the Event.isTrusted attribute.
>>>
>>>
>>> If you control all the code yourself (i.e. nothing gets injected), couldn't you just do the opposite and set an isSynthesized flag on synthesized events? If code does get injected, there's really not much you can do -- the code runs in the same execution context (assuming an XSS like the original email said), and it's indistinguishable from the "real" code.
>>> Bernhard.
>>>
>>>>
>>>> /Daniel
>>>>
>>>>
>>>> --
>>>> --
>>>> Chromium Developers mailing list: chromi...@chromium.org
>>>> View archives, change email options, or unsubscribe: http://groups.google.com/a/chromium.org/group/chromium-dev
>>>>
>>>> To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev...@chromium.org.
2014年1月10日 下午11:20于 "Torne (Richard Coles)" <to...@chromium.org>写道:Interesting idea, but can't the extension avoid it by chrcking the DOM node's positiion and visibility from time to time?
>
> On 10 January 2014 12:20, James Su <su...@chromium.org> wrote:
>>
>> The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
>
> From this description it sounds like the virtual keyboard is being added to the *page's* DOM by the extension. Am I understanding correctly?
>
> If so, then this is insecure anyway, no? If the threat is "the web page contains malicious JS which wants to force a certain sequence of virtual keyboard clicks", then it seems like you can achieve this without generating any "fake" click events at all just by manipulating the DOM something like this:
>
> 1) Find the DOM node corresponding to the virtual keyboard key you want to be clicked next
> 2) Make a visual duplicate of it to leave in place
> 3) Make the original DOM node invisible in some way
> 4) Reposition that node so that it's always right underneath the user's mouse cursor as it moves
>
> Now whenever the user clicks on something on the page, they'll click on the virtual keyboard and type something into your iframe. You can add your own onclick handler to the same DOM node and then have *that* handler inject a fake click event on whatever was underneath at that point on the page, so the user doesn't wonder why their clicks aren't doing anything. If you want a plausible reason for the user to click on your page content a lot without navigating away, just make your malicious page a match-three game. :)It's not practical on chrome, because AFAIU, it's not possible for an extension to show a separate window without stealing the keyboard focus. Please let me know if there is a way to do it.
>
> It just seems like there's no way for anything inside the page's DOM to ever be secure against the page being malicious. If an extension wants to provide a virtual keyboard securely this would have to be somewhere *outside* the page's DOM (e.g. in a separate window, or extension popup, or whatever)
2014年1月11日 上午12:02于 "Torne (Richard Coles)" <to...@chromium.org>写道:
>
> On 10 January 2014 16:00, James Su <su...@chromium.org> wrote:
>>
>>
>> 2014年1月10日 下午11:20于 "Torne (Richard Coles)" <to...@chromium.org>写道:
>>
>>
>> >
>> > On 10 January 2014 12:20, James Su <su...@chromium.org> wrote:
>> >>
>> >> The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
>> >
>> > From this description it sounds like the virtual keyboard is being added to the *page's* DOM by the extension. Am I understanding correctly?
>> >
>> > If so, then this is insecure anyway, no? If the threat is "the web page contains malicious JS which wants to force a certain sequence of virtual keyboard clicks", then it seems like you can achieve this without generating any "fake" click events at all just by manipulating the DOM something like this:
>> >
>> > 1) Find the DOM node corresponding to the virtual keyboard key you want to be clicked next
>> > 2) Make a visual duplicate of it to leave in place
>> > 3) Make the original DOM node invisible in some way
>> > 4) Reposition that node so that it's always right underneath the user's mouse cursor as it moves
>> >
>> Interesting idea, but can't the extension avoid it by chrcking the DOM node's positiion and visibility from time to time?
>
>
> It *might* be able to catch the page in the act, sure, but then you are playing a cat and mouse game - the author of the page can read the source code for your extension to see what you check, and work around your checks.
>
>>
>> > Now whenever the user clicks on something on the page, they'll click on the virtual keyboard and type something into your iframe. You can add your own onclick handler to the same DOM node and then have *that* handler inject a fake click event on whatever was underneath at that point on the page, so the user doesn't wonder why their clicks aren't doing anything. If you want a plausible reason for the user to click on your page content a lot without navigating away, just make your malicious page a match-three game. :)
>> >
>> > It just seems like there's no way for anything inside the page's DOM to ever be secure against the page being malicious. If an extension wants to provide a virtual keyboard securely this would have to be somewhere *outside* the page's DOM (e.g. in a separate window, or extension popup, or whatever)
>> It's not practical on chrome, because AFAIU, it's not possible for an extension to show a separate window without stealing the keyboard focus. Please let me know if there is a way to do it.
>
>
> I'm not saying there *is* a good, secure way to do this, I am just pointing out that this way is not secure and you shouldn't do it :)
The problem is that displaying the virtual keyboard inside the page's DOM is the only feasible way we found until now. We need to live with it until there is a better way, but meanwhile we do want to make the current solution as secure as possible.
2014年1月11日 上午12:02于 "Torne (Richard Coles)" <to...@chromium.org>写道:The problem is that displaying the virtual keyboard inside the page's DOM is the only feasible way we found until now. We need to live with it until there is a better way, but meanwhile we do want to make the current solution as secure as possible.
>
> On 10 January 2014 16:00, James Su <su...@chromium.org> wrote:
>>
>>
>> 2014年1月10日 下午11:20于 "Torne (Richard Coles)" <to...@chromium.org>写道:
>>
>>
>> >
>> > On 10 January 2014 12:20, James Su <su...@chromium.org> wrote:
>> >>
>> >> The real scenario is that a website containing malicious code may control the code injected by a chrome extension (a virtual keyboard in the original case) by faking mouse events to achieve some unexpected goals, e.g. click the virtual keyboard drawn by the extension to input malicious content into an iframe with a page from another website. It's possible because the extension injects code into both outside and nested pages, and the virtual keyboard is drawn on the outside page. It's perfect legal if the user clicks the virtual keyboard to input something into the nested page. But it'll be dangerous if a malicious script in the outside page can do the same thing by faking events. So the virtual keyboard extension surely want to avoid such thing by only accept trusted mouse events.
>> >
>> > From this description it sounds like the virtual keyboard is being added to the *page's* DOM by the extension. Am I understanding correctly?
>> >
>> > If so, then this is insecure anyway, no? If the threat is "the web page contains malicious JS which wants to force a certain sequence of virtual keyboard clicks", then it seems like you can achieve this without generating any "fake" click events at all just by manipulating the DOM something like this:
>> >
>> > 1) Find the DOM node corresponding to the virtual keyboard key you want to be clicked next
>> > 2) Make a visual duplicate of it to leave in place
>> > 3) Make the original DOM node invisible in some way
>> > 4) Reposition that node so that it's always right underneath the user's mouse cursor as it moves
>> >
>> Interesting idea, but can't the extension avoid it by chrcking the DOM node's positiion and visibility from time to time?
>
>
> It *might* be able to catch the page in the act, sure, but then you are playing a cat and mouse game - the author of the page can read the source code for your extension to see what you check, and work around your checks.
>
>>
>> > Now whenever the user clicks on something on the page, they'll click on the virtual keyboard and type something into your iframe. You can add your own onclick handler to the same DOM node and then have *that* handler inject a fake click event on whatever was underneath at that point on the page, so the user doesn't wonder why their clicks aren't doing anything. If you want a plausible reason for the user to click on your page content a lot without navigating away, just make your malicious page a match-three game. :)
>> >
>> > It just seems like there's no way for anything inside the page's DOM to ever be secure against the page being malicious. If an extension wants to provide a virtual keyboard securely this would have to be somewhere *outside* the page's DOM (e.g. in a separate window, or extension popup, or whatever)
>> It's not practical on chrome, because AFAIU, it's not possible for an extension to show a separate window without stealing the keyboard focus. Please let me know if there is a way to do it.
>
>
> I'm not saying there *is* a good, secure way to do this, I am just pointing out that this way is not secure and you shouldn't do it :)
--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/a5cd0182-2ce7-49c1-911d-44a49073b428%40chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/33cfafc6-3a10-486c-b448-dae23b7de39a%40chromium.org.