# Chat Anywhere > Leave comments or live chat on any web page! > Chat Anywhere adds a simple and elegant chat box to websites so that you can chat with anyone who is visiting the same web page as you. > You will be able to find out who is watching the same video, reading the same article or listening to the same song as you, chat with people who share common interests and make new friends! > You can also invite other people to join you on the same web page. [Google Webstore](https://chrome.google.com/webstore/detail/chat-anywhere/bldcellajihanglphncgjmceklbibjkk) [TOCM] [TOC] ## 0x00 序言 由于 Chat Anywhere 2.4.0 和更低版本,在线聊天处没有对 html 标签进行有效过滤与转义,导致可以通过拼接的方式绕过并执行任意 JavaScript 代码。 ## 0x01 分析 通常来说,由于 Goolge 为了安全性对插件进行了一定限制,从 Chrome Extenstion V2 开始,根据 [Content Security Policy (CSP)](https://developer.chrome.com/extensions/contentSecurityPolicy) 中的策略将不允许执行任何插件 html 内的 inline JavaScript 代码。 这样就有效避免了一些安全问题,如我们常见的 XSS。在插件内执行 js 时,将会看到 Console 中的以下告警。 ```html Refused to execute inline event handler because it violates the following Content Security Policy directive: "script-src 'self' blob: filesystem: chrome-extension-resource:". Either the 'unsafe-inline' keyword, a hash ('sha256-...'), or a nonce ('nonce-...') is required to enable inline execution. ``` 但是在 Chat Anywhere 引用的 js 文件 **2.4.0_0\chatbox-only\danmu.js** 中对载体的 document 插入了一个 className 为 danmuWrapper 的 div 标签,这个标签的主要作用是将接收到的消息在页面上以弹幕的形式进行展示。 ```javascript var danmuWrapper = document.createElement("div"); var dragX = 0; var dragY = 0; var dragging = false; danmuWrapper.className = 'danmuWrapper'; var showing = true; document.body.insertBefore(danmuWrapper, document.body.firstChild); ``` 但是由于这个 div 标签不在 CSP 策略的限制内,并且前后端都为对内容进行过滤和转义,那么在未设置 CSP 策略的载体页面中进行任意 JavaScript 代码执行。 Bypass ```html Submit:
HTML Code:
Submit: <
img src=x> HTML Code:
``` ## 0x02 PoC Get cookies ```html Submit: <
img src=x onerror=alert(document.cookie)> HTML Code:
```  ----