Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở
#21,257 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
javascript
Lĩnh vực
security

Hướng nghiên cứu

Bắt đầu với bộ truy vấn security-extended của JavaScript và xem xét cách các phản hồi của fetch().json() và insertAdjacentHTML được mô hình hóa. Xác định xem luồng này có bị loại trừ một cách có chủ ý hay cần mô hình hóa nguồn và sink, sau đó kiểm chứng kết luận dựa trên ví dụ được cung cấp và xác nhận liệu có ожида một kết quả XSS hay không.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.
Ngôn ngữ chính
CodeQL
Star
10.1k
Fork
2.1k
Merge trung bình
2 ngày 16 giờ
Pull request đã merge (30 ngày)
143

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/codeql

Tất cả issue của github/codeql

Issue tương tự

Thêm issue về Security

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.