User:CSteipp (WMF)/Training/VulnTagging easy

WARNING: This is a vulnerable script for demonstration. Don't use it!

This parser function is vulnerable to a few common attacks from Security_for_developers. Answers are on the Discussion page.

setHook( 'vtag', 'wfAddTags' ); return true; }

function wfAddTags( $input, $argv, $parser ) { $articleId = $parser->getTitle->getArticleID;

if ( isset( $argv['articleid'] ) ) { $articleId = $argv['articleid']; }

$dbr = wfGetDB( DB_SLAVE );

$res = $dbr->select(		'vulntags',		array( 'vt_tid', 'vt_tag_text' ),		array( "vt_article_id = $articleId" ),		__METHOD__	);

$tags = array;

foreach ( $res as $tag ) { $tags[] = "vt_tid."'>".$tag->vt_tag_text.""; }

return "". implode( "\n", $tags ). ""; }