[jbossseam-issues] [JBoss JIRA] Commented: (JBSEAM-2931) CLONE -Support protection against SQL injection in Query order parameter

Felix Ho?feld (JIRA) jira-events at lists.jboss.org
Mon Apr 28 11:29:08 EDT 2008


    [ http://jira.jboss.com/jira/browse/JBSEAM-2931?page=comments#action_12410934 ] 
            
Felix Ho?feld commented on JBSEAM-2931:
---------------------------------------

Sorry, I could not reopen JBSEAM-2099 so I have cloned it. 

The fix for JBSEAM-2099 does not work as expected because the regular expression is too restrictive.


When I suggested the regex for input filtering I did not think of funtion based order clauses which are quite common in the real world, e.g.



	<framework:entity-query name="qry_allPersons"
		ejbql="SELECT p FROM Person p" entity-manager="#{entityManager}" order="UPPER(p.lastname)">
	</framework:entity-query>

The query will raise an invalid argument exception "invalid order clause" because the order clause does not match the regular expression 
"^[\\w\\.,\\s]*$" defined in ORDER_CLAUSE_PATTERN). (http://fisheye.jboss.com/browse/Seam/trunk/src/main/org/jboss/seam/framework/Query.java?r=7173).

I suggest changing this to 

^(\\w+\\([\\w\\.\\s]+\\)\\s*,\\s*|[\\w\\.]+\\s*,\\s*)*(\\w+\\([\\w\\.\\s]+\\)|[\\w\\.]+)

which will alo match something like:

UPPER(p.lastname), p.age, LOWER(p.country).




> CLONE -Support protection against SQL injection in Query order parameter
> ------------------------------------------------------------------------
>
>                 Key: JBSEAM-2931
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-2931
>             Project: Seam
>          Issue Type: Patch
>          Components: Framework
>    Affects Versions: 2.0.0.CR2
>            Reporter: Felix Ho?feld
>         Assigned To: Norman Richards
>            Priority: Critical
>             Fix For: 2.0.0.CR3
>
>
> From http://www.jboss.com/index.html?module=bb&op=viewtopic&t=119810
> The 'order' parameter gets directly concatenaded to the query.. that would allow anything to get injected in the query, possibly resulting in a security threat. This patch gives the developer extending framework Query the chance to limit the acceptable order properties.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list