Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Aperta
#21,257 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript
Ambito
security

Direzione di ricerca

Inizia con la suite di query di sicurezza security-extended di JavaScript e verifica come vengono modellate le risposte di fetch().json() e insertAdjacentHTML. Determina se questo flusso è escluso intenzionalmente o se richiede la modellazione di una sorgente e di un sink, quindi convalida la conclusione rispetto all’esempio fornito e conferma se è previsto un risultato XSS.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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.
Lingua principale
CodeQL
Stelle
10.1k
Fork
2.1k
Merge medio
2g 16h
PR unite (30g)
143

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di github/codeql

Tutte le issue di github/codeql

Issue simili

Altre issue su Security

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.