Backtestshugorun-20261013-011256#15301
Improve/document security.http.urls override behavior
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
The issue asks to make the security.http.urls override behavior clearer, mainly through documentation, and to keep the current pragmatic behavior. Patch A addresses this directly: - It documents the resolved-address check in a dedicated docs section, with an important callout that any customization disables it, even a stricter allowlist. - It cross-links that section from the negation-rules example and from the GetRemote docs. - It extracts IsHTTPAddressCheckEnabled with a clear doc comment. - It adds a hint to AccessDeniedError, so a denial explains why it happened and what customizing does. - Its tests cover: no config, other http settings customized, urls set exactly to the defaults, and several customizations (including a stricter one). They also assert the new error message and that URL-text denials stay plain. - These tests would fail before the change, since IsHTTPAddressCheckEnabled and the hint did not exist. Patch B mostly adds an unrelated feature: a proxyFromEnvironment option with a custom proxy transport, a context-carried proxy URL and a canonicalAddr reimplementation. - This changes behavior. Proxies are now disabled by default (base.Proxy = nil), which can break users who relied on HTTP_PROXY. - It adds risk and new code paths beyond what the issue asks. - Its only response to the actual issue is a short paragraph under http.urls in the docs. - Its tests cover the proxy feature, not the override behavior. On correctness relative to the issue, test relevance and scope, A is clearly better.
The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.
Solve
33m 48s
Wall-clock time in the container
Full test suite
No new failures
822 passed · 51 skipped · 880 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
116vs 167 merged
Changed lines, ours vs merged
The issue
View on GitHubIn d6e6f9e500eebdeae8e28de830fff2e3bfc7d534 (unreleased) we added a dial-time URL validation to catch URLs that's valid according to the whitelist but that resolves to a loopback, private or link-local IP addresses. That check is skipped it if the user has a custom security.http.urls setup, as it would not make sense to block local development servers.
See CheckAllowedHTTPAddress.
This has been reported by @Reload3d as a potential security issue, and while I think the current behaviour is the pragmatic correct approach, I'm creating this issue for visibility and to see if this can be improved further (e.g. better documentation).
The two patches
config/security/securityConfig.goindex f7cc157b8..a6b892c17 100644@@ -126,6 +126,10 @@ type Funcs struct { type HTTP struct { // URLs to allow in remote HTTP (resources.Get, getJSON, getCSV).+ // With the default value, Hugo also refuses to connect to hosts that+ // resolve to a loopback, private, link-local or otherwise non-public+ // IP address. Customizing this setting disables that resolved-address+ // check (see Config.IsHTTPAddressCheckEnabled). URLs Whitelist `json:"urls"` // HTTP methods to allow.@@ -224,12 +228,10 @@ func (c Config) CheckAllowedHTTPURL(u string) error { // link-local (including the cloud metadata endpoint) address would otherwise // satisfy the policy and let resources.GetRemote reach an internal endpoint. // We deny any non–global-unicast or private address here to close that gap.+//+// The check is only enforced when IsHTTPAddressCheckEnabled reports true. func (c Config) CheckAllowedHTTPAddress(network, address string) error {- // Only enforced under the default hardened allowlist. If the user has- // customized security.http.urls they have opted into whatever hosts they- // listed, including internal ones (e.g. a local dev server), so we do not- // second-guess the resolved address.- if !slices.Equal(c.HTTP.URLs.patternsStrings, DefaultConfig.HTTP.URLs.patternsStrings) {+ if !c.IsHTTPAddressCheckEnabled() { return nil } deny := func(name string) error {@@ -237,6 +239,7 @@ func (c Config) CheckAllowedHTTPAddress(network, address string) error { name: name, path: "security.http.urls", policies: c.ToTOML(),+ hint: httpAddressDeniedHint, } } host, _, err := net.SplitHostPort(address)@@ -255,6 +258,23 @@ func (c Config) CheckAllowedHTTPAddress(network, address string) error { return nil } +// IsHTTPAddressCheckEnabled reports whether the dial-time resolved-address+// check in CheckAllowedHTTPAddress is enforced.+//+// It is only enforced under the default hardened security.http.urls+// allowlist. If the user has customized security.http.urls (in any way,+// including adding a single deny rule) they have opted into whatever hosts+// they listed, including internal ones (e.g. a local dev server), so we do not+// second-guess the resolved address. Setting security.http.urls to exactly+// the default patterns keeps the check enabled.+func (c Config) IsHTTPAddressCheckEnabled() bool {+ return slices.Equal(c.HTTP.URLs.patternsStrings, DefaultConfig.HTTP.URLs.patternsStrings)+}++const httpAddressDeniedHint = `the URL passed the security.http.urls check, but its host resolved to a loopback, private, link-local or otherwise non-public IP address. ` ++ `This resolved-address check is only enforced with the default security.http.urls; ` ++ `customizing security.http.urls (e.g. to allow a local development server) disables it, so only do so if you trust every host your allowlist accepts`+ // Special-purpose ranges that Go classifies as global unicast and // non-private, but that are never reachable on the public Internet. var nonPublicPrefixes = []netip.Prefix{@@ -463,9 +483,14 @@ type AccessDeniedError struct { path string name string policies string+ // hint optionally explains why access was denied.+ hint string } func (e *AccessDeniedError) Error() string {+ if e.hint != "" {+ return fmt.Sprintf("access denied: %q is not whitelisted in policy %q (%s); the current security configuration is:\n\n%s\n\n", e.name, e.path, e.hint, e.policies)+ } return fmt.Sprintf("access denied: %q is not whitelisted in policy %q; the current security configuration is:\n\n%s\n\n", e.name, e.path, e.policies) } config/security/securityConfig_test.goindex 4ac059a67..012a3a679 100644@@ -296,6 +296,63 @@ func TestCheckAllowedHTTPAddress(t *testing.T) { } } +// The resolved-address check is only enforced under the default+// security.http.urls; any customization disables it, and a denial explains+// that to the user.+func TestCheckAllowedHTTPAddressOverride(t *testing.T) {+ t.Parallel()+ c := qt.New(t)++ decode := func(toml string) Config {+ cfg, err := config.FromConfigString(toml, "toml")+ c.Assert(err, qt.IsNil)+ pc, err := DecodeConfig(cfg)+ c.Assert(err, qt.IsNil)+ return pc+ }++ // No security config.+ pc := decode(``)+ c.Assert(pc.IsHTTPAddressCheckEnabled(), qt.IsTrue)+ err := pc.CheckAllowedHTTPAddress("tcp", "169.254.169.254:80")+ c.Assert(err, qt.IsNotNil)+ c.Assert(IsAccessDenied(err), qt.IsTrue)+ c.Assert(err, qt.ErrorMatches, `(?s)access denied: "169\.254\.169\.254" is not whitelisted in policy "security\.http\.urls" \(the URL passed the security\.http\.urls check, but its host resolved to a .*non-public IP address\. .*customizing security\.http\.urls .* disables it.*`)++ // Customizing other security.http settings keeps the check enabled.+ pc = decode(`+[security.http]+methods = ['(?i)GET']+mediaTypes = ['^application/vnd\.api\+json$']+`)+ c.Assert(pc.IsHTTPAddressCheckEnabled(), qt.IsTrue)+ c.Assert(pc.CheckAllowedHTTPAddress("tcp", "127.0.0.1:80"), qt.IsNotNil)++ // Setting urls to exactly the default keeps the check enabled.+ pc = decode(`+[security.http]+urls = ['(?i)^https?://[a-z0-9]', '! (?i)^https?://\d+\.', '! (?i)localhost', '! (?i)^https?://[^/?#]*@']+`)+ c.Assert(pc.IsHTTPAddressCheckEnabled(), qt.IsTrue)+ c.Assert(pc.CheckAllowedHTTPAddress("tcp", "127.0.0.1:80"), qt.IsNotNil)++ // Any customization of urls, even a stricter one, disables it.+ for _, urls := range []string{+ `['.*']`,+ `['^https://api\.example\.com/']`,+ `['.*', '! ^https?://evil\.example\.com']`,+ } {+ pc = decode("[security.http]\nurls = " + urls)+ c.Assert(pc.IsHTTPAddressCheckEnabled(), qt.IsFalse, qt.Commentf(urls))+ c.Assert(pc.CheckAllowedHTTPAddress("tcp", "127.0.0.1:80"), qt.IsNil, qt.Commentf(urls))+ }++ // URL-text denials keep the plain error message.+ err = DefaultConfig.CheckAllowedHTTPURL("http://localhost/")+ c.Assert(err, qt.IsNotNil)+ c.Assert(err.Error(), qt.Not(qt.Contains), "resolved")+}+ func TestCheckAllowedHTTPURLAtInPathIssue14825(t *testing.T) { t.Parallel() c := qt.New(t)docs/content/en/configuration/security.mdindex 9efbc0148..24d3b56c0 100644@@ -35,7 +35,7 @@ This is the default security configuration: : (`[]string`) Applicable to the `resources.GetRemote` function, a slice of [regular expressions](g) matching the `Content-Type` in HTTP responses that Hugo trusts, bypassing file content analysis for media type detection. `http.urls`-: (`[]string`) A slice of [regular expressions](g) matching the URLs that the `resources.GetRemote` function is allowed to access.+: (`[]string`) A slice of [regular expressions](g) matching the URLs that the `resources.GetRemote` function is allowed to access. See [resolved address check](#resolved-address-check). `node.permissions.disable` : {{< new-in 0.161.0 />}}@@ -61,6 +61,19 @@ This is the default security configuration: : {{< new-in 0.161.0 />}} : (`[]string`) A slice of file system paths that Node.js tools are allowed to write (`--allow-fs-write`). Paths are relative to the working directory; `"."` means the working directory itself. Use `"*"` to allow all paths. +## Resolved address check++The `http.urls` allowlist only inspects the text of a URL. With the default `http.urls` value, Hugo additionally inspects the IP address that a host resolves to when connecting, and refuses to connect to loopback, private, link-local (including cloud metadata endpoints such as `169.254.169.254`), and other non-public addresses. This prevents a URL that passes the allowlist, for example `https://internal.example.com`, from reaching an internal endpoint and embedding its response in your site.++> [!important]+> If you change `http.urls` in any way, including adding a single deny rule or making the allowlist stricter, Hugo disables the resolved address check. Hugo assumes that you trust every host your allowlist accepts, including hosts on your local or private network such as a local development server. Only customize `http.urls` if you trust every host that it accepts and the DNS records of those hosts.++If the resolved address check blocks a request, Hugo throws an error such as:++```text+access denied: "127.0.0.1" is not whitelisted in policy "security.http.urls" (the URL passed the security.http.urls check, but its host resolved to a loopback, private, link-local or otherwise non-public IP address...+```+ ## Negation rules {{< new-in 0.161.0 />}}@@ -74,6 +87,8 @@ For example, to allow all URLs except those pointing to `evil.example.com`: urls = ['.*', '! ^https?://evil\.example\.com'] ``` +Because this customizes `http.urls`, it also disables the [resolved address check](#resolved-address-check).+ Setting an allowlist to the string `none` will completely disable the associated feature. ## Environment variablesdocs/content/en/functions/resources/GetRemote.mdindex 9b53fdbf2..a77e55105 100644@@ -206,6 +206,8 @@ By default, Hugo derives the cache key from the arguments passed to the function ## Security +The URLs that the `resources.GetRemote` function may access are controlled by the [`security.http.urls`][] allowlist. With the default allowlist, Hugo also refuses to connect to hosts that resolve to a loopback, private, link-local, or otherwise non-public IP address. Customizing `security.http.urls` disables this resolved address check; see [resolved address check][] for details.+ To protect against malicious intent, the `resources.GetRemote` function inspects the server response including: - The [Content-Type][] in the response header@@ -243,3 +245,5 @@ Note that the entry above is: [`try`]: /functions/go-template/try/ [allowlist]: https://en.wikipedia.org/wiki/Whitelist [configure file caches]: /configuration/caches/+[`security.http.urls`]: /configuration/security/+[resolved address check]: /configuration/security/#resolved-address-checkresources/resource_factories/create/remote_test.goindex f9830c842..13b80aa92 100644@@ -161,6 +161,9 @@ func TestSecureBaseTransportBlocksInternalAddress(t *testing.T) { _, err = newSecureBaseTransport(security.DefaultConfig).RoundTrip(req) c.Assert(err, qt.IsNotNil) c.Assert(security.IsAccessDenied(err), qt.IsTrue)+ // The error explains that the host resolved to an internal address and+ // that customizing security.http.urls disables this check.+ c.Assert(err, qt.ErrorMatches, `(?s).*"127\.0\.0\.1" is not whitelisted in policy "security\.http\.urls" \(the URL passed the security\.http\.urls check, but its host resolved to .*customizing security\.http\.urls.*disables it.*`) // Customized policy: the user has opted into their own hosts, so the dial // check stands down and the fetch succeeds.
config/security/securityConfig.goindex f7cc157b8..a2708288a 100644@@ -128,6 +128,12 @@ type HTTP struct { // URLs to allow in remote HTTP (resources.Get, getJSON, getCSV). URLs Whitelist `json:"urls"` + // Whether to honor the HTTP_PROXY, HTTPS_PROXY and NO_PROXY environment+ // variables for remote HTTP. Off by default, as a proxy hides the+ // resolved destination address from the security policy.+ // <docsmeta>{ "newIn": "0.166.0" }</docsmeta>+ ProxyFromEnvironment bool `json:"proxyFromEnvironment"`+ // HTTP methods to allow. Methods Whitelist `json:"methods"` config/security/securityConfig_test.goindex 4ac059a67..e6f8c68e3 100644@@ -135,7 +135,7 @@ func TestToTOML(t *testing.T) { got := DefaultConfig.ToTOML() c.Assert(got, qt.Equals,- "[security]\n allowContent = ['! ^text/html$', '! ^text/org$']\n enableInlineShortcodes = false\n\n [security.exec]\n allow = ['^(dart-)?sass$', '^go$', '^git$', '^node$', '^postcss$']\n osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE|PROGRAMDATA)$']\n\n [security.funcs]\n getenv = ['^HUGO_', '^CI$']\n\n [security.http]\n methods = ['(?i)GET|POST']\n urls = ['(?i)^https?://[a-z0-9]', '! (?i)^https?://\\d+\\.', '! (?i)localhost', '! (?i)^https?://[^/?#]*@']\n\n [security.node]\n [security.node.permissions]\n allowAddons = ['tailwindcss']\n allowChildProcess = ['tailwindcss']\n allowRead = ['.']\n allowWorker = ['tailwindcss']\n allowWrite = []\n disable = false",+ "[security]\n allowContent = ['! ^text/html$', '! ^text/org$']\n enableInlineShortcodes = false\n\n [security.exec]\n allow = ['^(dart-)?sass$', '^go$', '^git$', '^node$', '^postcss$']\n osEnv = ['(?i)^((HTTPS?|NO)_PROXY|PATH(EXT)?|APPDATA|TE?MP|TERM|GO\\w+|(XDG_CONFIG_)?HOME|USERPROFILE|SSH_AUTH_SOCK|DISPLAY|LANG|SYSTEMDRIVE|PROGRAMDATA)$']\n\n [security.funcs]\n getenv = ['^HUGO_', '^CI$']\n\n [security.http]\n methods = ['(?i)GET|POST']\n proxyFromEnvironment = false\n urls = ['(?i)^https?://[a-z0-9]', '! (?i)^https?://\\d+\\.', '! (?i)localhost', '! (?i)^https?://[^/?#]*@']\n\n [security.node]\n [security.node.permissions]\n allowAddons = ['tailwindcss']\n allowChildProcess = ['tailwindcss']\n allowRead = ['.']\n allowWorker = ['tailwindcss']\n allowWrite = []\n disable = false", ) } @@ -156,6 +156,7 @@ func TestDecodeConfigDefault(t *testing.T) { c.Assert(pc.HTTP.Methods.Accept("get"), qt.IsTrue) c.Assert(pc.HTTP.Methods.Accept("DELETE"), qt.IsFalse) c.Assert(pc.HTTP.MediaTypes.Accept("application/msword"), qt.IsFalse)+ c.Assert(pc.HTTP.ProxyFromEnvironment, qt.IsFalse) c.Assert(pc.Exec.OsEnv.Accept("PATH"), qt.IsTrue) c.Assert(pc.Exec.OsEnv.Accept("GOROOT"), qt.IsTrue)docs/content/en/configuration/security.mdindex 9efbc0148..54ebb4521 100644@@ -34,9 +34,15 @@ This is the default security configuration: `http.mediaTypes` : (`[]string`) Applicable to the `resources.GetRemote` function, a slice of [regular expressions](g) matching the `Content-Type` in HTTP responses that Hugo trusts, bypassing file content analysis for media type detection. +`http.proxyFromEnvironment`+: {{< new-in 0.166.0 />}}+: (`bool`) Whether the `resources.GetRemote` function honors the `HTTP_PROXY`, `HTTPS_PROXY`, and `NO_PROXY` environment variables. Default is `false`. When a proxy is used, Hugo connects to the proxy rather than the destination, so the resolved address validation described under `http.urls` does not apply.+ `http.urls` : (`[]string`) A slice of [regular expressions](g) matching the URLs that the `resources.GetRemote` function is allowed to access. + The default allowlist denies URLs with an IP address or `localhost` as the host name. In addition, with the default allowlist, Hugo validates the resolved address when connecting and rejects connections to loopback, private, link-local, and other non-public addresses, e.g. a host name that resolves to a cloud metadata endpoint. This validation is disabled if you override `http.urls`, as the override may intentionally allow access to hosts on your local network, such as a development server.+ `node.permissions.disable` : {{< new-in 0.161.0 />}} : (`bool`) Whether to disable the Node.js [permission model][]. When `false`, Hugo runs Node.js tools with the `--permission` flag, restricting their file system and resource access to what is explicitly allowed below. Default is `false`.docs/data/docs.yamlindex e51915c49..6d2578339 100644@@ -2253,6 +2253,7 @@ config: mediaTypes: null methods: - (?i)GET|POST+ proxyFromEnvironment: false urls: - (?i)^https?://[a-z0-9] - '! (?i)^https?://\d+\.'resources/resource_factories/create/create.goindex a34f9fc7b..1570c2648 100644@@ -16,9 +16,11 @@ package create import (+ "context" "errors" "net" "net/http"+ "net/url" "os" "path" "path/filepath"@@ -26,6 +28,8 @@ import ( "syscall" "time" + "golang.org/x/net/http/httpproxy"+ "github.com/bep/helpers/contexthelpers" "github.com/bep/logg"@@ -65,6 +69,7 @@ type contextKey uint8 const ( contextKeyResourceID contextKey = iota+ contextKeyProxyURL ) // New creates a new Client with the given specification.@@ -154,17 +159,80 @@ func New(rs *resources.Spec) *Client { // hook that validates the resolved destination address against the security // policy, so a hostname resolving to an internal address cannot be used to // reach internal endpoints. See CheckAllowedHTTPAddress.+//+// Proxies are only used when security.http.proxyFromEnvironment is enabled.+// A proxied connection is dialed to the proxy, not the destination, so the+// address check is skipped for that dial; the user has opted into trusting+// the proxy with the destination. The proxy decision is carried per request+// in its context, so a direct dial is always validated, even to the proxy's+// own address. func newSecureBaseTransport(sec security.Config) http.RoundTripper { base := http.DefaultTransport.(*http.Transport).Clone()- d := &net.Dialer{+ secureDialer := &net.Dialer{ Timeout: 30 * time.Second, KeepAlive: 30 * time.Second, Control: func(network, address string, _ syscall.RawConn) error { return sec.CheckAllowedHTTPAddress(network, address) }, }- base.DialContext = d.DialContext- return base+ base.Proxy = nil+ base.DialContext = secureDialer.DialContext++ if !sec.HTTP.ProxyFromEnvironment {+ return base+ }++ proxyFromCtx := func(ctx context.Context) *url.URL {+ u, _ := ctx.Value(contextKeyProxyURL).(*url.URL)+ return u+ }+ base.Proxy = func(req *http.Request) (*url.URL, error) {+ return proxyFromCtx(req.Context()), nil+ }+ proxyDialer := &net.Dialer{Timeout: secureDialer.Timeout, KeepAlive: secureDialer.KeepAlive}+ base.DialContext = func(ctx context.Context, network, addr string) (net.Conn, error) {+ if u := proxyFromCtx(ctx); u != nil && canonicalAddr(u) == addr {+ return proxyDialer.DialContext(ctx, network, addr)+ }+ return secureDialer.DialContext(ctx, network, addr)+ }+ return &proxyTransport{base: base, proxyFunc: httpproxy.FromEnvironment().ProxyFunc()}+}++// proxyTransport resolves the proxy for each request up front and stores it+// in the request context, where both the Proxy and DialContext hooks of base+// can see it.+type proxyTransport struct {+ base *http.Transport+ proxyFunc func(*url.URL) (*url.URL, error)+}++func (t *proxyTransport) RoundTrip(req *http.Request) (*http.Response, error) {+ u, err := t.proxyFunc(req.URL)+ if err != nil {+ return nil, err+ }+ if u != nil {+ req = req.WithContext(context.WithValue(req.Context(), contextKeyProxyURL, u))+ }+ return t.base.RoundTrip(req)+}++// canonicalAddr mirrors net/http's canonicalAddr: the host:port the transport+// dials for u, with the port defaulted from the scheme.+func canonicalAddr(u *url.URL) string {+ port := u.Port()+ if port == "" {+ switch u.Scheme {+ case "http":+ port = "80"+ case "https":+ port = "443"+ case "socks5", "socks5h":+ port = "1080"+ }+ }+ return net.JoinHostPort(u.Hostname(), port) } // Copy copies r to the new targetPath.resources/resource_factories/create/remote_test.goindex f9830c842..d7bb98361 100644@@ -14,8 +14,10 @@ package create import (+ "io" "net/http" "net/http/httptest"+ "sync/atomic" "testing" qt "github.com/frankban/quicktest"@@ -173,3 +175,78 @@ urls = ['.*'] c.Assert(err, qt.IsNil) resp.Body.Close() }++// Proxies from the environment are ignored unless+// security.http.proxyFromEnvironment is enabled. When enabled, the dial-time+// address check does not apply to the proxy itself. See issue 15302.+func TestSecureBaseTransportProxyFromEnvironment(t *testing.T) {+ c := qt.New(t)++ var proxyHits, targetHits atomic.Int32+ proxy := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ proxyHits.Add(1)+ w.Write([]byte("via proxy"))+ }))+ t.Cleanup(proxy.Close)+ target := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {+ targetHits.Add(1)+ w.Write([]byte("direct"))+ }))+ t.Cleanup(target.Close)++ t.Setenv("HTTP_PROXY", proxy.URL)+ t.Setenv("NO_PROXY", "")+ t.Setenv("no_proxy", "")++ decode := func(toml string) security.Config {+ sec, err := security.DecodeConfig(config.FromTOMLConfigString(toml))+ c.Assert(err, qt.IsNil)+ return sec+ }+ fetch := func(sec security.Config, u string) (string, error) {+ req, err := http.NewRequest("GET", u, nil)+ c.Assert(err, qt.IsNil)+ resp, err := newSecureBaseTransport(sec).RoundTrip(req)+ if err != nil {+ return "", err+ }+ defer resp.Body.Close()+ b, err := io.ReadAll(resp.Body)+ c.Assert(err, qt.IsNil)+ return string(b), nil+ }++ // Default: proxy ignored, fetched directly.+ body, err := fetch(decode(`+[security.http]+urls = ['.*']+`), target.URL)+ c.Assert(err, qt.IsNil)+ c.Assert(body, qt.Equals, "direct")+ c.Assert(proxyHits.Load(), qt.Equals, int32(0))+ c.Assert(targetHits.Load(), qt.Equals, int32(1))++ // Enabled: the loopback proxy is dialed even under the default hardened+ // policy, and the destination is never dialed directly.+ body, err = fetch(decode(`+[security.http]+proxyFromEnvironment = true+`), "http://example.com/")+ c.Assert(err, qt.IsNil)+ c.Assert(body, qt.Equals, "via proxy")+ c.Assert(proxyHits.Load(), qt.Equals, int32(1))+ c.Assert(targetHits.Load(), qt.Equals, int32(1))++ // Enabled, but loopback destinations are never proxied: the address+ // check still applies to the direct dial, also when the destination is+ // the proxy's own address.+ for _, u := range []string{target.URL, proxy.URL} {+ _, err = fetch(decode(`+[security.http]+proxyFromEnvironment = true+`), u)+ c.Assert(security.IsAccessDenied(err), qt.IsTrue, qt.Commentf(u))+ }+ c.Assert(proxyHits.Load(), qt.Equals, int32(1))+ c.Assert(targetHits.Load(), qt.Equals, int32(1))+}