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

JSON payload includes an extra space when using python scripts #7

Closed
Draoken opened this issue Feb 21, 2024 · 4 comments · Fixed by #11 · May be fixed by PortSwigger/pycript#2
Closed

JSON payload includes an extra space when using python scripts #7

Draoken opened this issue Feb 21, 2024 · 4 comments · Fixed by #11 · May be fixed by PortSwigger/pycript#2
Assignees
Labels
bug Something isn't working

Comments

@Draoken
Copy link

Draoken commented Feb 21, 2024

Have you gone through the Documentation or Video Tutorial

Describe the bug
When you use the automatic encryption feature with Python along with the Request Type of parameter value, the resulting payload adds an additional space in the json body causing an error. It is between the key and the value (after the colon).

To Reproduce
Steps to reproduce the behavior:

  1. Configure settings similar to screenshot below
  2. Use automatic encrypt function with a JSON request
  3. Observe the extra space in the resulting request in the Logger/Comparer tab of BurpSuite

Expected behavior
An extra space should not be added, the payload should sit exactly in the same spot as before.
This is not an issue with the encrypting script, as the resulting payload is exactly correct. Removing the space causes the request to successfully pass.

Screenshots
image
image

Desktop (please complete the following information):

  • PyCript Version .3
@Draoken Draoken added the bug Something isn't working label Feb 21, 2024
@Anof-cyber
Copy link
Owner

Is it possible to share the json request body (if you can update the value with dummy value).

Also can you confirm if it only happens with auto encrypt? Or is it same when click on pycript tab in repeater.

By default pycript tries to beautify the json, can you check if its same in raw and pretty within request.

@Draoken
Copy link
Author

Draoken commented Feb 21, 2024

It is the same when you click on pycript tab in repeater.

image

I found the exact spot that I was able to fix the issue. The red highlight is where it's adding a space, and I added my "fix" below it in green. I'm sure you can find something more elegant than what I did.

image

@Anof-cyber
Copy link
Owner

Anof-cyber commented Feb 21, 2024

Just for reference, can you confirm if the back-end application/API (the one you are working on in the screenshot) gives any error if space are there.

Its a default python JSON behaviour to add spaces when json.dump is used.

@Draoken
Copy link
Author

Draoken commented Feb 21, 2024

Yes, that's why I had to fix it this as the space was breaking the server response

Anof-cyber added a commit that referenced this issue Jul 3, 2024
@Anof-cyber Anof-cyber mentioned this issue Jul 6, 2024
@Anof-cyber Anof-cyber linked a pull request Jul 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants