Skip to content

No input sanitisation  #4

Description

@fraserc6

Hey Donald,

As part of a University led project I am looking for an open source project with a security issue.
The project entails that once a security issue has been found, we develop a patch and inform the developer(s).

We have found that within your chat application that there is no sanitation performed on the users input before it is emitted for other users to view. This vulnerability can be exploited in a variety of ways such as leveraging the injection of HTML, CSS and JavaScript into other clients’ browsers to perform XSS.

The solution is very simple - you simply need to sanitise the users input before emitting it back into the system for others to view.

We want to add the following sanitise function into the top of the chat.js file (or somewhere more suitable if you prefer):

function sanitise(str) { return String(str).replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;'); }

Once this has been added, we want to edit the sendButton.onclick function to include this sanitation.
Simply wrap field.value and name.value with the sanitation function when emitting.

socket.emit('send', { message: sanitise(field.value), username: sanitise(name.value) });

That should then resolve the issue.

I have attached an amended chat.js for your convenience

chat.zip

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions