Repository navigation
fix(docker): do not serve dotfiles from the default Caddyfile - #2804
Open
shinsenter wants to merge 3 commits into
Open
shinsenter wants to merge 3 commits into
shinsenter wants to merge 3 commits into
Conversation
shinsenter
force-pushed
the
fix/hide-dotfiles
branch
from
November 3, 2026 08:31
93ae669 to
332040a
Compare
shinsenter
force-pushed
the
fix/hide-dotfiles
branch
from
November 3, 2026 08:32
332040a to
a407fbe
Compare
Member
|
I wonder is this doesn't belong in the Caddy file server directly |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The default Caddyfile used by the Docker image serves dotfiles.
php_serverincludesfile_server, and Caddy serves hidden files unless told not to. A.envor.git/configin the document root can be downloaded.To reproduce:
This returns 200 with
secret./.git/configdoes the same.The fix adds a matcher to the site block that returns 404 when any path segment starts with a dot, except under
/.well-known/.respondruns beforephp_server, so PHP files and the front controller still work. I usedpath_regexpplus anot pathcondition because Caddy's regexp engine (RE2) has no lookahead.I mounted the changed Caddyfile into
dunglas/frankenphp:latest(v1.13.4, Caddy v2.11.7) with apublic/folder that has.env,.git/config,sub/.env,.well-known/security.txtandindex.php:/.env/.git/config/sub/.env/.well-known/security.txt/index.phpNo Go code changes, so I did not run
go test.I left
package/Caddyfilealone. It only serves the default page from/usr/share/frankenphp/.The default changes for anyone who serves a dotfile on purpose. They can still do it with their own Caddyfile or
CADDY_SERVER_EXTRA_DIRECTIVES. I'm sending this as a hardening change to the default config, not as a vulnerability in FrankenPHP, sinceSECURITY.mdasks for those to be reported privately.