• arichards (Veracode)

    Hi,

     

    The reason CWE-80 may be reported is because if the variable "url" is tainted with untrusted data, it may be possible to execute JavaScript in the client's browser. It is unclear from the snippet where the data originates, but for instance, assume "url" equals "javascript:alert(1)", then when location.href is set to "url", the client's browser will then execute "alert(1)". This example is not exhaustive as there are other URI schemes that can also introduce issues. In this instance it is recommended to validate that the URL conforms to an expected format such as HTTPS and that untrusted elements that construct the URL are sanitized before use. Keep in mind that simply checking that a URL is an expected scheme such as HTTPS does not remediate all risk, as the risk for CWE-601 open redirects may still be possible if compensating controls are not in place.

     

    If you have any other questions, I would recommend you schedule a consultation call to discuss, https://help.veracode.com/r/t_schedule_consultation , or you can send an email to Support@veracode.com with the application and scan name so we can look into the identified flaw to provide you more specific feedback.

     

    Regards,

    Veracode Application Security Consulting Team

    Expand Post
    • BMcKeever981950 (Community Member)

      "The reason CWE-80 may be reported is because if the variable "url" is tainted with untrusted data, it may be possible to execute JavaScript in the client's browser".

      Thanks for that explanation. Can I suggest that text like this be added to the description that gets attached to the findings? The current description talks only about http responses, which is very confusing when the scanner is flagging a js line that modifies window.location. Or perhaps this should be a separate CWE with its own description.

      Expand Post
  • cng168336 (Community Member)

    I tried to use Angular DomSanitizer sanitizer() function to process the URL before passing it to location.href but now I get this error:

     

    Attack Vector: ng.platformBrowser.DomSanitizer.sanitize

    Number of Modules Affected: 1

    Description: This call to ng.platformBrowser.DomSanitizer.sanitize() contains a cross-site scripting (XSS) flaw. The application populates the HTTP response with untrusted input, allowing an attacker to embed malicious content, such as Javascript code, which will be executed in the context of the victim's browser. XSS vulnerabilities are commonly exploited to steal or manipulate cookies, modify presentation of content, and compromise confidential information, with new attack vectors being discovered on a regular basis.

     

    I thought sanitize() should prevent the embedded Javascript code from being executed? What's the proper fixes for this?

    Expand Post
  • Hi,

     

    While this is a valid control to defend against this flaw category (if using the correct context!), Veracode Static Analysis currently does not recognize the DomSanitizer sanitizer function ( https://angular.io/api/platform-browser/DomSanitizer#sanitize ) as a Supported Cleansing Function ( https://help.veracode.com/r/review_cleansers ) yet.

     

    I would recommend proposing a mitigation, you can find more information on how to do this here: https://help.veracode.com/r/improve_mitigation .

    After proposing the mitigation you need to contact your security team to request approval.

     

    Please let us know if you have any remaining questions or concerns.

     

    Regards,

    Veracode Application Security Consulting Team

    Expand Post
    • cng168336 (Community Member)

      Seems like there’s no cleansing function for Javascript / Typescript. Are you planning to add support for that?
      • Hi @cng168336 (Community Member)​ ,

         

        We are actively looking into supporting the DomSanitizer, however we have no definite date at this time.

        To subscribe to updates for our Veracode Static Analysis product you can subscribe in the Notifications Settings ( you can find more information on where to find this in the Veracode Platform here: https://help.veracode.com/r/t_configure_emails).

         

        I would recommend proposing a mitigation, you can find more information on how to do this here: https://help.veracode.com/r/improve_mitigation .

        After proposing the mitigation you need to contact your security team to request approval.

         

        Thank you,

        Boy Baukema

        Expand Post
    • vkr536186 (Community Member)

      @Boy, Security Consultant (Veracode)​ ,

       

      So in future will Vera code support Angular's DomSanitizer? or we need to check some other way to fix this vulnerability.

  • nkakar430822 (Community Member)

    This vulnerability occurs when user-supplied data is not properly validated, encoded, or sanitized before being included in dynamic HTML content.

Topics (1)

No articles found
Loading

Ask the Community

Get answers, share a use case, discuss your favorite features, or get input from the community.