RegEx for XSS (Cross-Site Scripting)?

Ask a Question related to ASP.NET Security, Design and Development.

  1. #1

    Default RegEx for XSS (Cross-Site Scripting)?

    Trying to use the RegularExpressionValidator with the following
    expression [^0-9a-zA-Z] which functions well when using code
    with the System.Text.RegularExpressions class but the same
    expression will not function when used with the
    RegularExpressionValidator leaving me wondering "what?"

    The expression 'negates' any entry but those alphanumeric
    characters 0-9, a-z and A-Z thus I assume this expression
    would be sufficient to disallow XSS exploits noting as a matter
    of practice I will also continue to use Server.HtmlEncode.

    Comments regarding the dysfunction of the expression when used
    with the RegularExpressionValidator and 'your' methodology to
    prevent XSS exploits will be appreciated.

    --
    <%= Clinton Gallagher, "Twice the Results -- Half the Cost"
    Architectural & e-Business Consulting -- Software Development
    NET [email]csgallagher@REMOVETHISTEXTmetromilwaukee.com[/email]
    URL [url]http://www.metromilwaukee.com/clintongallagher/[/url]


    clintonG Guest

  2. Similar Questions and Discussions

    1. Prevent cross-scripting from the same domain
      Hello, i have 2 swf files, example1.swf and example2.swf, both on the same domain. I load example2 in a Loader control (Flex) from example1. I...
    2. CFAdmin Cross Site Scripting
      We recently signed up with ScanAlert, and they are reporting a XSS vulnerablilty in the CF Aministration. Path /CFIDE/administrator/enter.cfm ...
    3. Cross-domain scripting with Flash Player 6
      I'm sure I'm missing something basic here, but for some reason I'm not able to access a text file on another domain when my movie is viewed with...
    4. Cross Site Scripting & Custom Error Pages
      Hi, I have been investigating CSS vulnerabilites within my application and have a question. If I added malicious script tags to the Url these are...
    5. Cross-Site Scripting & sqlDataReader
      I am using sqlDataReader for Showing data from the Data base. But if the Data from sql is having tags like <script>alert()</script> then it shows an...
  3. #2

    Default Re: RegEx for XSS (Cross-Site Scripting)?

    Your expression should be enclosed in ^ and $ symbols so that every
    character must be in this set. In addition, the use of negation is
    incorrect. You want the validator to report an error when anything outside
    of the letter or digit character set is given. You have indicated that only
    these characters are illegal.
    Here's a reworked expression:
    ^[0-9a-zA-Z]*$

    Since you are attempting to improve your site's security, please be aware
    that there is a new product for ASP.NET sites to protect against XSS, SQL
    injection, Input Tampering, and Brute Force Input attacks. I am the author.
    It is "Visual Input Security" ([url]http://www.peterblum.com/vise/home.aspx[/url]).

    --- Peter Blum
    [url]www.PeterBlum.com[/url]
    Email: [email]PLBlum@PeterBlum.com[/email]
    Creator of "Professional Validation And More" at
    [url]http://www.peterblum.com/vam/home.aspx[/url]

    "clintonG" <csgallagher@REMOVETHISTEXTmetromilwaukee.com> wrote in message
    news:urp1KeclEHA.536@TK2MSFTNGP11.phx.gbl...
    > Trying to use the RegularExpressionValidator with the following
    > expression [^0-9a-zA-Z] which functions well when using code
    > with the System.Text.RegularExpressions class but the same
    > expression will not function when used with the
    > RegularExpressionValidator leaving me wondering "what?"
    >
    > The expression 'negates' any entry but those alphanumeric
    > characters 0-9, a-z and A-Z thus I assume this expression
    > would be sufficient to disallow XSS exploits noting as a matter
    > of practice I will also continue to use Server.HtmlEncode.
    >
    > Comments regarding the dysfunction of the expression when used
    > with the RegularExpressionValidator and 'your' methodology to
    > prevent XSS exploits will be appreciated.
    >
    > --
    > <%= Clinton Gallagher, "Twice the Results -- Half the Cost"
    > Architectural & e-Business Consulting -- Software Development
    > NET [email]csgallagher@REMOVETHISTEXTmetromilwaukee.com[/email]
    > URL [url]http://www.metromilwaukee.com/clintongallagher/[/url]
    >
    >

    Peter Blum Guest

  4. #3

    Default Re: RegEx for XSS (Cross-Site Scripting)?

    Thank you for responding Peter. I'll work with the revised expression
    and will certainly avail myself of your work as you referred.

    <%= Clinton Gallagher


    "Peter Blum" <PLBlum@Blum.info> wrote in message
    news:ec%23$ASplEHA.2680@TK2MSFTNGP15.phx.gbl...
    > Your expression should be enclosed in ^ and $ symbols so that every
    > character must be in this set. In addition, the use of negation is
    > incorrect. You want the validator to report an error when anything outside
    > of the letter or digit character set is given. You have indicated that
    only
    > these characters are illegal.
    > Here's a reworked expression:
    > ^[0-9a-zA-Z]*$
    >
    > Since you are attempting to improve your site's security, please be aware
    > that there is a new product for ASP.NET sites to protect against XSS, SQL
    > injection, Input Tampering, and Brute Force Input attacks. I am the
    author.
    > It is "Visual Input Security" ([url]http://www.peterblum.com/vise/home.aspx[/url]).
    >
    > --- Peter Blum
    > [url]www.PeterBlum.com[/url]
    > Email: [email]PLBlum@PeterBlum.com[/email]
    > Creator of "Professional Validation And More" at
    > [url]http://www.peterblum.com/vam/home.aspx[/url]
    >
    > "clintonG" <csgallagher@REMOVETHISTEXTmetromilwaukee.com> wrote in message
    > news:urp1KeclEHA.536@TK2MSFTNGP11.phx.gbl...
    > > Trying to use the RegularExpressionValidator with the following
    > > expression [^0-9a-zA-Z] which functions well when using code
    > > with the System.Text.RegularExpressions class but the same
    > > expression will not function when used with the
    > > RegularExpressionValidator leaving me wondering "what?"
    > >
    > > The expression 'negates' any entry but those alphanumeric
    > > characters 0-9, a-z and A-Z thus I assume this expression
    > > would be sufficient to disallow XSS exploits noting as a matter
    > > of practice I will also continue to use Server.HtmlEncode.
    > >
    > > Comments regarding the dysfunction of the expression when used
    > > with the RegularExpressionValidator and 'your' methodology to
    > > prevent XSS exploits will be appreciated.
    > >
    > > --
    > > <%= Clinton Gallagher, "Twice the Results -- Half the Cost"
    > > Architectural & e-Business Consulting -- Software Development
    > > NET [email]csgallagher@REMOVETHISTEXTmetromilwaukee.com[/email]
    > > URL [url]http://www.metromilwaukee.com/clintongallagher/[/url]
    > >
    > >
    >
    >

    clintonG Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139