wtorek, 28 marca 2017

How to find username (principal) in Heap Dump of Spring Application deployed on Tomcat

1. Load Heap Dump with MAT (Eclipse Memory Analyzer)
2. Find suspicious org.apache.tomcat.util.threads.TaskThread instance
3. Open outgoing references for it
4. Order by class name descending to easier find spring classes
5. Look for class   org.springframework.security.web.servletapi.HttpServlet3RequestFactory$Servlet3SecurityContextHolderAwareRequestWrapper

6. Look for response
7. Look for authBeforeExecution and select it
8. In Inspector window on the left you have Attributes and principal is the username of suspicious request



czwartek, 9 marca 2017

How to take heap dump of a Tomcat installed as a Windows Service


  1. You need to download PsExec tool from Microsoft. This is because Tomcat service usually run with Local System account.
  2. You need a Tomcat service PID. Get it with the task manager.
  3. PsExec tool don't need to be installed. Just go to where PsExec.exe or PsExec64.exe file is located and run:
  4. >psexec64 -s "C:\Program Files\Java\jdk1.8.0_121\bin\jmap" -dump:file=c:\dump\heapdump170309.data 19304

    The last argument is the PID. You'll also need to locate the jmap tool which is usually installed with your Java JDK.

wtorek, 7 marca 2017