Hello, I'm new to Perl....& this web application built on perl-cgi(~10 yrs old app) Recently the Rational webAppscan that scanned the URL ,reported several(20) cgi modules for Cross-Site Request Forgery (CSRF). I didnt see anything obvious...I was hoping someone could point out the code that is causing the vulnerability Below is the code (both cgi & the template)of one of the module *****************************sched_history.tmpl************************************************************************
<TMPL_INCLUDE NAME="./icon_top.tmpl"> <!--webbot bot="Include" endspan i-checksum="28680" --> <p class="page-header">Distribution Schedule Audit Log</p> <hr class="header-line"> <br> <form name=schedhistform method=POST action="/gdr/cgi-bin/user_detail. +cgi"> <input type=hidden name=user_id value="<tmpl_var name=user_id>"> <input type=hidden name=sched_effective_dt> <table class="data-table"> <caption class="info-table-caption">Distribution ID: <TMPL_VAR NAME=US +ER_ID></caption> <tr class="info-table-header"> <td>Effective Date</td> <td>Status</td> <td>Updated By</td> <td>Description</td> </tr> <TMPL_LOOP NAME=sched_history_list> <tr class="<tmpl_if name=__ODD__>shaded<tmpl_else>unshaded</tmpl_if>" +> <td><TMPL_VAR NAME=SCHED_EFFECTIVE_DT></td> <td><TMPL_VAR NAME=STATUS_CD></td> <td><TMPL_VAR NAME=SCHED_UPD_USER_ID></td> <td><TMPL_VAR NAME=DESC></td> </tr> </TMPL_LOOP> </table> </form> <TMPL_INCLUDE NAME="./icon_bottom.tmpl">
*********************************sched_history.cgi********************************************************************
use HTML::Template; use Provider::CGI; use strict; use Apache::DBI; use DBI; use coplib; use Provider::LogAgent; use Provider::Constants; my $cgi = Provider::CGI->new(); # Store the user information in the session object my %session; getSession( \%session ); print $cgi->header( -charset => q{utf-8} ); my $user_id=$cgi->param( "user_id" ); ## Common Log my $logger = new Provider::LogAgent(\%session); my $event = $Provider::Constants::ADMIN_INFO; my $entity = "$user_id"; my $entityType = "distribution_id"; my $additional = {"action"=>$Provider::Constants::COMMON_LOG_ACCESS}; $logger->store_message($event, $entity, $entityType, %$additional); $user_id =~ s/^\s+//; $user_id =~ s/\s+$//; $user_id = uc($user_id); my $dbh = cpDBConnect( \%session ); my $row_data; my $sql_stmt; my $template = new_template( "sched_history.tmpl", "Distribution Sched +ule History", \%session); $sql_stmt = "SELECT to_char( DSD.EFF_DT, 'DD-MON-YYYY HH24:MI:SS') AS +SCHED_EFFECTIVE_DT, " . "DSD.LAST_UPD_USER_ID AS SCHED_UPD_USER_ID, " . "DSD.STAT_CD AS STATUS_CD, " . "DSD.DESC_TXT AS DESC_TXT " . "FROM DIST_SCHED_DETAIL DSD , DIST_SCHED DS " . "WHERE DSD.USER_ID=? AND DS.USER_ID = DSD.USER_ID "; my $sth = $dbh->prepare($sql_stmt); $sth->execute( $user_id ); my @loop_data; while ( $row_data = $sth->fetchrow_hashref ) { push(@loop_data, $row_data); } $sth->finish; $template->param( sched_history_list => \@loop_data); $template->param( USER_ID => $user_id ); #$dbh->disconnect; print $template->output; END { untie %session; undef %session; }

In reply to Need help figure out CSRF vulnerability on this cgi code by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.