Hi,
Thank you for asking, this is exactly the topic I was looking for !
I might have some answers:
Watch these two videos about authentication
in ZAP and about the AJAX
Spider, it helped me.
But I had to improvise a little because I didn't manage to make the Forced User
mode to work (is it specific to WebGoat... ?)
1) First of all, I added a regexp pattern for logged IN user, which is simply
the "logout" button. To do this, manually login as guest and search
for the html snippet <li><a ...
href="j_spring_security_logout">Logout</a></li>
in the response of the login request GET:start.mvc node.
2) Create a user from the left tabs in the same dialog:
"tester_guest" as User Name, "guest" as username and
"guest" as password. Hit OK.
3) I also set the regexp pattern for logged OUT
state after manually logging out, as you did (I set as the pattern "You
have logged out successfully").
4) Since I want to crawl all the website with the AJAX Spider, I have to
exclude at least a link from the spider's seeds: GET:j_spring_security_logout
(right-click > Exclude from... > Spider). Otherwise, ZAP will follow that
link and log out from the app (Forced User mode didn't work for me, I still
don't know why...).
5) From the HHTP Sessions tab, I set as active the session where the Token
Value matches the session cookie value from WebGoat. You can find that value in
the "Cookie/Parameters" table on every screen in WebGoat.
6) From the AJAX Spider tab, hit New Scan
Starting point (adapt if your app runs not locally on port 8081): http://localhost:8081/WebGoat/attack. I added “attack” because in the Alerts tab, vulnerabilities were found passively in similar URLs.
Context: WebGoat
User (the one created above): tester_guest
Show advanced options > Options tab > Maximum crawl depth & states : 0
Instead of a context, you can try Just in scope option, because they’re mutually exclusive.
7) Now you can launch an active scan
It doesn’t feel like all the lessons in WebGoat were crawled by the AJAX Spider... Rather, it seems to me that the tool simply opens the tabs. Although it happened once, but I can’t recall under which settings.
The scans I ran seem to have found some vulnerabilities in the lessons (which is what we want).
I am also new to this software, so I may have missed several crucial points...
Let me know if you get something relevant