Fix dir traversal by percent-encoding dots

release/1.3.2
Lauri Kasanen 11 months ago
parent 9f7a6b58ce
commit 4b18320984
No known key found for this signature in database

@ -917,6 +917,12 @@ static void servefile(ws_ctx_t *ws_ctx, const char *in, const char * const user,
percent_decode(path, buf, 1); percent_decode(path, buf, 1);
// in case they percent-encoded dots
if (strstr(buf, "../")) {
handler_msg("Attempted dir traversal attack, rejecting\n", len);
goto nope;
}
handler_msg("Requested file '%s'\n", buf); handler_msg("Requested file '%s'\n", buf);
sprintf(fullpath, "%s/%s", settings.httpdir, buf); sprintf(fullpath, "%s/%s", settings.httpdir, buf);

Loading…
Cancel
Save