-
Notifications
You must be signed in to change notification settings - Fork 1
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
Lack of Input Validation in Note Creation #8
Comments
@CSGY-9223-Group3/engineering & @CSGY-9223-Group3/security |
- Add html-sanitizer library to sanitize user input - Sanitize data in create_note and update_note functions - Prevent potential XSS and injection attacks - Address issue #8: Lack of Input Validation in Note Creation This commit enhances the security of the application by implementing input sanitization for user-generated content, reducing the risk of malicious code injection.
Thank you @dr3394 for raising this important security concern, and @jjl9839 for the updated recommendation on the sanitization library. We have addressed this issue by implementing input sanitization for both note creation and updates. Here are the changes we've made:
Here's a snippet of the implemented changes: from html_sanitizer import Sanitizer
sanitizer = Sanitizer()
def create_note(note_id, user, data, is_public):
sanitized_data = sanitizer.sanitize(data)
notes[note_id] = {"text": sanitized_data, "author": user, "isPublic": is_public}
# ... rest of the function
def update_note(note_id, user, data):
if can_user_modify(user, note_id):
sanitized_data = sanitizer.sanitize(data)
notes[note_id]["text"] = sanitized_data
# ... rest of the function |
Adjusted to make it a function:
|
There is no input validation or sanitization when creating or updating a note (
create_note
,update_note
). This opens up the application to potential injection attacks, such as Cross-Site Scripting (XSS) or even command injection in the future.Use input validation and sanitization libraries to filter out or encode potentially harmful input. For Flask, libraries like
bleach
can be used to sanitize user input.The text was updated successfully, but these errors were encountered: