users@glassfish.java.net

(no subject)

From: Martin Gainty <mgainty_at_hotmail.com>
Date: Wed, 8 Aug 2012 09:38:49 -0400

http://download.oracle.com/otn-pub/jcp/jacc-1.0-fr-spec-oth-JSpec/jacc-1_0-fr-spec.pdf?AuthParam=1344431271_c27abd82b7b45ea09fbf22ba55ab8381

• If the pattern is a path prefix pattern, it must be qualified by
every path-prefix pattern in the deployment descriptor matched by (the pattern being qualified) *and*
different from the pattern being qualified.
The pattern must also be qualified by every exact pattern appearing in the deployment descriptor that is matched by the pattern being qualified.

• If the pattern is an extension pattern, it must be qualified by
every path-prefix pattern appearing in the deployment descriptor *and*
 every exact pattern in the deployment descriptor that is matched by the pattern being qualified.

• If the pattern is the default pattern, "/", it must be qualified by
every other pattern except the default pattern appearing in the deployment descriptor.

• If the pattern is an exact pattern, its qualified form must not contain any qualifying
patterns.
icantly
it seems the spec lacks specific examples for each pattern use case the statistical probability of mis-interpretation for each pattern and mis-implementation is increased

Martin Gainty
______________________________________________
Verzicht und Vertraulichkeitanmerkung/Note de déni et de confidentialité
 
Diese Nachricht ist vertraulich. Sollten Sie nicht der vorgesehene Empfaenger sein, so bitten wir hoeflich um eine Mitteilung. Jede unbefugte Weiterleitung oder Fertigung einer Kopie ist unzulaessig. Diese Nachricht dient lediglich dem Austausch von Informationen und entfaltet keine rechtliche Bindungswirkung. Aufgrund der leichten Manipulierbarkeit von E-Mails koennen wir keine Haftung fuer den Inhalt uebernehmen.
Ce message est confidentiel et peut être privilégié. Si vous n'êtes pas le destinataire prévu, nous te demandons avec bonté que pour satisfaire informez l'expéditeur. N'importe quelle diffusion non autorisée ou la copie de ceci est interdite. Ce message sert à l'information seulement et n'aura pas n'importe quel effet légalement obligatoire. Étant donné que les email peuvent facilement être sujets à la manipulation, nous ne pouvons accepter aucune responsabilité pour le contenu fourni.


Subject: Re:
From: v.b.kumar.jayanti_at_oracle.com
Date: Wed, 8 Aug 2012 11:49:49 +0530
CC: ron.monzillo_at_oracle.com; jeff.tancill_at_oracle.com; paul.hendley_at_oracle.com
To: users_at_glassfish.java.net


On Aug 8, 2012, at 11:21 AM, KumarJayanti wrote:

On Aug 7, 2012, at 7:41 PM, CASALINO, Matteo Maria wrote:Hello Everyone,

I believe I found a problem in the Glassfish interpretation of some combinations of security constraints in the deployment descriptor of web applications.

In particular, the problem seems to occur whenever one or more security constraints apply to the context root of a web application (/) and other constraints apply instead to every path under the context root (/*). One such example is given by the following configuration:

<!-- Security Constraint SC1 -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name/>
            <url-pattern>/*</url-pattern>
        </web-resource-collection>
    </security-constraint>

<!-- Security Constraint SC2 -->
    <security-constraint>
        <web-resource-collection>
            <web-resource-name/>
            <url-pattern>/</url-pattern>
        </web-resource-collection>
        <auth-constraint/>
    </security-constraint>

According to Servlet spefication [1, 13.8.3] a HTTP request directed to the context root (such as "GET /") shall be denied in this case, since SC2 has the "best matching" URL pattern. In contrast, Glassfish allows any (even unauthenticated) requests to the context root. Notice that Tomcat behaves instead as prescribed by the Servlet specification and denies all the requests directed to the context root.

Does anyone know if there is any explanation to this behaviour?

It seems like an interesting corner case that i never experimented before, but here are some relevant points from the JSR 115 Spec and Servlet Spec.
-------------------------------------------------------Servlet URL-Pattern Matching Rules (JSR 115)-----------------------------------------------
this pattern is the special default pattern,"/",which matches all other patterns.
Qualified URL Pattern Names (JSR 115)------------------------------------If the pattern is the default pattern,"/",it must be qualified by every other pattern except the default pattern appearing in the deployment descriptor.
Any pattern, qualified by a pattern that matches it, is overridden and made irrelevant (in the translation) by the qualifying pattern. Specifically, all extension patterns and the default pattern are made irrelevant by the presence of the path prefix pattern "/*" in a deployment descriptor.
Combining Constraints (servlet spec)----------------------------------The special case of an authorization constraint that names no roles shall combine with any other constraints to override their affects and cause access to be precluded.---------------------------------------------
Please note the statement above about the presence of path prefix pattern "/*" making the default pattern "/" irrelevant. So the granted.policy generated in this case for glassfish is :
grant { permission javax.security.jacc.WebUserDataPermission "/*"; permission javax.security.jacc.WebResourcePermission "/*";};
And it allows access.
 On the other hand in SC1 if you remove the path prefix pattern and change it to something else say "/xyz" then you can see the deny behavior due to SC2 kicking in :
Here is the granted.policy
grant { permission javax.security.jacc.WebUserDataPermission "/xyz"; permission javax.security.jacc.WebResourcePermission "/xyz";};
and exclude.policy generated in this case :
grant { permission javax.security.jacc.WebUserDataPermission "/:/xyz"; permission javax.security.jacc.WebResourcePermission "/:/xyz";};
As you can see the final result is to deny access to /xyz
Correction : i meant deny access to "/" here.
. So i am tending to believe that GlassFish is correct in your case. I am CCing Ron who is the author of these specs for his comments.
regards,kumar



[1] http://jcp.org/aboutJava/communityprocess/final/jsr315/index.html


Matteo Casalino
Research Associate
Security & Trust
SAP Research, SAP Labs France SAS
805, avenue du Dr. Maurice Donat
06254 Mougins Cedex
T +334 92 28 - 63 42
E matteo.maria.casalino_at_sap.com
W http://www.sap.com/research