<br><font size=2 face="sans-serif">I think&quot; validation patterns&quot;
are a real solution to the problem and minimizing access-priviliges is
not.</font>
<br>
<br><font size=2 face="sans-serif">When filter with URL-substitution is
used without validation patterns, one relies to heavily on the security-system
of postgres. </font>
<br><font size=2 face="sans-serif">This is acceptable in most intranets
but hazardous in the internet.</font>
<br><font size=2 face="sans-serif">Look for example at http://www.postgresql.org/support/security.html
to see, &nbsp;what can be done with even a minimal-postgres-login.</font>
<br>
<br><font size=2 face="sans-serif">But again: Everything's fine with &quot;validation
patterns&quot; &nbsp;...</font>
<br>
<br><font size=2 face="sans-serif">Ciao</font>
<br><font size=2 face="sans-serif">Benedikt</font>
<br>
<br><font size=2 face="sans-serif">Extract of the http://www.postgresql.org/support/security.html</font>
<br><font size=2 face="sans-serif">* </font><font size=3>Three vulnearbilities
in the regular expression handling libraries can be exploited to cause
a backend crash, infinite loops or memory exhaustion. This vulnearbility
can be exploited through frontend applications that allow unfiltered regular
expressions to be passed in queries. </font>
<br><font size=2 face="sans-serif">* </font><font size=3>A bug in the handling
of SET ROLE allows escalation of privileges to any other database user,
including superuser. A valid login is required to exploit this vulnerability
</font>
<br><font size=2 face="sans-serif">* </font><font size=3>Calling COALESCE()
with two NULL parameters would cause the current backend to crash, causing
a denial of service. A valid login is required to exploit this vulnerability.
</font>
<br><font size=2 face="sans-serif">* </font><font size=3>Public EXECUTE
access is given to certain character conversion functions that are not
designed to be safe against malicious arguments. This can cause at least
a denial of service. A valid login is required to exploit this vulnerability
</font>
<br>
<br>
<br><tt><font size=2>&quot;Steve Lime&quot; &lt;Steve.Lime@dnr.state.mn.us&gt;
schrieb am 26.01.2009 21:29:52:<br>
<br>
&gt; In addition, one can and should apply validation patterns to variables<br>
&gt; used in SQL. That way MapServer<br>
&gt; can test the input data before handing off to PostGIS or whatever.<br>
&gt; <br>
&gt; These patterns are set in LAYER metadata. For example:<br>
&gt; <br>
&gt; LAYER<br>
&gt; &nbsp; ...<br>
&gt; &nbsp; DATA&quot;'the_geom FROM (SELECT the_geom FROM my_table WHERE
ID = '%id%')<br>
&gt; as foo USING UNIQUE OID&quot; &nbsp;<br>
&gt; &nbsp; METADATA<br>
&gt; &nbsp; &nbsp; id_validation_pattern '^[0-9]{3}$'<br>
&gt; &nbsp; END<br>
&gt; END<br>
&gt; <br>
&gt; This tells the CGI to test the request parameter against the regex<br>
&gt; '^[1-9]{3}$'. The regex says that the value<br>
&gt; of the id variable must be an number exactly 3 digits long with no<br>
&gt; zeros. Any attempt to send a value other<br>
&gt; than that will generate an error message. The CGI code does not force<br>
&gt; the use of validation.<br>
&gt; <br>
&gt; Validation like this will be further expanded in 5.4 with the addition<br>
&gt; of a new validation object. So you'd see <br>
&gt; something like:<br>
&gt; <br>
&gt; LAYER<br>
&gt; &nbsp; ...<br>
&gt; &nbsp; VALIDATION<br>
&gt; &nbsp; &nbsp; 'id' &nbsp;'^[0-9]{3}$<br>
&gt; &nbsp; END<br>
&gt; END<br>
&gt; <br>
&gt; Steve<br>
&gt; <br>
&gt; &gt;&gt;&gt; On 1/26/2009 at 8:47 AM, in message<br>
&gt; &lt;6246727221874A4FB8D3F9BBC37D9BD5056DA174@s-sp22.pca.state.mn.us&gt;,<br>
&gt; &quot;Fawcett,<br>
&gt; David&quot; &lt;David.Fawcett@state.mn.us&gt; wrote:<br>
&gt; &gt; Of course, part of security is also having your application hit
your<br>
&gt; database <br>
&gt; &gt; as a user that only has the rights that it needs. &nbsp;If your
user only<br>
&gt; has <br>
&gt; &gt; select rights on only the data that you want to expose, that
should<br>
&gt; help <br>
&gt; &gt; limit some of these issues.<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp;-----Original Message-----<br>
&gt; &gt; &nbsp; &nbsp;From: mapserver-users-bounces@lists.osgeo.org <br>
&gt; &gt; [mailto:mapserver-users-bounces@lists.osgeo.org] On Behalf Of
<br>
&gt; &gt; umn-ms@hydrotec.de <br>
&gt; &gt; &nbsp; &nbsp;Sent: Monday, January 26, 2009 4:43 AM<br>
&gt; &gt; &nbsp; &nbsp;To: MapServer<br>
&gt; &gt; &nbsp; &nbsp;Subject: Re: [mapserver-users] Dynamin SQL with
mapserver CGI?<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; Not any great hazard, I believe, ... <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;Mmh. I'd be cautious. <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;Example: <br>
&gt; &gt; &nbsp; &nbsp;* Mapfile: <br>
&gt; &gt; &nbsp; &nbsp; &nbsp; DATA &quot;the_geom from buildings&quot;<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;* Set Filter via URL to this: <br>
&gt; &gt; &nbsp; &nbsp; &nbsp;1=1);DELETE FROM OTHERTABLE; DECLARE X BINARY
CURSOR FOR<br>
&gt; SELECT * from <br>
&gt; &gt; buildings WHERE (1=1 <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;I think Mapserver will create the following statements:
(I've<br>
&gt; added <br>
&gt; &gt; newlines) <br>
&gt; &gt; &nbsp; &nbsp;DECLARE mycursor BINARY CURSOR FOR SELECT the_geom
from<br>
&gt; buildings WHERE <br>
&gt; &gt; (1=1); <br>
&gt; &gt; &nbsp; &nbsp;DELETE FROM OTHERTABLE; <br>
&gt; &gt; &nbsp; &nbsp;DECLARE X BINARY CURSOR FOR SELECT * from buildings
WHERE (1=1)<br>
&gt; and (%s &amp;&amp; <br>
&gt; &gt; setSRID( ...) ) <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;Mapserver calls PQExec with these statements. PQExec
will<br>
&gt; execute every <br>
&gt; &gt; statement and will return <br>
&gt; &gt; &nbsp; &nbsp;the results of the last one. <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;Bye <br>
&gt; &gt; &nbsp; &nbsp;Benedikt Rothe <br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;&quot;Rahkonen Jukka&quot; &lt;Jukka.Rahkonen@mmmtike.fi&gt;
schrieb am<br>
&gt; 26.01.2009 09:34:31:<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;&gt; Hi, <br>
&gt; &gt; &nbsp; &nbsp;&gt; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp;&gt; Not any great hazard, I believe, if it means
that user can<br>
&gt; normally <br>
&gt; &gt; &nbsp; &nbsp;&gt; get all the features, but only a subset when
filter is set. <br>
&gt; It is <br>
&gt; &gt; &nbsp; &nbsp;&gt; different case if DATA clause is manipulated,
and therefore<br>
&gt; that <br>
&gt; &gt; &nbsp; &nbsp;&gt; must be connected to DATAPATTERN. <br>
&gt; &gt; &nbsp; &nbsp;&gt; &nbsp; <br>
&gt; &gt; &nbsp; &nbsp;&gt; -Jukka Rahkonen- <br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; Lähettäjä: mapserver-users-bounces@lists.osgeo.org
[mailto:<br>
&gt; &gt; &nbsp; &nbsp;&gt; mapserver-users-bounces@lists.osgeo.org] Puolesta<br>
&gt; umn-ms@hydrotec.de <br>
&gt; &gt; &nbsp; &nbsp;&gt; Lähetetty: 26. tammikuuta 2009 10:03<br>
&gt; &gt; &nbsp; &nbsp;&gt; Vastaanottaja: MapServer<br>
&gt; &gt; &nbsp; &nbsp;&gt; Aihe: Re: [mapserver-users] Dynamin SQL with
mapserver CGI?<br>
&gt; &gt; &nbsp; &nbsp;<br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; Hi <br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; You can use a replaceable parameter in
the FILTER clause if<br>
&gt; all you ... <br>
&gt; &gt; &nbsp; &nbsp;&gt; This introduces the hazard of SQL-Injection,
doesn't it? <br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; Bye <br>
&gt; &gt; &nbsp; &nbsp;&gt; Benedikt Rothe <br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; mapserver-users-bounces@lists.osgeo.org schrieb
am 24.01.2009<br>
&gt; 14:04:42:<br>
&gt; &gt; &nbsp; &nbsp;&gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; On Sat, Jan 24, 2009 at 3:18 AM, Saka
Royban<br>
&gt; &lt;srph124@yahoo.com&gt; wrote:<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &gt; Hi all<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &gt; I'm looking for a way to change SQL
dynamically via URL<br>
&gt; parameters. it<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &gt; sounds from doc that changing DATA
element in map file is<br>
&gt; impossible. Is<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &gt; there any other way?<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; You can use a replaceable parameter in
the FILTER clause if<br>
&gt; all you<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; want to do is alter the WHERE clause.
So for example:<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &nbsp; &nbsp;FILTER &quot;%criteria%&quot;<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; and<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; &nbsp; criteria=id='value'<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; would work with a database like Postgres.<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; When working with a database you put the
whole SQL WHERE<br>
&gt; clause in the<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; FILTER, whereas with shapefiles or ORG
data sources you use<br>
&gt; the<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; FILTERITEM and FILTER.<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; -- <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; Richard Greenwood<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; richard.greenwood@gmail.com <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; www.greenwoodmap.com <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; _______________________________________________<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; mapserver-users mailing list<br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; mapserver-users@lists.osgeo.org <br>
&gt; &gt; &nbsp; &nbsp;&gt; &gt; http://lists.osgeo.org/mailman/listinfo/mapserver-users<br>
</font></tt>