Making WordPress.org

Changeset 9074


Ignore:
Timestamp:
07/24/2019 06:42:12 AM (7 years ago)
Author:
dd32
Message:

Trac: Security Question: Add some tweaks to the Security Questioncatch those pentesting Trac.

  • Displays the question when onload=, onerror=, or <script is present.
  • Only disables the Submit button, leaving Preview available.
  • Asks the Security question on Ticket previews in addition to newly written tickets.
  • Doesn't hide the question if they remove the keyword that triggered it. (There existed code to hide it in that case, but it didn't work. It's now a bit more specific)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/style/trac/trac-security.js

    r7901 r9074  
    44(function($) {
    55        var propertyform = $( '#propertyform' ),
    6                 submit = propertyform.find( 'input[type="submit"]' );
     6                submit = propertyform.find( 'input[type="submit"][name="submit"]' );
    77
    88        if ( $( document.body ).hasClass( 'security' ) ) {
    … …  
    3333
    3434                        return ( overlap.length !== 0 );
     35                },
     36
     37                seems_like_pentest : function(str) {
     38                        return (
     39                                str.toLowerCase().indexOf( 'onerror=' ) != -1
     40                                ||
     41                                str.toLowerCase().indexOf( 'onload=' ) != -1
     42                                ||
     43                                str.toLowerCase().indexOf( '<script' ) != -1
     44                        );
    3545                }
    3646        };
    … …  
    4757                } else {
    4858                        // We need to add the checkbox
    49                         $( '.buttons' ).before( '<p id="security-question"><label><input type="checkbox" name="sec_question" />' +
     59                        $( '.buttons' ).before(
     60                                '<p id="security-question"><label><input type="checkbox" name="sec_question" />' +
    5061                                '&nbsp;I am <strong>not</strong> reporting a security issue</label>' +
    51                                 ' &mdash; report <a href="http://make.wordpress.org/core/handbook/reporting-security-vulnerabilities/">security issues</a> to the <a href="https://hackerone.com/wordpress">WordPress HackerOne program</a></p>' );
     62                                ' &mdash; report <a href="http://make.wordpress.org/core/handbook/reporting-security-vulnerabilities/">security issues</a> to the <a href="https://hackerone.com/wordpress">WordPress HackerOne program</a>' +
     63                                '</p>'
     64                        );
    5265                }
    5366
    … …  
    5669        function hide_box() {
    5770                submit.prop( 'disabled', false );
    58                 $( '#sec_question' ).hide();
     71                // Continue to ask the question, just don't require it to submit the ticket.
     72                // $( '#security-question' ).hide();
    5973        }
    6074
    61         jQuery( '#field-summary, #field-description, #field-keywords' ).on( 'keyup', function() {
    62                 var entry = $(this).val();
     75        function check_field_value( $el ) {
     76                var entry = $el.val();
    6377
    6478                if ( wp.trac_security.has_overlap( entry, wp.trac_security.badwords ) ) {
     79                        show_box();
     80                } else if ( wp.trac_security.seems_like_pentest( entry ) ) {
    6581                        show_box();
    6682                } else {
    6783                        hide_box();
    6884                }
    69         });
     85        }
     86
     87        // Check the field value upon keyup
     88        jQuery( '#field-summary, #field-description, #field-keywords' ).on( 'keyup', function() {
     89                return check_field_value( $(this) );
     90        } );
     91
     92        // Trigger on pageload too, ie. upon Preview
     93        jQuery( '#field-summary, #field-description, #field-keywords' ).each( function( i, el ) {
     94                var $el = $(el);
     95                if ( $el.val() != '' ) {
     96                        check_field_value( $el );
     97                }
     98        } );
    7099
    71100        propertyform.on( 'change', '#security-question input', function() {
Note: See TracChangeset for help on using the changeset viewer.