这个问题最早是可以追溯到2011年的一篇paper《Attacks on WebView in the Android System》14aK9s2c8@1M7q4)9K6b7g2)9J5c8W2)9J5c8Y4N6%4N6#2)9J5k6h3y4A6M7#2)9J5k6i4y4&6M7W2)9J5k6h3g2V1N6g2)9J5c8W2)9%4c8i4N6W2k6s2g2Q4x3V1k6d9k6i4y4W2j5i4u0U0K9q4)9J5c8Y4m8S2M7r3g2J5i4K6u0r3N6$3g2T1N6X3W2W2N6#2)9#2k6X3q4U0M7$3q4U0x3U0l9I4x3g2)9J5k6i4m8V1k6R3`.`. 这篇文章指出了addJavascriptInterface的方式在功能上带来的一些风险,比如你的app里实现了一个读写文件的类,然后使用addJavascriptInterface借口允许js调用,那么就可能导致攻击者直接调用这个class实现读写文件的操作。这种方式是最原始的风险,并没有直接指出getClass()方法的利用。
* Use addJavascriptInterface only if the application loads trusted content into the WebView component (Internet || IPC == sketch).
* Develop a custom JavaScript bridge using the shouldOverrideUrlLoading function. An application could check the newly loaded URL for a custom URI scheme and respond accordingly, but be careful about what functionality you expose via this custom URI scheme, and use input validation and output encoding to prevent the standard injection attacks.
* Reconsider why a bridge between JavaScript and Java is a necessity for this Android application and remove the bridge if feasible.