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;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.