Growl/GNTPアドオンのセキュリティ問題について作者に報告しておいた

現状の Growl/GNTP アドオンの危険性については
Growl/GNTP 1.1.1が危険すぎる - hogehoge
で言及してもらっているとおり。

とりあえず、つたない英語を駆使して作者にこの問題を伝えた。(いきなりMLに流すのもなーって思ったので本人に直接送った)

Hi, Brian.

I was really excited about that GfW's support Greasemonkey.
Then I was wrote a experimental script and published it on my blog.

But... a few user commented about Growl/GNTP add-on's security issue.

Comment summary is as follows.

  • It is very dangerous because it is executed the code to which

eval() has evaluated with the chrome privilege given.

  • It enables a malicious attacker to attack users computer easily.

He wrote the experimental proof code about issue here.
http://www.paw.hi-ho.ne.jp/makochi/growl.html

- Run the code when 'fire' button click.
- This code will open your 'note pad' application.

And he told the solution about this issue as below.

  • Use JSON.jsm and JSON.parse() (or JSON.fromString()) method instead eval().
  • Or use evalInSandbox()

He wore a patch also.

--- browserOverlay.js.old       2009-06-16 20:51:57.125000000 +0900
+++ browserOverlay.js   2009-06-16 20:51:33.171875000 +0900
@@ -14,6 +14,11 @@
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 * */

+if (typeof JSON == "undefined"){
+    Components.utils.import("resource://gre/modules/JSON.jsm");
+    JSON.parse = JSON.fromString;
+    JSON.stringfy = JSON.toString;
+}
 var growlgntp = {
    APPNAME : "Firefox",

@@ -137,14 +142,14 @@
    externalRegisterHandler : function(e){
        var attr = e.target.getAttribute("data");
        //alert(attr);
-        var data = eval('(' + attr + ')');
+        var data = JSON.parse(attr);
        this.growl.register(data.appName, data.icon, data.notificationTypes);
    },

    externalNotifyHandler : function(e){
        var attr = e.target.getAttribute("data");
        //alert(attr);
-        var data = eval('(' + attr + ')');
+        var data = JSON.parse(attr);
        this.growl.notify(data.appName, data.type, data.title,
data.text, data.icon);
    }
 };

Please consider about this issue.

Best regards.

For your information, my blog entry is here.
http://d.hatena.ne.jp/snaka72/20090613/1244895578

and ... Google translated version is here.
http://translate.google.com/translate?hl=en&sl=ja&u=http://d.hatena.ne.jp/snaka72/20090613/1244895578&ei=fhg4SrGqCdSIkAXz5pHoDQ&sa=X&oi=translate&resnum=3&ct=result&prev=/search%3Fq%3Dsnaka72%2Bhatena%2B%25E3%2582%25B0%25E3%2583%25AA%25E3%2583%25A2%25E3%2583%25B3%2B%25E3%2582%25B3%25E3%2583%25A1%25E3%2583%25B3%25E3%2583%2588%2B%25E3%2581%25AF%25E3%2581%25A6%25E3%2581%25AA%2Bsite:d.hatena.ne.jp%26hl%3Den

  • -

snaka
http://sumimasen2.blogspot.com/
http://d.hatena.ne.jp/snaka72/

この手の反応には素早く対応してきている人なので、すぐに対応してくれることを期待している。

追記:2009.6.17

アドオンの修正版がAMOに登録された。
その修正版を取得してそのコードをちょっと変更してちゃんと動いているか確認してみる。以下のようにtry-catchしてみてちゃんと例外が発生するかどうかを見てみる。

        try {
        var data = JSON.parse(attr);
        } catch(e) {
          alert("JSON.parse error");
        }

実行結果は以下のとおり。ちゃんと例外が発生するようになった。
http://gyazo.com/a508fada335af1f02598e51c183360c2.png