mapserver cgi-bin security

Sebastiano Laini <[email protected]> Mon, 25 Nov 2019 10:19:02 +0000
Newsgroups gmane.comp.gis.mapserver.user
Message-ID <487fc53f105145b890c5dfbf0a0ddeef@BCExchange.BuchananComputing.co.uk>
--===============7501778475778153463==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_487fc53f105145b890c5dfbf0a0ddeefBCExchangeBuchananCompu_"

--_000_487fc53f105145b890c5dfbf0a0ddeefBCExchangeBuchananCompu_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

Hi All,

We submitted our new system to a pen-test and apparently is pretty easy to =
be infected by SQL-injection, anyone came across this before?

We run the feature layer through a cgi-bin request, see the script below

#! /bin/sh
MAPSERV=3D"/var/.../cgi-bin/mapserv"
MAPFILE=3D"/var/.../twfeat.map"
if [ "${REQUEST_METHOD}" =3D "GET" ]; then
   if [ -z "${QUERY_STRING}" ]; then
      QUERY_STRING=3D"map=3D${MAPFILE}"
   else
      QUERY_STRING=3D"map=3D${MAPFILE}&${QUERY_STRING}"
   fi
   exec ${MAPSERV}
else
   echo "Sorry, I only understand GET requests."
fi
exit 1

how can you sanitize or implement security layers?

Kind Regards,

Sebastiano Laini
Web Developer
Buchanan Computing

--_000_487fc53f105145b890c5dfbf0a0ddeefBCExchangeBuchananCompu_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	font-size:11.0pt;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
	{mso-style-priority:99;
	color:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-family:"Calibri",sans-serif;
	mso-fareast-language:EN-US;}
@page WordSection1
	{size:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-GB" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Hi All,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We submitted our new system to a pen-test and appare=
ntly is pretty easy to be infected by SQL-injection, anyone came across thi=
s before?<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">We run the feature layer through a cgi-bin request, =
see the script below<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">#! /bin/sh<o:p></o:p></p>
<p class=3D"MsoNormal">MAPSERV=3D&quot;/var/&#8230;/cgi-bin/mapserv&quot;<o=
:p></o:p></p>
<p class=3D"MsoNormal">MAPFILE=3D&quot;/var/&#8230;/twfeat.map&quot;<o:p></=
o:p></p>
<p class=3D"MsoNormal">if [ &quot;${REQUEST_METHOD}&quot; =3D &quot;GET&quo=
t; ]; then<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp; if [ -z &quot;${QUERY_STRING}&quot; ]; =
then<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QUERY_STRING=3D&quot;=
map=3D${MAPFILE}&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp; else<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; QUERY_STRING=3D&quot;=
map=3D${MAPFILE}&amp;${QUERY_STRING}&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp; fi<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp; exec ${MAPSERV}<o:p></o:p></p>
<p class=3D"MsoNormal">else<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp; echo &quot;Sorry, I only understand GET=
 requests.&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">fi<o:p></o:p></p>
<p class=3D"MsoNormal">exit 1<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">how can you sanitize or implement security layers?<o=
:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Kind Regards,<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:EN=
-GB">Sebastiano Laini<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:EN=
-GB">Web Developer<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:EN=
-GB">Buchanan Computing<o:p></o:p></span></p>
</div>
</body>
</html>

--_000_487fc53f105145b890c5dfbf0a0ddeefBCExchangeBuchananCompu_--

--===============7501778475778153463==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KbWFwc2VydmVy
LXVzZXJzIG1haWxpbmcgbGlzdAptYXBzZXJ2ZXItdXNlcnNAbGlzdHMub3NnZW8ub3JnCmh0dHBz
Oi8vbGlzdHMub3NnZW8ub3JnL21haWxtYW4vbGlzdGluZm8vbWFwc2VydmVyLXVzZXJz

--===============7501778475778153463==--