Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

JavaScript DOM XSS via fetch().json() → insertAdjacentHTML not detected by CodeQL

オープン
#21,257 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
javascript
領域
security

調査の方向性

JavaScript の security-extended クエリスイートから始め、fetch().json() のレスポンスと insertAdjacentHTML がどのようにモデル化されているかを確認します。このフローが意図的に除外されているのか、それともソースとシンクのモデル化が必要なのかを判断し、その結論を提供された例に照らして検証したうえで、XSS の結果が想定されるかどうかを確認します。

索引モデルが issue の本文から書いたものです。

説明

Description of the false positive

We are trying to better understand the design decisions behind JavaScript XSS detection in CodeQL, specifically around taint sources involving network responses.

I have a piece of client-side JavaScript that builds HTML using insertAdjacentHTML with values coming from a fetch().json() response. From an application-security perspective, this is treated as a potential DOM XSS risk in our project, but CodeQL does not report it.

I’d like to confirm whether this behavior is by design, and if so, what the recommended way is to model this trust boundary.

Code samples or links to source code

            function loadMessageLogs(pageSize, continuationToken) {
                let url = '?handler=LoadMessageLogs&pageSize=' + pageSize;
                if (continuationToken)
                    url += '&continuationToken=' + encodeURIComponent(continuationToken);

                fetch(url)
                    .then(response => response.json())
                    .then(data => {
                        const tbody = document.querySelector("#tblMessageLogs tbody");
                        tbody.innerHTML = "";

                        if (!data.items || data.items.length === 0) {
                            messageLogs.hidden = true;
                            noMessageLogs.hidden = false;
                        }
                        else {

                            data.items.forEach(item => {
                                const link = `<a href="/MessageLogs/Details/${item.messageId}">View message</a>`;
                                const row = `<tr>
                                        <td>${item.createdDate}</td>
                                        <td>${item.messageId}</td>
                                        <td>${item.interfaceId ?? ''}</td>
                                        <td>${item.target ?? ''}</td>
                                        <td>${item.mpanCore ?? ''}</td>
                                        <td>${item.meterId ?? ''}</td>
                                        <td>${link}</td>
                                        </tr>`;
                                tbody.insertAdjacentHTML('beforeend', row);
                            });

                            PagingModule.updatePaging(data.continuationToken)
                            messageLogs.hidden = false;
                            noMessageLogs.hidden = true;
                        }
                    });
            }

In our case, data.items[*] ultimately contains data that may originate from user input stored and returned by the backend.

  • We are running the javascript-security-extended query suite.
  • No XSS issue is reported for this code.
主要言語
CodeQL
スター
10.1k
フォーク
2.1k
平均マージ
2日 16時間
マージ済み PR(30日)
143

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

github/codeql のほかの issue

github/codeql の issue をすべて見る

似ている issue

Security の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。