Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 372615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:13:41+00:00 2026-05-12T14:13:41+00:00

In my web.xml I’ve defined a user-data-constraint for some resources: <security-constraint> <web-resource-collection> <web-resource-name>Personal Area</web-resource-name>

  • 0

In my web.xml I’ve defined a user-data-constraint for some resources:

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Personal Area</web-resource-name>
        <url-pattern>/personal/*</url-pattern>
    </web-resource-collection>
    <web-resource-collection>
        <web-resource-name>User Area</web-resource-name>
        <url-pattern>/user/*</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>
  1. When I load the page with http I’ve got my JSESSIONID ID1 in my cookie.
  2. When I change to context/user/sample.faces then Tomcat makes a 302 redirect to HTTPS. But my JSESSIONID is still ID1.

I think this is a vulnerability? Or is it my configuration mistake?

The problem I see is the following: While browsing over HTTP with cookie ID1 there is an attacker who is listening to my network traffic. He “steals” my cookie ID1. Now I switch to HTTPS and my cookie is still ID1. I login. The attacker is then able to taker over my session because he knows my cookie…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:13:41+00:00Added an answer on May 12, 2026 at 2:13 pm

    If it’s a recent version of Tomcat, you may not have a problem. However, this depends on your checking the SSL ID associated with the session. This is available using code such as

    String sslId = (String) req.getAttribute("javax.servlet.request.ssl_session");
    

    (Note that the attribute key may change in the future to javax.servlet.request.ssl_session_id – as part of the Servlet 3.0 spec).

    I set up a servlet with the following doGet method:

    protected void doGet(HttpServletRequest request, HttpServletResponse response)
                        throws ServletException, IOException {
        HttpSession session = request.getSession(true);
        String sid = session.getId();
        String sslId = (String) request.getAttribute(
                    "javax.servlet.request.ssl_session");
        String uri = request.getRequestURI();
        OutputStream out = response.getOutputStream();
        PrintWriter pw = new PrintWriter(out);
        HashMap<String, Object> secrets;
        Object secret = null;
        Object notSecret;
        Date d = new Date();
    
        notSecret = session.getAttribute("unprotected");
        if (notSecret == null) {
            notSecret = "unprotected: " + d.getTime();
            session.setAttribute("unprotected", notSecret);
        }
        secrets = (HashMap<String, Object>) session.getAttribute("protected");
        if (secrets == null) {
            secrets = new HashMap<String, Object>();
            session.setAttribute("protected", secrets);
        }
        if (sslId != null) {
            if (secrets.containsKey(sslId))
                secret = secrets.get(sslId);
            else {
                secret = "protected: " + d.getTime();
                secrets.put(sslId, secret);
            }
        }
        response.setContentType("text/plain");
        pw.println(MessageFormat.format("URI: {0}", new Object[] { uri }));
        pw.println(MessageFormat.format("SID: {0}", new Object[] { sid }));
        pw.println(MessageFormat.format("SSLID: {0}", new Object[] { sslId }));
        pw.println(MessageFormat.format("Info: {0}", new Object[] { notSecret }));
        pw.println(MessageFormat.format("Secret: {0}", new Object[] { secret }));
        pw.println(MessageFormat.format("Date: {0}", new Object[] { d }));
        pw.close();
    }
    

    I then invoked a suitable unprotected URL using Firefox and the Live HTTP Headers extension, to get the session cookie. This was the response sent when I navigated to

    http://localhost:8080/EchoWeb/unprotected
    

    (my web.xml, like yours, only protects /user/* and /personal/*):

    URI: /EchoWeb/unprotected
    SID: 9ACCD06B69CA365EFD8C10816ADD8D71
    SSLID: null
    Info: unprotected: 1254034761932
    Secret: null
    Date: 27/09/09 07:59
    

    Next, I tried to access a protected URL

    http://localhost:8080/EchoWeb/personal/protected
    

    and, as expected, I got redirected to

    https://localhost:8443/EchoWeb/personal/protected
    

    and the response was

    URI: /EchoWeb/personal/protected
    SID: 9ACCD06B69CA365EFD8C10816ADD8D71
    SSLID: 4abf0d67549489648e7a3cd9292b671ddb9dd844b9dba682ab3f381b462d1ad1
    Info: unprotected: 1254034761932
    Secret: protected: 1254034791333
    Date: 27/09/09 07:59
    

    Notice that the cookie/session ID is the same, but we now have a new SSLID. Now, let’s try to spoof the server using the session cookie.

    I set up a Python script, spoof.py:

    import urllib2
    
    url = "https://localhost:8443/EchoWeb/personal/protected"
    headers = {
        'Host': 'localhost:8080',
        'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.1.3) Gecko/20090824 Firefox/3.5.3',
        'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
        'Accept-Language': 'en-gb,en;q=0.5',
        'Accept-Charset': 'ISO-8859-1,utf-8;q=0.7,*;q=0.7',
        'Cookie' : 'JSESSIONID=9ACCD06B69CA365EFD8C10816ADD8D71'
    }
    req = urllib2.Request(url, None, headers)
    response = urllib2.urlopen(req)
    print response.read()
    

    Now, you don’t need to know Python, particularly – I’m just trying to send an HTTP request to a (different) protected resource with the same session ID in the Cookie. Here’s the response when I ran my spoof script twice:

    C:\temp>spoof
    URI: /EchoWeb/personal/protected
    SID: 9ACCD06B69CA365EFD8C10816ADD8D71
    SSLID: 4abf0eafb4ffa30b6579cf189c402a8411294201e2df94b33a48ae7484f22854
    Info: unprotected: 1254034761932
    Secret: protected: 1254035119303
    Date: 27/09/09 08:05
    
    
    C:\temp>spoof
    URI: /EchoWeb/personal/protected
    SID: 9ACCD06B69CA365EFD8C10816ADD8D71
    SSLID: 4abf0eb184cb380ce69cce28beb01665724c016903650539d095c671d98f1de3
    Info: unprotected: 1254034761932
    Secret: protected: 1254035122004
    Date: 27/09/09 08:05
    

    Notice in the above responses that the session data (a value with a timestamp of 1254034761932) which was set in the first, unprotected request, has been sent throughout, because Tomcat is using the same session because the session ID is the same. This is of course not secure. However, note that the SSL IDs were different each time and if you use those to key into your session data (e.g. as shown), you should be safe. If I refresh my Firefox tab, here’s the response:

    URI: /EchoWeb/personal/protected
    SID: 9ACCD06B69CA365EFD8C10816ADD8D71
    SSLID: 4abf0d67549489648e7a3cd9292b671ddb9dd844b9dba682ab3f381b462d1ad1
    Info: unprotected: 1254034761932
    Secret: protected: 1254034791333
    Date: 27/09/09 08:05
    

    Notice that the SSLID is the same as for the earlier Firefox request. So, the server can tell the sessions apart using the SSL ID value. Notice particularly that the “protected data” is the same for each request made from the Firefox session, but different for each of the spoofed sessions and also different from the Firefox session.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 339k
  • Answers 339k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer In our case we succeded using curl inside our controller,… May 14, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer The problem is that the key into the Attributes[] indexer… May 14, 2026 at 4:29 am
  • Editorial Team
    Editorial Team added an answer In WordPress you may create your own page templates, where… May 14, 2026 at 4:29 am

Related Questions

In my web.xml I've defined a user-data-constraint for some resources: <security-constraint> <web-resource-collection> <web-resource-name>Personal Area</web-resource-name>
In my Tomcat logs (catalina) I am getting the following error preventing my application
I am working with javascript and here is what I am trying to do:
If I do not specify the following in my web.xml file: <session-config> <session-timeout>10</session-timeout> </session-config>
In web.xml I have the following: <servlet> <description>JAX-WS endpoint - EARM</description> <display-name>jaxws-servlet</display-name> <servlet-name>jaxws-servlet</servlet-name> <servlet-class>com.sun.xml.ws.transport.http.servlet.WSSpringServlet</servlet-class>

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.