Skip to content

Conversation

@jh0ker
Copy link
Member

@jh0ker jh0ker commented Apr 15, 2018

As pointed out in #1072, malicious clients can send arbitrary callback_data in callback queries, even bytes that can't be decoded using the utf-8 codec. This would bring the whole bot to a halt.

data = json.loads(decoded_s)
except UnicodeDecodeError:
logging.getLogger(__name__).debug(
'Logging raw invalid UTF-8 response:\n%s', str(json_data))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Python 2 str is the byte array type, so str(json_data) is a noop (the bogus UTF-8 will enter the logging stream). I didn't realize str(b'...') was the same as repr(b'...') in Python 3 until I just tried it, is that what you were intending? What about just ('Logging raw invalid UTF-8 response:\n%r', json_data)?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's better :)

@tsnoam tsnoam merged commit b77b329 into master Apr 17, 2018
@jsmnbom jsmnbom deleted the malicious-callback-data branch September 1, 2018 17:47
@github-actions github-actions bot locked and limited conversation to collaborators Aug 21, 2020
@Bibo-Joshi Bibo-Joshi added 🔌 bug pr description: bug and removed bug 🐛 labels Nov 3, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

🔌 bug pr description: bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants