SonarSource Rules
  • Products

    In-IDE

    Code Quality and Security in your IDE with SonarQube Ide

    IDE extension that lets you fix coding issues before they exist!

    Discover SonarQube for IDE

    SaaS

    Code Quality and Security in the cloud with SonarQube Cloud

    Setup is effortless and analysis is automatic for most languages

    Discover SonarQube Cloud

    Self-Hosted

    Code Quality and Security Self-Hosted with SonarQube Server

    Fast, accurate analysis; enterprise scalability

    Discover SonarQube Server
  • SecretsSecrets
  • ABAPABAP
  • AnsibleAnsible
  • ApexApex
  • AzureResourceManagerAzureResourceManager
  • CC
  • C#C#
  • C++C++
  • CloudFormationCloudFormation
  • COBOLCOBOL
  • CSSCSS
  • DartDart
  • DockerDocker
  • FlexFlex
  • GitHub ActionsGitHub Actions
  • GoGo
  • HTMLHTML
  • JavaJava
  • JavaScriptJavaScript
  • JSONJSON
  • JCLJCL
  • KotlinKotlin
  • KubernetesKubernetes
  • Objective CObjective C
  • PHPPHP
  • PL/IPL/I
  • PL/SQLPL/SQL
  • PythonPython
  • RPGRPG
  • RubyRuby
  • RustRust
  • ScalaScala
  • ShellShell
  • SwiftSwift
  • TerraformTerraform
  • TextText
  • TypeScriptTypeScript
  • T-SQLT-SQL
  • VB.NETVB.NET
  • VB6VB6
  • XMLXML
  • YAMLYAML
HTML

HTML static code analysis

Unique rules to find Bugs, Security Hotspots, and Code Smells in your HTML code

  • All rules 83
  • Bug23
  • Security Hotspot3
  • Code Smell57
Filtered: 1 rule found
phishing
    Impact
      Clean code attribute
        1. Authorizing an opened window to access back to the originating window is security-sensitive

           Security Hotspot

        Authorizing an opened window to access back to the originating window is security-sensitive

        intentionality - complete
        security
        Security Hotspot
        • cwe
        • phishing

        A newly opened window having access back to the originating window could allow basic phishing attacks (the window.opener object is not null and thus window.opener.location can be set to a malicious website by the opened page).

        For instance, an attacker can put a link (say: "http://example.com/mylink") on a popular website that changes, when opened, the original page to "http://example.com/fake_login". On "http://example.com/fake_login" there is a fake login page which could trick real users to enter their credentials.

        Ask Yourself Whether

        • The application opens untrusted external URL.

        There is a risk if you answered yes to this question.

        Recommended Secure Coding Practices

        Use noopener to prevent untrusted pages from abusing window.opener.

        Note: In Chrome 88+, Firefox 79+ or Safari 12.1+ target=_blank on anchors implies rel=noopener which make the protection enabled by default.

        Sensitive Code Example

        <a href="http://example.com/dangerous" target="_blank"> <!-- Sensitive -->
        
        <a href="{{variable}}" target="_blank"> <!-- Sensitive -->
        

        Compliant Solution

        To prevent pages from abusing window.opener, use rel=noopener on <a href=> to force its value to be null on the opened pages.

        <a href="http://petssocialnetwork.io" target="_blank" rel="noopener">
        

        Exceptions

        No Issue will be raised when href contains a hardcoded relative url as there it has less chances of being vulnerable. An url is considered hardcoded and relative if it doesn’t start with http:// or https://, and if it does not contain any of the characters {}$()[]

        <a href="internal.html" target="_blank" >
        

        See

        • OWASP - Top 10 2021 Category A5 - Security Misconfiguration
        • Reverse Tabnabbing
        • CWE - CWE-1022 - Use of Web Link to Untrusted Target with window.opener Access
        • OWASP - Top 10 2017 Category A6 - Security Misconfiguration
        • https://mathiasbynens.github.io/rel-noopener/
          Available In:
        • SonarQube IdeCatch issues on the fly,
          in your IDE
        • SonarQube CloudDetect issues in your GitHub, Azure DevOps Services, Bitbucket Cloud, GitLab repositories
        • SonarQube Community BuildAnalyze code in your
          on-premise CI
          Available Since
          9.1
        • SonarQube ServerAnalyze code in your
          on-premise CI
          Developer Edition
          Available Since
          9.1

        © 2008-2025 SonarSource SA. All rights reserved.

        Privacy Policy | Cookie Policy | Terms of Use