-
Notifications
You must be signed in to change notification settings - Fork 6
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
Validate verification code input before sending it #103
Conversation
This makes sure that the verification code only contains characters a-z A-Z 0-9, and is of limited length. Otherwise it is possible for a user to cause arbitrary data to be sent to the server, including invalid JSON. This could be a problem if the JSON parser on the receiving end has bugs. For example, code input 'A"}BBBBBBBB...' would lead to JSON data '{"session_id":"SESSIONID","pin":"A"}BBBBBBBB..."}' to be sent to the server.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #103 +/- ##
==========================================
+ Coverage 72.51% 72.87% +0.35%
==========================================
Files 6 6
Lines 302 306 +4
Branches 47 47
==========================================
+ Hits 219 223 +4
Misses 71 71
Partials 12 12 ☔ View full report in Codecov by Sentry. |
Hooray for unit tests!
When using pamtester to test the PR, I get a segmentation fault on and empty code response:
It would be nice if you could extend the validation to the username input and return a
|
I fixed the segfault - I overlooked that tty_input() returns NULL on empty input. This can also bite the group input, I opened PR #104 for this. I will extent this to cover user names in a separate |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Martin!
Thanks for this PR. Looks good in principle, but I think we should be a bit more careful with the string manipulations (see comments).
This makes sure that the verification code only contains characters a-z A-Z 0-9, and is of limited length.
Otherwise it is possible for a user to cause arbitrary data to be sent to the server, including invalid JSON. This could be a problem if the JSON parser on the receiving end has bugs.
For example, code input 'A"}BBBBBBBB...' would lead to JSON data '{"session_id":"SESSIONID","pin":"A"}BBBBBBBB..."}' to be sent to the server.