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

Fix security bugs #34

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Fix security bugs #34

wants to merge 5 commits into from

Conversation

rgooler
Copy link

@rgooler rgooler commented Nov 17, 2019

I was interested in using this code, but upon quick review, I noticed that there was insufficient protection against SQL and JSON injection. So I made a quick PR to fix the issues.

Brief summary: is_numeric isn't a defense against SQL injection, as an attacker can encode their injection as a hexadecimal number instead of ascii text - and it will pass is_numeric, but be decoded by the sql server before execution. The solution is just to cast it to an integer, which isn't large enough to hold a dangerous pile of SQL

The JSON injection comes from the fact that you were taking unsanitized data (messages containing things like usernames), and then just concatenating strings to make the curl query. This could have unexpected/dangerous results, so instead of concatenating strings, I build a PHP object and let php safely convert that to json, with all the proper escaping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant