zaproxy: AJAX Spider - Default Allowed Resources Missing

Is your feature request related to a problem? Please describe.

Hi ZAP. This is a simple html code that invokes the http request when you click a button using $.ajax. But… Spider and Ajax Spider does not seem to detect this.

<html>
  <script src="https://code.jquery.com/jquery-3.6.3.min.js" integrity="sha256-pvPw+upLPUjgMXY0G+8O0xUf+/Im1MZjXxxgOcBQBXU=" crossorigin="anonymous"></script>
  <body>
    <button onclick="btnClick()">Login</button>
    <script>
      function btnClick(){
        $.ajax({
            type: "GET",
            contentType: "application/json",
            url: '/alert.js',
            data: JSON.stringify({"id":"1234"}),
            dataType: 'json'
        })
      }
    </script>
  </body>
</html>

Ajax Spider Spider

I changed the advanced option of Ajax Spider, but the results are the same 😭 I hope it’s detected personally. Is there a good solution?

cc, @pyo-counting

Describe the solution you’d like

Detects $.ajax requests.

Describe alternatives you’ve considered

.

Screenshots

No response

Additional context

No response

Would you like to help fix this issue?

  • Yes

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 19 (14 by maintainers)

Commits related to this issue

Most upvoted comments

@thc202 I just tested it in the latest version of AjaxSpider and it detects alert.js.

And now the default allowed resources also have a values.

It was really nice to learn more about ZAP apart from solving issues! Thank you for always giving me motivation 😄

@nitek29 that is a known restriction, and one we’d like to have implemented. Best to comment on https://github.com/zaproxy/zaproxy/issues/6461 rather than this closed issue.

I see, your case is different, we’ll have to set the defaults to existing homes as well.

I can reproduce this using the latest weekly and a clean config dir:

  1. Start ZAP with a new dir, eg using ./zap.sh -port 9090 -dir ajaxtest
  2. Switch to the AJAX Spider tab
  3. Click on “New Scan”
  4. Specify a starting Point of “https://pocs.hahwul.com/logintest.html
  5. Start the scan
Screenshot 2023-02-04 at 13 04 19

FYI I’m surprised the AJAX Spider can not cope with this. It works by launching browsers and clicking on stuff, and it should click on all buttons. The fact that the button is using a $.ajax request shouldnt matter - the browser should handle that. You can configure it to launch non headless browsers and then you can see what its doing. I’ll try and have a play with this asap…

Hello @thc202 @psiinon

It seems that “allowed resources” parameter isn’t available in the Automation Framework.

- parameters:
    context: "https://myapp.com"
    user: "toto"
    url: "https://myapp.com/"
    maxDuration: 60
    maxCrawlDepth: 10
    numberOfBrowsers: 2
    browserId: "firefox"
    maxCrawlStates: 0
    eventWait: 3000
    reloadWait: 3000
    clickDefaultElems: false
    clickElemsOnce: true
    randomInputs: false
    inScopeOnly: true
    runOnlyIfModern: false
  name: "spiderAjax"
  type: "spiderAjax"
  

Is this issue known ?

PS: I can’t generate automation conf file from a given session with the cmdline : zap.sh -cmd -autogenconf -session /opt/zaproxy/mysession.session

@hahwul the latest version of AJAX Spider add-on should address the case you mentioned.

I’ve just tried this and confirm the AJAX Spider doesnt work with it 😦 Why not? Because for some reason https://code.jquery.com/jquery-3.6.3.min.js is treated as being out of scope 😦 When I add that domain to the scope then the AJAX Spider works. This is a bug - all GET requests for JS files should be treated as being in scope.

Thanks! This is exactly the sort of info we need 😁