Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message tags might not always be reflected in the History tab #8399

Open
1 task
roisec opened this issue Mar 13, 2024 · 28 comments
Open
1 task

Message tags might not always be reflected in the History tab #8399

roisec opened this issue Mar 13, 2024 · 28 comments

Comments

@roisec
Copy link

roisec commented Mar 13, 2024

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

Hi
I encourage some use cases that http request contains json requests, and there is no tag on the relevant message.
I think there are missing scenarios that I send content-type: application/json and there is no JSON tag on the message

Describe the solution you'd like

Cover all the http requests with json

Describe alternatives you've considered

Filter out by myself .

Screenshots

No response

Additional context

No response

Would you like to help fix this issue?

  • Yes
@thc202
Copy link
Member

thc202 commented Mar 13, 2024

The tagging mechanism works on requests and responses but the default tag is only for responses (as the name indicates response_json).

@roisec
Copy link
Author

roisec commented Mar 20, 2024

@thc202
I saw in history some HTTP requests and responses without the JSON tag, but they contained the header content-type: application/JSON.
Do you know why?

@kingthorin
Copy link
Member

kingthorin commented Mar 20, 2024

Tagging is based on passive scan which uses a queue, so they just may not have been processed/tagged yet.

Also the current pattern seems to be case sensitive.

@kingthorin
Copy link
Member

kingthorin commented Mar 21, 2024

Correction the patterns are all handled case insensitively in the end.

@kingthorin
Copy link
Member

Should the tag also cover other JSON'ish types?

"application/hal+json",
"application/health+json",
"application/json",
"application/octet-stream",
"application/problem+json",
"application/problem+xml",
"application/soap+xml",
"application/vnd.api+json",
"application/xml",
"application/x-ndjson",
"application/x-yaml",
"application/yaml",
"text/x-json",
"text/json",

@kingthorin
Copy link
Member

@psiinon @thc202 @ricekot thoughts?

@kingthorin
Copy link
Member

This was discussed via IRC. The decision was to not modify the existing pattern at this point. Others can be added, initially disabled.

Without further evidence of something actually misbehaving this issue will be closed.

@roisec
Copy link
Author

roisec commented Apr 9, 2024

Hi
I have several examples of HTTP responses with content-type: application/json, and there is no JSON tag on the request in ZAP.

@kingthorin
Copy link
Member

That's not evidence. Unless you can provide the details to back it up there's nothing we can do for you.

@roisec
Copy link
Author

roisec commented Apr 10, 2024

image
In the following screenshots you are able to see some requests tagged by JSON and original without.
The first request is not tagged by JSON.
When I send the same request again manually for this use case it works fine.
image

Maybe you should support: application/json; charset=utf-8
or adding with a wildcard? like "applicaiton/json*"

@kingthorin
Copy link
Member

As discussed above the existing pattern won't be updated in case anyone is depending on it in the current form. However there is already a PR in flight adding a json_extended pattern which would cover more circumstances.

@roisec
Copy link
Author

roisec commented Apr 10, 2024

@kingthorin thanks for your response,
Do you mean that there is no current solution for this bug?
Because this form does not cover tag JSON requests properly. (I can't depend on this)

@kingthorin
Copy link
Member

The solution would be to update the regex in your options.
In future versions of ZAP a new regex will be available to everyone (who chooses to enable it), but it won't replace the existing one.

@roisec
Copy link
Author

roisec commented Apr 10, 2024

Can I edit the regex currently?if yes,where?
Can I add custom tag and add custom regex for this?

@kingthorin
Copy link
Member

@roisec
Copy link
Author

roisec commented Apr 10, 2024

Ok, I checked this and configured my regex, and still, there is no automatic assignment of the relevant tag.
It's works only if I manually send the same request but not detected automatically by proxy requests.
@kingthorin wdyt?

@kingthorin
Copy link
Member

It's not retro active, it'll only tag new traffic (proxy, spider, manual), and only if your regex actually matches.
You can test with regexplanet (select Java).

@roisec
Copy link
Author

roisec commented Apr 10, 2024

I created the tag regex and then generated the traffic .
if you want I able to share with you an screen recording

@kingthorin
Copy link
Member

kingthorin commented Apr 10, 2024

🤷‍♂️ There's a ton of variables here. Your regex could be wrong/poor, you might not be waiting for the passive scan queue, you might have "only in scope" on, etc. To name a few. Unless you can provide the tag/regex and a public example of it not working then we can't recreate/troubleshoot.

@roisec
Copy link
Author

roisec commented Apr 10, 2024

The regex work perfect ,when I do the same request manually through zap the tag works properly
Tomorrow I will send a screen recording that proves it

@kingthorin
Copy link
Member

Make sure it includes the rule config and passive scan settings. Plus the message details of what is tagged and what's not.

@thc202
Copy link
Member

thc202 commented Apr 11, 2024

#8399 (comment)

The existing pattern is not a/the problem anyway, it already handles the case application/json; charset=utf-8.

@roisec
Copy link
Author

roisec commented Apr 11, 2024

Screen.Recording.2024-04-11.at.10.19.06.mov

Let's see the video,
My tag and JSON tag are recognized only in manual, but through the proxy it's not detected automatically.
This issue occurs in many sites

@thc202 thc202 changed the title Zap message history tag not cover all json scenarios Message tags might not always be reflected in the History tab Apr 11, 2024
@thc202
Copy link
Member

thc202 commented Apr 11, 2024

That's a problem with the UI not the passive scanner/regex.

@kingthorin
Copy link
Member

Things you can try:

  • On one/some of the entry(ies) after the passive scan queue has emptied (the Eyeball counter in the lower right), right click on an un-tagged entry and select "Manage History Tags" (do you see the tag there even if it wasn't shown in the table?).
  • Run this standalone community-script after the passive scan queue is empty.

@thc202
Copy link
Member

thc202 commented Apr 11, 2024

There's no need to try, it's a confirmed bug in the UI (or more accurately on how the HistoryReferences are managed).

@roisec
Copy link
Author

roisec commented Apr 11, 2024

@kingthorin I did 2 things you said, and still this is not tagged with JSON, also in "Manage History Tags".
Anyway, when the filter you implement in the PR through the API ZAP (#8422), is should be working properly?

@kingthorin
Copy link
Member

I haven't talked to @thc202 about the issue but he seems to have confirmed a UI issue, so no there will still be a piece outstanding it seems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

3 participants