Fix security bug with whitelist
Username wasn't sanitized before being used in the regex to check the whitelist with, so a user named ... (literally three periods) would be allowed to use the script as long as any user on the list had a name three characters long. Thanks to MusikAnimal for pointing this out.
This commit is contained in:
parent
b9f3b76eee
commit
33d2176754
@ -101,8 +101,14 @@
|
||||
var user = AFCH.consts.user,
|
||||
whitelist = new AFCH.Page( AFCH.consts.whitelistTitle );
|
||||
whitelist.getText().done( function ( text ) {
|
||||
|
||||
// sanitizedUser is user, but escaped for use in the regex.
|
||||
// Otherwise a user named ... would always be able to use
|
||||
// the script, so long as there was a user whose name was
|
||||
// three characters long on the list!
|
||||
var $howToDisable,
|
||||
userAllowed = ( new RegExp( '\\|\\s*' + user + '\\s*}' ) ).test( text );
|
||||
sanitizedUser = user.replace( /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&' ),
|
||||
userAllowed = ( new RegExp( '\\|\\s*' + sanitizedUser + '\\s*}' ) ).test( text );
|
||||
|
||||
if ( !userAllowed ) {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user