Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulnerable to Cross-site Scripting (XSS) #177

Closed
stanleyowen opened this issue May 23, 2021 · 1 comment
Closed

Vulnerable to Cross-site Scripting (XSS) #177

stanleyowen opened this issue May 23, 2021 · 1 comment
Assignees
Labels
bug Something isn't working dependencies fixed

Comments

@stanleyowen
Copy link
Owner

Describe the bug
Unsanitized input from data from a remote resource flows into innerHTML, where it is used to dynamically construct the HTML page on client side. This may result in a DOM Based Cross-Site Scripting attack (DOMXSS).
client/src/components/account.component.js Line 73

    const BackupCodes = () => {
        const codes = [...valid, ...invalid]
        // function validateToken(token) {
        //     for (let a=0; valid.length; a++){
        //         if(token === valid[a]) return true
        //         else if(a === valid.length-1 && token !== valid[a].toLowerCase()) return false
        //     }
        // }
        let table = document.createElement('table')
        let row = document.createElement('tr')
        let column = document.createElement('td')
        table.classList.add('isCentered', 'full-width', 'no-border')
        for (let x=0; x<codes.length; x++) {
            if(x%2 === 0 && x !== 0) {table.innerHTML += row.outerHTML; column.innerHTML = codes[x]; row.innerHTML = column.outerHTML}
            else if(x === codes.length - 1) {column.innerHTML = codes[x]; row.innerHTML += column.outerHTML; table.innerHTML += row.outerHTML}
            else{column.innerHTML = codes[x]; row.innerHTML += column.outerHTML}
        } return table.outerHTML
    }

Expected behavior
This issue should be fixed as soon as possible to prevent Cross-site Scripting (XSS) Attack.

Desktop (please complete the following information):

  • OS: Windows 10 OS Version 2009 (Build 19042.985)
  • Browser Chrome
  • Version 90.0.4430.212
@stanleyowen stanleyowen self-assigned this May 23, 2021
@stanleyowen stanleyowen added the bug Something isn't working label May 23, 2021
@stanleyowen
Copy link
Owner Author

After reading some references, may these articles maybe we will use dompurify dependency which sanitize html into a cleaner code and prevents DOM Based Cross-Site Scripting attack (DOMXSS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working dependencies fixed
Projects
None yet
Development

No branches or pull requests

1 participant