diff options
author | Guilhem Moulin <guilhem@fripost.org> | 2017-06-29 10:48:35 +0200 |
---|---|---|
committer | Guilhem Moulin <guilhem@fripost.org> | 2017-06-29 10:48:39 +0200 |
commit | 15639f5b1aa607ccb4fec1a41643a3b916e0e44a (patch) | |
tree | 7461bdfba8a3936d618099c511803eb626725d8e /webserver | |
parent | 3dde7848732e6fe3f0323866b7fe06cc12748bf5 (diff) |
webserver: refuse to follow symlink when serving ACME challenge responses.
Diffstat (limited to 'webserver')
-rwxr-xr-x | webserver | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -91,7 +91,11 @@ while (1) { while (defined (my $h = $conn->getline())) { last if $h eq "\r\n" }; my ($status_line, $content_type, $content); - if ($req =~ /\A\Q$ROOT\E\/([A-Za-z0-9_\-]+)\z/ and -f $1) { + if ($req =~ /\A\Q$ROOT\E\/([A-Za-z0-9_\-]+)\z/ and + ! -l $1 and -f _) { # reuse previous stat structure and save a syscall + # XXX calling lstat(2) before open(2) is racy; if O_NOFOLLOW was + # exposed to perl we would instead use it and later fstat(2) the + # file descriptor if (open my $fh, '<', $1) { # only open files in the cwd ($status_line, $content_type) = ('200 OK', 'application/jose+json'); $content = do { local $/ = undef; $fh->getline() }; |