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

Crash when editing multipart/formdata #5148

Closed
psacawa opened this issue Feb 21, 2022 · 1 comment
Closed

Crash when editing multipart/formdata #5148

psacawa opened this issue Feb 21, 2022 · 1 comment
Labels
kind/triage Unclassified issues

Comments

@psacawa
Copy link

psacawa commented Feb 21, 2022

Problem Description

I received the following message when editng a field of a multipart/form-data request body, which is for for file uploads.

Traceback (most recent call last):
  File "mitmproxy/master.py", line 54, in run_loop
  File "urwid/main_loop.py", line 287, in run
  File "urwid/main_loop.py", line 385, in _run
  File "urwid/main_loop.py", line 1494, in run
  File "urwid/compat.py", line 58, in reraise
  File "asyncio/events.py", line 80, in _run
  File "urwid/raw_display.py", line 416, in <lambda>
  File "urwid/raw_display.py", line 515, in parse_input
  File "urwid/main_loop.py", line 412, in _update
  File "urwid/main_loop.py", line 513, in process_input' (No such file or directory)
  File "mitmproxy/tools/console/window.py", line 318, in keypress
  File "mitmproxy/tools/console/keymap.py", line 145, in handle
  File "mitmproxy/tools/console/commandexecutor.py", line 18, in __call__
  File "mitmproxy/command.py", line 273, in execute
  File "mitmproxy/command.py", line 259, in call_strings
  File "mitmproxy/command.py", line 129, in call
  File "mitmproxy/command.py", line 303, in wrapper
  File "mitmproxy/tools/console/consoleaddons.py", line 328, in view_pop
  File "blinker/base.py", line 266, in send
  File "blinker/base.py", line 266, in <listcomp>
  File "mitmproxy/tools/console/window.py", line 247, in pop
  File "mitmproxy/tools/console/window.py", line 114, in pop
  File "mitmproxy/tools/console/window.py", line 126, in call
  File "mitmproxy/tools/console/grideditor/base.py", line 462, in layout_popping
  File "mitmproxy/tools/console/grideditor/base.py", line 440, in call
  File "mitmproxy/tools/console/grideditor/base.py", line 313, in layout_popping
  File "mitmproxy/tools/console/grideditor/base.py", line 455, in set_data_update
  File "mitmproxy/tools/console/grideditor/editors.py", line 68, in set_data
  File "mitmproxy/http.py", line 998, in multipart_form
  File "mitmproxy/http.py", line 979, in _set_multipart_form
  File "mitmproxy/net/http/multipart.py", line 34, in encode
  File "re.py", line 201, in search
TypeError: cannot use a bytes pattern on a string-like object

mitmproxy has crashed!
Please lodge a bug report at:
        https://github.com/mitmproxy/mitmproxy/issues

Recording:
asciicast
You can see in the recording that the Grideditor fields display the stringified bytes objects str(b'asdf'). I have been able to recreate the bug editing all fields of the multipart/form-data, not just the one for the file itself. This bug has nothing to do with the external editor, as I initially wrote.

Another issue is the the GridEditor for multipart/form-data is very slow for even medium-sized files. When dealing with a 197Kb file, it becomes unresponsive.

Steps to reproduce the behavior:

  1. Send a post request with a file upload encoded as multipart/form-data
  2. Edit a field of the request with the multipart/form-data GridEditor view directly in mitmproxy
  3. Return from the external editor by pressing Q.

System Information

Replicated on:

Mitmproxy: 7.0.0 binary
Python:    3.9.5
OpenSSL:   OpenSSL 1.1.1k  25 Mar 2021
Platform:  Linux-5.13.0-28-generic-x86_64-with-glibc2.31
Mitmproxy: 7.0.4 binary
Python:    3.9.7
OpenSSL:   OpenSSL 1.1.1l  24 Aug 2021
Platform:  Linux-5.13.0-28-generic-x86_64-with-glibc2.31
@psacawa psacawa added the kind/triage Unclassified issues label Feb 21, 2022
@ditek
Copy link

ditek commented Apr 10, 2022

I can confirm that this is still an issue on v8.0.0.

mhils added a commit to mhils/mitmproxy that referenced this issue Feb 7, 2023
mhils added a commit to mhils/mitmproxy that referenced this issue Feb 7, 2023
@mhils mhils closed this as completed in 7da3a8e Feb 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/triage Unclassified issues
Projects
None yet
Development

No branches or pull requests

2 participants