You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Protect static file routes from directory traversal attacks.
Currently using a URL like
`http://baseURL/../../../../../../../../../../../../../../../../etc/passwd`
returns the file `/etc/passwd`. That of course is a security
vulnerability that should not happen.
This was recently discovered and fixed for webwork2, and basically the
same solution is used to fix it here.
Below is a minimal script that can be used to test this:
```perl
use Mojo::Base -strict;
use Mojo::UserAgent;
my $server = 'http://localhost:3001';
my $ua = Mojo::UserAgent->new;
my $res = $ua->get("$server/../../../../../../../../../../../../../../../../etc/passwd")->result;
if ($res->is_success) { say 'success'; say $res->body }
elsif ($res->is_error) { say 'error'; say $res->message }
elsif ($res->code == 301) { say '301'; say $res->headers->location }
else { say 'Whatever...' }
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
```
Set `$server` to the URL of your renderer including the `$baseURL`.
With the develop branch the above script will output "success" followed
by the contents of the `/etc/passwd` file on your server. With this
branch it will output "error" followed by "Not found".
0 commit comments