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

Weird-byte filenames trigger internal server error on json encode #205

Closed
bast0006 opened this issue Mar 15, 2024 · 2 comments · Fixed by #209
Closed

Weird-byte filenames trigger internal server error on json encode #205

bast0006 opened this issue Mar 15, 2024 · 2 comments · Fixed by #209
Assignees
Labels
area: backend Related to internal functionality and utilities priority: 3 - low type: bug Something isn't working

Comments

@bast0006
Copy link
Contributor

bast0006 commented Mar 15, 2024

The following test code:

with open(b"\xC3.txt", "w") as f: 
  f.write("test")

Snekbox fails with a (presumably non-exploitable) 500 error:

[FALCON] [ERROR] POST /eval => Traceback (most recent call last):
File "falcon/app.py", line 386, in falcon.app.App.__call__
File "falcon/app.py", line 1070, in falcon.app.App._get_body
File "falcon/response.py", line 270, in falcon.response.Response.render_body
File "falcon/media/json.py", line 179, in falcon.media.json.JSONHandler._serialize_s	
UnicodeEncodeError: 'utf-8' codec can't encode character '\udcc3' in position 279: surrogates not allowed

This is because the filename for included files (since python-discord/bot#2326 ) doesn't handle arbitrary bytes in filenames.

Presumably safe_path (

def safe_path(path: str) -> str:
) needs to be updated to catch invalid byte sequences that will fail JSON encoding.

@bast0006 bast0006 added type: bug Something isn't working area: backend Related to internal functionality and utilities priority: 3 - low labels Mar 15, 2024
@Esther-Goldberg
Copy link
Member

Can I work on this?

@MarkKoz
Copy link
Member

MarkKoz commented Apr 7, 2024

Can I work on this?

Yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: backend Related to internal functionality and utilities priority: 3 - low type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants