]> git.maquefel.me Git - brevno-suite/hugo/commit
config/security: Add "! " negation to Whitelist, harden default http.urls
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 22 Apr 2026 14:25:38 +0000 (16:25 +0200)
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Wed, 22 Apr 2026 18:15:19 +0000 (20:15 +0200)
commit79f030be5bdb31e014c2996da7464898df750801
treeaa220c2ddf992d40d975b7ca8edb0a9919b2aa46
parent896bc89ab8f4badfa90240503cf964a9e445b028
config/security: Add "! " negation to Whitelist, harden default http.urls

Whitelist now treats any pattern prefixed with "! " (the same negation
prefix used by hglob/predicate) as a deny rule. Deny matches take
precedence over allow, and a whitelist made up exclusively of deny
rules implicitly allows everything it does not deny.

The default security.http.urls now reads:

    urls = ['(?i)^https?://[a-z]', '! (?i)localhost', '! @']

i.e. allow URLs whose host starts with a letter (the common
"https://example.com" shape), deny anything that looks like localhost,
and deny URLs with userinfo to foil "http://user@127.0.0.1/" bypasses.
Public IP literals are collateral blocks; users who need them (or their
own private hosts) override security.http.urls as before, mixing allow
and deny rules with the same "! " prefix, e.g.

    [security.http]
    urls = ['.*', '! ^https?://evil\.example\.com']

Fixes #14792
config/security/securityConfig.go
config/security/securityConfig_test.go
config/security/whitelist.go
config/security/whitelist_test.go
hugolib/resource_chain_test.go
hugolib/securitypolicies_test.go
tpl/openapi/openapi3/openapi3_integration_test.go