Response mixed between users with mod_jk-1.2.40

2014-09-07 Thread Philippe Mouawad
Hello,

I am working currently on an issue where an application is facing either
Response mix or Session mix.
For example:
1/ a user A gets the basket of customer B when going on basket detail
(response mix)
2/ Cookies also get mixed up, more of session mix in this case

The versions of components are the following:

   - Load Balancer = modjk_1.2.40 = Tomcat 5.5.23 (Yes very old)


I have made some searches on bug database and found this issue which seems
similar:

   - https://issues.apache.org/bugzilla/show_bug.cgi?id=47714

But the issue is in state WORKSFORME so it is not a bug AFAIU.

Also issue seems to be related to a bug fix that occured in mod_jk 1.2.27 :
AJP13: [CVE-2008-5519] Always send initial POST packet even if the client
disconnected after sending request but before providing POST data. In that
case or in case the client broke the connection in a middle of read send an
zero size packet informing container about broken client connection.
(mturk) 

What makes me say this is that there is a JBoss solution document that says
this:
https://access.redhat.com/solutions/19239

There is a known bug in mod_jk versions 1.2.26 and below that can cause
session crosstalk

AJP13: [CVE-2008-5519] Always send initial POST packet even if the client
disconnected after sending request but before providing POST data. In that
case or in case the client broke the connection in a middle of read send an
zero size packet informing container about broken client connection.
(mturk) 

So with version 1.2.40 no issue should remain Afaik.

So I have 3 questions:

1) Does the fix in mod_jk require an upgrade to a particular tomcat version
?

2) The issue was related to a security problem, but how response mix did
occur ?

3) The Bug 47714 close as Worksforme is not clear for me. Is it possible
that non optimal config can lead to this issue, for example:

- Not setting recovery_options ? what would be the technical explanation ?

Request would be retried but how mix would occur ?
I am besides this investigating load balancer and application issues.

Thanks for help
Regards
Philippe M.


-- 
Cordialement.
Philippe Mouawad.


RE: web.xml authentication and Tomcat Realm

2014-09-07 Thread Dalecki, Janusz


-Original Message-
From: Neven Cvetkovic [mailto:neven.cvetko...@gmail.com]
Sent: Friday, 5 September 2014 11:40 PM
To: Tomcat Users List
Subject: Re: web.xml authentication and Tomcat Realm

Hey Janusz,

On Thu, Sep 4, 2014 at 8:02 PM, Dalecki, Janusz jdale...@tycoint.com
wrote:

Follow the link Chris provided. It will give you some ideas about how Realms 
work.

(Note that using JDBCRealm will give you terrible performance: use a
 DataSourceRealm instead with a JNDI DataSource.)

 You really need to read this:
 http://tomcat.apache.org/tomcat-7.0-doc/realm-howto.html

 - -chris


 Hi,

 Sorry I need to explain my problem more clearly.
 I have put JDBCRealm configuration with all details in the META-INF
 folder:

Realm className=org.apache.catalina.realm.JDBCRealm
 driverName=org.postgresql.Driver
 connectionURL=jdbc:postgresql://localhost:5432/df_Scheduler?user=postgresamp;password=admin
 userTable=users userNameCol=userName userCredCol=password
 userRoleTable=user_roles roleNameCol=roleName/


Where specifically did you put in this Realm information? Is it 
YourApp.war/META-INF/context.xml file?
What this configuration means is that your users/passwords for authentication 
and users/roles for authorization are going to be stored in the JDBCRealm, i.e. 
in your Postgres database called df_Scheduler, more specifically in your 
users table and in your user_roles table.

You can connect to your database and see specifically what users and roles are 
defined in these tables, e.g.

psql -U postgres -W -h localhost df_Scheduler (prompted for password)

SELECT userName,password FROM users;

Should give you all the users and their passwords, e.g.
janusz / mypassword1
john / mypassword2
...


SELECT * FROM user_roles;

Should give you all users and their respective roles, one combo per row/record, 
e.g.

janusz TPA_USER
janusz TPA_ADMIN
janusz SYSADMIN
john TPA_USER
...

You need to inspect and see that the actual username/password combinations 
actually exist in the database.


In my web.xml I have login-config element and security constraint as
 follows:
 security-constraint
 web-resource-collection
 web-resource-nameAdmin/web-resource-name
 url-pattern/auth/*/url-pattern
 /web-resource-collection
 auth-constraint
 role-nameSYSADMIN/role-name
 /auth-constraint
 /security-constraint

 security-role
 role-nameSYSADMIN/role-name
 /security-role
 login-config
 auth-methodBASIC/auth-method
 !--realm-nameAdmin/realm-name--
 /login-config


What this configuration in YourApp.war/WEB-INF/web.xml file does, is that it 
configures that all requests made to /auth/*, e.g.
http://blahblah/YourApp/auth/

So, all these requests will need to know who makes the call (Authorization) and 
once you login, logged user needs to have SYSADMIN role defined in the Realm.

Also, the login-config mandates BASIC login mechanism, i.e. window popup with 
username/password.

So, once you make the first request, your browser will popup authentication 
window asking you for username and password, it would have said Admin but you 
commented out the realm-nameAdmin/realm-name in the login-config 
configuration.

Once you submit username/password it will try to authenticate against whatever 
Realm was setup (I will get to this point later). If the username/password 
combination does not match, it asks again, and again, and again, until you 
press ESC, which you will get redirected to 401 (Not
Authenticated) page.

Next, if the username/password combination was successful, the user is 
Authenticated, next - it needs to be Authorized, i.e. it needs to be associated 
with the Role defined in the auth-constraint, e.g. SYSADMIN. So, whoever logged 
in - they need to have SYSADMIN role in order to get to the resources 
(/auth/* pages). If they don't have required role - the server would return 
403 (Forbidden) page. If they do have the required role - the server would 
proceed with the request (i.e. happy path).



 I have defined users and passwords as explained in the TOMCAT Realm
 Configuration – HOW TO.
 When I ask for a page */auth/* the user/password dialog box pops up
 and no matter what I type in in user name field and password field and
 pops up again for ever.
 What am I doing wrong?


Now, there are two things that could be the reason of the behaviour you
described:

(1) The realm defined for this application is ignored or not setup properly.

The easiest test would be to change the password, and try restarting the server 
and try logging in again. See if the console/logfile shows any errors. If it 
does, you will know your Realm configuration is being read.
(That's a good thing, you know your configuration is being read!) If you don't 
observe any errors, and you get the same type of behaviour, that means your