Encrypting Web Page Data

We are trying to implement a secure application to allow our students to view their grades online. They would authenticate via a university-maintained authentication mechanism and then pass and maintain that ID securely between the student's web browser and an application server. Initially, through a java API, I was going to include code to see whether the user was authenticated, and if not, invoke the authentication mechanism, which would return a cookie containing an encryted ID. I was going to include this code in all servlets, so that the ID would never have to be passed back and forth between client browser and app server. This would prevent the direct manipulation of the ID and prevent the client from passing another student's ID to the server. I didn't ever want to pass an ID as part of a post or get.

This worked well, with a servlet able to obtain the ID solely by invoking the University's Authentication API and obtaining the ID that way. Unfortunately, a requirement was added to protect the app server behind a firewall, and only allow communication to it via a reverse proxy. The university's authentication mechanism, unfortunately, will not work with a reverse proxy in the middle, so I have to separate the code into a java servlet that will invoke the API on the reverse proxy server, and then pass that ID to my servlet via a post, or get.

I want to make sure the user can't modify this ID, and possibly other sensitive information that will need to be passed back and forth between the servlets. I am being encouraged to use PKI to do this. Is this valid? And are there any examples of this being done?

Thanks in advance.

[1683 byte] By [plsqlrocksa] at [2007-11-26 15:23:52]
# 1

I implemented a similar system to this for a large credit card system. I don't know about PKI, I would use AES. There are some things you might want to consider with your current system.

1) Include a timestamp in the Cookie so that the server can reject it if it is too old (10 minutes seems to be a reasonable value). The timestamp must be encrypted with the Cookie payload. The timestamp must be updated with every response.

2) Use something like CBC so that hackers/users cannot generate a new Cookie by splicing two Cookies. Use a different random IV with every response.

3) Include a hash (MD5 or SHA1 is normally good enough) of the content of the Cookie at the end of the Cookie so that Cookie fraud will be almost impossible. The hash must be encrypted with the Cookie payload. Within your servlet you must make sure the hash is valid.

4) Change the key every time the server is re-started - this normally means generating a new random key.

sabre150a at 2007-7-8 21:39:13 > top of Java-index,Security,Cryptography...