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

Prevent requesting arbitrary file paths via socket #158

Merged
merged 1 commit into from
Feb 4, 2016

Conversation

e2
Copy link
Contributor

@e2 e2 commented Feb 4, 2016

In certain situations, specially crafted HTTP GET requests on the
livereload socket (default: 35729) may cause any user readable file to
be sent over that socket.

Temporarily in this patch, requests for readable files now result in 403
HTTP error responses. The exception is of course the file
'./livereload.js'.

Security vulnerability example:

Accessing the socket on localhost:35729 and requesting:

./../../etc/passwd (note the single leading dot)

to be expanded to "../../../etc/passwd", which may effectively serve the
contents of /etc/passwd.

In certain situations, specially crafted HTTP GET requests on the
livereload socket (default: 35729) may cause any user readable file to
be sent over that socket.

Temporarily in this patch, requests for readable files now result in 403
HTTP error responses. The exception is of course the file
'./livereload.js'.

Security vulnerability example:

Accessing the socket on localhost:35729 and requesting:

  ./../../etc/passwd (note the single leading dot)

to be expanded to "../../../etc/passwd", which may effectively serve the
contents of /etc/passwd.
@@ -6,6 +6,9 @@
module Guard
class LiveReload
class WebSocket < EventMachine::WebSocket::Connection
HTTP_DATA_FORBIDDEN = "HTTP/1.1 403 Forbidden\r\nContent-Type: text/plain\r\nContent-Length: 13\r\n\r\n403 Forbidden"
HTTP_DATA_NOT_FOUND = "HTTP/1.1 404 Not Found\r\nContent-Type: text/plain\r\nContent-Length: 13\r\n\r\n404 Not Found"

Choose a reason for hiding this comment

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

Freeze mutable objects assigned to constants.

e2 added a commit that referenced this pull request Feb 4, 2016
Prevent requesting arbitrary file paths via socket
@e2 e2 merged commit 0e98469 into master Feb 4, 2016
@e2 e2 deleted the fix_path_traversal_vulnerability branch February 4, 2016 02:08
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.

2 participants