Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

1,955 views
Skip to first unread message

Mhidi Bousselham

unread,
Jan 28, 2022, 5:34:47 AM1/28/22
to OWASP ZAP Developer Group
Hello ! 
I'm new in ZAP Owasp, 
I've copy past script many scripts from the zaproxy/community-scripts 
However, During the scans I always see the below error without the predicted results.

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

^
Parsing message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof

psiinon

unread,
Jan 28, 2022, 5:39:57 AM1/28/22
to OWASP ZAP Developer Group
Thats typically caused by a script trying to parse an HTTP response body as JSON when its not JSON.
You can just ignore those messages.
Unless you fancy working out which script is doing that and submitting a fix? :)

Cheers,

Simon

Mhidi Bousselham

unread,
Feb 2, 2022, 10:26:32 AM2/2/22
to OWASP ZAP Developer Group
Thank you for your reactivity !

Basically, I use this simple script from proxy, where no body is called :/ 
I can't also see the content of the print function


"""
The proxyRequest and proxyResponse functions will be called for all requests  and responses made via ZAP,
excluding some of the automated tools
If they return 'false' then the corresponding request / response will be dropped.
You can use msg.setForceIntercept(true) in either method to force a break point

Note that new proxy scripts will initially be disabled
Right click the script in the Scripts tree and select "enable"  
"""

def proxyRequest(msg):
  # Debugging can be done using print like this
  print('proxyRequest called for url=' + msg.getRequestHeader().getURI().toString());
  return True;

def proxyResponse(msg):
  # Debugging can be done using print like this
  print('proxyResponse called for url=' + msg.getRequestHeader().getURI().toString());
  return True;

Screenshot 2022-02-02 at 16.24.33.png



kingthorin+owaspzap

unread,
Feb 2, 2022, 11:28:52 AM2/2/22
to OWASP ZAP Developer Group
> I've copy past script many scripts from the zaproxy/community-scripts 

So you've disabled/removed them all but that one single proxy script? (That seems unlikely given the output you're reporting.)

thc...@gmail.com

unread,
Feb 2, 2022, 4:32:45 PM2/2/22
to zaproxy...@googlegroups.com
Those errors messages are caused by a GraphQL add-on script, which was
already fixed, just pending a release.

Best regards.

On 02/02/2022 16:28, kingthorin+owaspzap wrote:
>> I've copy past script many scripts from the zaproxy
> <https://github.com/zaproxy>/*community-scripts
> <https://github.com/zaproxy/community-scripts> *
>>>> <https://github.com/zaproxy>/*community-scripts
>>>> <https://github.com/zaproxy/community-scripts> *

Mhidi Bousselham

unread,
Feb 3, 2022, 4:57:49 AM2/3/22
to OWASP ZAP Developer Group

Can you please help me to print results (use print function) because it doesn’t work in order to debug ? 

psiinon

unread,
Feb 3, 2022, 5:56:17 AM2/3/22
to OWASP ZAP Developer Group
The fixed GraphQL add-on has been released.

We can help with problems but only if you ask specific questions :)

Cheers,

Simon

Mhidi Bousselham

unread,
Feb 3, 2022, 6:13:39 AM2/3/22
to OWASP ZAP Developer Group
Hello,

Thank you psiinon,
As you can see in my simple proxy code, there is a print function that it doesn’t works , 
All what I can see is the magical error messages x (N times)  "message body failed: Invalid JSON: <json>:1:0 Expected json literal but found eof".

Screenshot 2022-02-03 at 12.12.57.png

psiinon

unread,
Feb 3, 2022, 6:16:54 AM2/3/22
to OWASP ZAP Developer Group
First things first, is the script enabled?

Mhidi Bousselham

unread,
Feb 3, 2022, 6:22:07 AM2/3/22
to OWASP ZAP Developer Group
Yes the script is enabled, 
I forgot to specify that I use OWASP ZAP 2.11.1 in MAC OS.

psiinon

unread,
Feb 3, 2022, 11:00:53 AM2/3/22
to OWASP ZAP Developer Group
See the second button on your screenshot?
If you hover over it you will see "Disable clear output script panel on run".
Deselect it.
That option clears the output panel everytime a script runs. The fact that you are getting those other messages means that you have other scripts enabled .
I'm guessing your script _is_ writing to the output panel but then another passive script runs after it and clears the panel.

Mhidi Bousselham

unread,
Feb 4, 2022, 8:28:26 AM2/4/22
to OWASP ZAP Developer Group
I've create an empty session with only 1 proxy script from the proxy template (The script in screenshoot), also, I've disabled clear output script panel on run option. However, I still dont see the output of the print (print('proxyRequest called for url=' + msg.getRequestHeader().getURI().toString()); ) 

Screenshot 2022-02-04 at 14.25.44.png

 

thc...@gmail.com

unread,
Feb 4, 2022, 8:38:32 AM2/4/22
to zaproxy...@googlegroups.com
The Proxy scripts are not executed for active scan requests, if you want
for those you need to use a HTTP Sender script.

Best regards.

Mhidi Bousselham

unread,
Feb 7, 2022, 10:40:55 AM2/7/22
to OWASP ZAP Developer Group
Thank you so much  for your response , that was exactly the reason.
That works perfectly with HTTP Sender :) 

Reply all
Reply to author
Forward
0 new messages